[java-identity-provider] 05/06: IDP-1499 Installer: Revert removal of some tasks
Rod Widdowson
rdw at steadingsoftware.com
Thu Oct 24 12:00:34 EDT 2019
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=a8ebb8279d3d204674320d77ca3e2d9be5b4f727
commit a8ebb8279d3d204674320d77ca3e2d9be5b4f727
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Oct 24 10:08:53 2019 +0100
IDP-1499 Installer: Revert removal of some tasks
selfsignedcert, mergeproperties and rewriteproperties are used by the jetty
install script (currently only used by Windows)
This partially reverts commit db9c4ded6d921eb9c04adb06f591b85e2edb50a0.
https://issues.shibboleth.net/jira/browse/IDP-1499
---
.../net/shibboleth/idp/installer/V4Install.java | 2 +-
.../ant/impl/BasicKeystoreKeyStrategyTask.java | 128 +++++++++++++
.../installer/ant/impl/MergePropertiesTask.java | 128 +++++++++++++
.../installer/ant/impl/MetadataGeneratorTask.java | 209 +++++++++++++++++++++
.../installer/ant/impl/RewritePropertiesTask.java | 117 ++++++++++++
.../impl/SelfSignedCertificateGeneratorTask.java | 171 +++++++++++++++++
.../resources/net/shibboleth/idp/installer/ant.xml | 3 +
.../idp/installer/metadata-generator-ant.xml | 19 ++
8 files changed, 776 insertions(+), 1 deletion(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
index cf7981c..b753acf 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
@@ -340,7 +340,7 @@ public class V4Install extends AbstractInitializableComponent {
}
final Resource resource = new ClassPathResource("net/shibboleth/idp/installer/metadata-generator.xml");
final GenericApplicationContext context = new ApplicationContextBuilder()
- .setName(V4Install.class.getName())
+ .setName(MetadataGenerator.class.getName())
.setServiceConfigurations(Collections.singletonList(resource))
.setContextInitializer(new Initializer())
.build();
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/BasicKeystoreKeyStrategyTask.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/BasicKeystoreKeyStrategyTask.java
new file mode 100644
index 0000000..6b0963f
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/BasicKeystoreKeyStrategyTask.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.installer.ant.impl;
+
+import java.io.File;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
+import net.shibboleth.utilities.java.support.security.BasicKeystoreKeyStrategyTool;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * Wrapper around {@link BasicKeystoreKeyStrategyTool}.
+ */
+public class BasicKeystoreKeyStrategyTask extends Task {
+
+ /** encapsulated {@link BasicKeystoreKeyStrategyTool}.*/
+ private BasicKeystoreKeyStrategyTool tool;
+
+ /** Constructor. */
+ public BasicKeystoreKeyStrategyTask() {
+ tool = new BasicKeystoreKeyStrategyTool();
+ }
+
+ /**
+ * Set the type of key that will be generated. Defaults to AES.
+ *
+ * @param type type of key that will be generated
+ */
+ public void setKeyType(@Nonnull @NotEmpty final String type) {
+ tool.setKeyType(type);
+ }
+
+ /**
+ * Set the size of the generated key. Defaults to 128
+ *
+ * @param size size of the generated key
+ */
+ public void setKeySize(@Positive final int size) {
+ tool.setKeySize(size);
+ }
+
+ /**
+ * Set the encryption key alias base name.
+ *
+ * @param alias the encryption key alias base
+ */
+ public void setKeyAlias(@Nonnull @NotEmpty final String alias) {
+ tool.setKeyAlias(alias);
+ }
+
+ /**
+ * Set the number of keys to maintain. Defaults to 3.
+ *
+ * @param count number of keys to maintain
+ */
+ public void setKeyCount(@Positive final int count) {
+ tool.setKeyCount(count);
+ }
+
+ /**
+ * Set the type of keystore to create. Defaults to JCEKS.
+ *
+ * @param type keystore type
+ */
+ public void setKeystoreType(@Nonnull @NotEmpty final String type) {
+ tool.setKeystoreType(type);
+ }
+
+ /**
+ * Set the keystore file to create or modify.
+ *
+ * @param file keystore file
+ */
+ public void setKeystoreFile(@Nonnull final File file) {
+ tool.setKeystoreFile(file);
+ }
+
+ /**
+ * Set the password for the keystore.
+ *
+ * @param password password for the keystore
+ */
+ public void setKeystorePassword(@Nullable final String password) {
+ tool.setKeystorePassword(password);
+ }
+
+ /**
+ * Set the key versioning file to create or modify.
+ *
+ * @param file key versioning file
+ */
+ public void setVersionFile(@Nonnull final File file) {
+ tool.setVersionFile(file);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void execute() {
+ try {
+ tool.changeKey();
+ } catch (final Exception e) {
+ log("Build failed", e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+ }
+}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MergePropertiesTask.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MergePropertiesTask.java
new file mode 100644
index 0000000..89e7652
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MergePropertiesTask.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.installer.ant.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.idp.installer.PropertiesWithComments;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * A class to merge a property file into another property file, preserving the comments.
+ */
+public class MergePropertiesTask extends Task {
+
+ /** The input file. */
+ private File inFile;
+
+ /** The output file. */
+ private File outFile;
+
+ /** The merge file. */
+ private File mergeFile;
+
+ /** Set the input file.
+ * @param what what to set
+ */
+ public void setInFile(@Nonnull final File what) {
+ inFile = Constraint.isNotNull(what, "Provided file must not be null");
+ }
+
+ /** Set the output file.
+ * @param what what to set
+ */
+ public void setOutFile(@Nonnull final File what) {
+ outFile = Constraint.isNotNull(what, "Provided file must not be null");
+ }
+
+ /** Set the merge file.
+ * @param what what to set
+ */
+ public void setMergeFile(@Nonnull final File what) {
+ mergeFile = Constraint.isNotNull(what, "Provided file must not be null");
+ }
+
+ /** {@inheritDoc} */
+ // Checkstyle: CyclomaticComplexity OFF
+ @Override
+ public void execute() {
+ if (null == inFile) {
+ log("Input file not provided", Project.MSG_ERR);
+ throw new BuildException("Input file not provided");
+ }
+ if (!inFile.exists()) {
+ log("Input file " + inFile.getAbsolutePath() + " does not exist");
+ throw new BuildException("Non-existent input file");
+ }
+ if (null == outFile) {
+ log("Output file not provided", Project.MSG_ERR);
+ throw new BuildException("Output file not provided");
+ }
+ if (null == mergeFile) {
+ log("Merge file not provided", Project.MSG_ERR);
+ throw new BuildException("Non-existent input file");
+ }
+ if (!mergeFile.exists()) {
+ log("Input file " + mergeFile.getAbsolutePath() + " does not exist");
+ throw new BuildException("Non-existent merge file");
+ }
+
+ final PropertiesWithComments in = new PropertiesWithComments();
+
+ try (final FileInputStream stream = new FileInputStream(inFile)) {
+ in.load(stream);
+ } catch (final IOException e) {
+ log("Could not load input " + inFile.getAbsolutePath(), e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+
+ final Properties merge = new Properties();
+ try (final FileInputStream stream = new FileInputStream(mergeFile)) {
+ merge.load(stream);
+ } catch (final IOException e) {
+ log("Could not load merge " + mergeFile.getAbsolutePath(), e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+
+
+ for (final Object propName:merge.keySet()) {
+ if (propName instanceof String) {
+ final String name = (String) propName;
+ in.replaceProperty(name, merge.getProperty(name));
+ }
+ }
+
+ try (final FileOutputStream stream = new FileOutputStream(outFile)) {
+ in.store(stream);
+ } catch (final IOException e) {
+ log("Could not store output " + outFile.getAbsolutePath(), e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+ }
+ // Checkstyle: CyclomaticComplexity ON
+}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MetadataGeneratorTask.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MetadataGeneratorTask.java
new file mode 100644
index 0000000..3f40b66
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MetadataGeneratorTask.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.installer.ant.impl;
+
+import java.io.File;
+import java.util.Collections;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+import net.shibboleth.ext.spring.util.ApplicationContextBuilder;
+import net.shibboleth.idp.installer.metadata.impl.MetadataGeneratorImpl;
+import net.shibboleth.idp.installer.metadata.impl.MetadataGeneratorParametersImpl;
+import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
+
+/**
+ * Task to generate metadata.
+ */
+public class MetadataGeneratorTask extends Task {
+
+ /** Where we collect the parameters. */
+
+ /** where to put the data. */
+ private File outputFile;
+
+ /** Where idp.home is. */
+ @Nullable private String idpHome;
+
+ /** Ant level override for the back channel certificate. */
+ @Nullable private File backchannelCert;
+
+ /** Ant level override for the DNS name. */
+ @Nullable private String dnsName;
+
+ /**
+ * Whether to comment out the SAML2 AA port.
+ */
+ private boolean saml2AttributeQueryCommented = true;
+
+ /**
+ * Whether to comment out the SAML2 SLO endpoints.
+ */
+ private boolean saml2LogoutCommented = true;
+
+ /**
+ * Where is idp.home.
+ *
+ * @return Returns idpHome.
+ */
+ @Nullable public String getIdpHome() {
+ return idpHome;
+ }
+
+ /**
+ * Set where where is idp.home.
+ *
+ * @param home The idpHome to set.
+ */
+ public void setIdpHome(@Nullable final String home) {
+ idpHome = home;
+ }
+
+ /**
+ * Set the output file.
+ *
+ * @param file what to set.
+ */
+ public void setOutput(final File file) {
+
+ outputFile = file;
+ }
+
+ /**
+ * Set the Backchannel Certificate file.
+ *
+ * @param file what to set.
+ */
+ public void setBackchannelCert(final File file) {
+ backchannelCert = file;
+ }
+
+ /**
+ * Sets the dns name.
+ *
+ * @param name what to set.
+ */
+ public void setDnsName(final String name) {
+ dnsName = name;
+ }
+
+ /**
+ * Returns whether to comment the SAML2 AA endpoint.
+ *
+ * @return Returns when to comment the SAML2 AA endpoint.
+ */
+ public boolean isSAML2AttributeQueryCommented() {
+ return saml2AttributeQueryCommented;
+ }
+
+ /**
+ * Sets whether to comment the SAML2 AA endpoint.
+ *
+ * @param asComment whether to comment or not.
+ */
+ public void setSAML2AttributeQueryCommented(final boolean asComment) {
+ saml2AttributeQueryCommented = asComment;
+ }
+
+ /**
+ * Returns whether to comment the SAML2 Logout endpoints.
+ *
+ * @return whether to comment the SAML2 Logout endpoints
+ */
+ public boolean isSAML2LogoutCommented() {
+ return saml2LogoutCommented;
+ }
+
+ /**
+ * Sets whether to comment the SAML2 Logout endpoints.
+ *
+ * @param asComment whether to comment or not
+ */
+ public void setSAML2LogoutCommented(final boolean asComment) {
+ saml2LogoutCommented = asComment;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute() {
+ try {
+ final MetadataGeneratorParametersImpl parameters;
+
+ final Resource resource = new ClassPathResource("net/shibboleth/idp/installer/metadata-generator-ant.xml");
+
+ final GenericApplicationContext context = new ApplicationContextBuilder()
+ .setName(MetadataGeneratorTask.class.getName())
+ .setServiceConfigurations(Collections.singletonList(resource))
+ .setContextInitializer(new Initializer())
+ .build();
+
+ parameters = context.getBean("IdPConfiguration", MetadataGeneratorParametersImpl.class);
+
+ parameters.setBackchannelCert(backchannelCert);
+ parameters.setDnsName(dnsName);
+ parameters.initialize();
+
+ final MetadataGeneratorImpl generator = new MetadataGeneratorImpl();
+ generator.setSAML2AttributeQueryCommented(saml2AttributeQueryCommented);
+ generator.setSAML2LogoutCommented(saml2LogoutCommented);
+ generator.setParameters(parameters);
+ generator.setOutput(outputFile);
+ generator.initialize();
+ generator.generate();
+
+ } catch (final Exception e) {
+ log("Build failed", e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+ }
+
+ // Checkstyle: CyclomaticComplexity ON
+
+ /**
+ * An initializer which knows about our idp.home.
+ *
+ */
+ public class Initializer extends IdPPropertiesApplicationContextInitializer {
+
+ /** {@inheritDoc} */
+ @Override @Nonnull public String selectSearchLocation(
+ @Nonnull final ConfigurableApplicationContext applicationContext) {
+ if (null == idpHome) {
+ return super.selectSearchLocation(applicationContext);
+ }
+ return idpHome;
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nonnull public String getSearchLocation() {
+ if (null == idpHome) {
+ return super.getSearchLocation();
+ }
+ return idpHome;
+ }
+
+ }
+}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/RewritePropertiesTask.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/RewritePropertiesTask.java
new file mode 100644
index 0000000..8c86320
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/RewritePropertiesTask.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.installer.ant.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.idp.installer.PropertiesWithComments;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * A class to rename the property names in a property file, preserving the comments.
+ */
+public class RewritePropertiesTask extends Task {
+
+ /** The input file. */
+ private File inFile;
+
+ /** The output file. */
+ private File outFile;
+
+ /** The names file. */
+ private File propertyNameFile;
+
+ /** Set the input file.
+ * @param what what to set
+ */
+ public void setInFile(@Nonnull final File what) {
+ inFile = Constraint.isNotNull(what, "Provided file must not be null");
+ }
+
+ /** Set the output file.
+ * @param what what to set
+ */
+ public void setOutFile(@Nonnull final File what) {
+ outFile = Constraint.isNotNull(what, "Provided file must not be null");
+ }
+
+ /** Set the merge file.
+ * @param what what to set
+ */
+ public void setPropertyNameFile(@Nonnull final File what) {
+ propertyNameFile = Constraint.isNotNull(what, "Provided file must not be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void execute() {
+ if (null == inFile) {
+ log("Input file not provided", Project.MSG_ERR);
+ throw new BuildException("Input file not provided");
+ }
+ if (!inFile.exists()) {
+ log("Input file " + inFile.getAbsolutePath() + " does not exist");
+ throw new BuildException("Non-existent input file");
+ }
+ if (null == outFile) {
+ log("Output file not provided", Project.MSG_ERR);
+ throw new BuildException("Non-existent output file");
+ }
+
+ if (null == propertyNameFile) {
+ log("Property Name file not provided", Project.MSG_ERR);
+ throw new BuildException("Non-existent input file");
+ }
+ if (!propertyNameFile.exists()) {
+ log("Input file " + propertyNameFile.getAbsolutePath() + " does not exist");
+ throw new BuildException("Non-existent property file");
+ }
+
+ final PropertiesWithComments properties = new PropertiesWithComments();
+ try (final InputStream in = new FileInputStream(propertyNameFile)) {
+ properties.loadNameReplacement(in);
+ } catch (final IOException e) {
+ log("Could not load name replacements " + propertyNameFile.getAbsolutePath(), e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+
+ try (final InputStream in = new FileInputStream(inFile)) {
+ properties.load(in);
+ } catch (final IOException e) {
+ log("Could not load input " + inFile.getAbsolutePath(), e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+
+ try (final FileOutputStream out = new FileOutputStream(outFile)) {
+ properties.store(out);
+ } catch (final IOException e) {
+ log("Could not store output " + outFile.getAbsolutePath(), e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+ }
+}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/SelfSignedCertificateGeneratorTask.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/SelfSignedCertificateGeneratorTask.java
new file mode 100644
index 0000000..73d85e9
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/SelfSignedCertificateGeneratorTask.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.installer.ant.impl;
+
+import java.io.File;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+import net.shibboleth.utilities.java.support.security.SelfSignedCertificateGenerator;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * Task to shim around {@link SelfSignedCertificateGenerator}.
+ */
+public class SelfSignedCertificateGeneratorTask extends Task {
+
+ /** Our wrapped {@link SelfSignedCertificateGenerator}. */
+ private SelfSignedCertificateGenerator generator;
+
+ /**
+ * Constructor.
+ */
+ public SelfSignedCertificateGeneratorTask() {
+ generator = new SelfSignedCertificateGenerator();
+ }
+
+ /**
+ * Set the type of key that will be generated. Defaults to RSA.
+ *
+ * @param type type of key that will be generated
+ */
+ public void setKeyType(@Nonnull @NotEmpty final String type) {
+ generator.setKeyType(type);
+ }
+
+ /**
+ * Set the size of the generated key. Defaults to 2048
+ *
+ * @param size size of the generated key
+ */
+ public void setKeySize(@Positive final int size) {
+ generator.setKeySize(size);
+ }
+
+ /**
+ * Set the number of years for which the certificate will be valid.
+ *
+ * @param lifetime number of years for which the certificate will be valid
+ */
+ public void setCertificateLifetime(@Positive final int lifetime) {
+ generator.setCertificateLifetime(lifetime);
+ }
+
+ /**
+ * Set the certificate algorithm that will be used. Defaults to SHA256withRSA.
+ *
+ * @param alg certificate algorithm
+ */
+ public void setCertificateAlg(@Nonnull @NotEmpty final String alg) {
+ generator.setCertificateAlg(alg);
+ }
+
+ /**
+ * Set the hostname that will appear in the certificate's DN.
+ *
+ * @param name hostname that will appear in the certificate's DN
+ */
+ public void setHostName(@Nonnull @NotEmpty final String name) {
+ generator.setHostName(name);
+ }
+
+ /**
+ * Set the file to which the private key will be written.
+ *
+ * @param file file to which the private key will be written
+ */
+ public void setPrivateKeyFile(@Nullable final File file) {
+ generator.setPrivateKeyFile(file);
+ }
+
+ /**
+ * Set the file to which the certificate will be written.
+ *
+ * @param file file to which the certificate will be written
+ */
+ public void setCertificateFile(@Nullable final File file) {
+ generator.setCertificateFile(file);
+ }
+
+ /**
+ * Set the type of keystore to create.
+ *
+ * @param type keystore type
+ */
+ public void setKeystoreType(@Nonnull @NotEmpty final String type) {
+ generator.setKeystoreType(type);
+ }
+
+ /**
+ * Set the file to which the keystore will be written.
+ *
+ * @param file file to which the keystore will be written
+ */
+ public void setKeystoreFile(@Nullable final File file) {
+ generator.setKeystoreFile(file);
+ }
+
+ /**
+ * Set the password for the generated keystore.
+ *
+ * @param password password for the generated keystore
+ */
+ public void setKeystorePassword(@Nullable final String password) {
+ generator.setKeystorePassword(password);
+ }
+
+ /**
+ * Set the optional DNS subject alt names.
+ *
+ * @param altNames collection of subject alt names.
+ */
+ public void setDNSSubjectAltNames(@Nonnull @NonnullElements final String altNames) {
+ final List<String> nameList = StringSupport.stringToList(altNames, " ");
+ generator.setDNSSubjectAltNames(nameList);
+ }
+
+ /**
+ * Set the optional URI subject alt names.
+ *
+ * @param subjectAltNames collection of subject alt names.
+ */
+ public void setURISubjectAltNames(@Nonnull @NonnullElements final String subjectAltNames) {
+ final List<String> nameList = StringSupport.stringToList(subjectAltNames, " ");
+ generator.setURISubjectAltNames(nameList);
+ }
+
+ @Override
+ /** {@inheritDoc} */
+ public void execute() {
+ try {
+ generator.generate();
+ } catch (final Exception e) {
+ log("Build failed", e, Project.MSG_ERR);
+ throw new BuildException(e);
+ }
+ }
+}
diff --git a/idp-installer/src/main/resources/net/shibboleth/idp/installer/ant.xml b/idp-installer/src/main/resources/net/shibboleth/idp/installer/ant.xml
index 9c286dd..5f80174 100644
--- a/idp-installer/src/main/resources/net/shibboleth/idp/installer/ant.xml
+++ b/idp-installer/src/main/resources/net/shibboleth/idp/installer/ant.xml
@@ -1,4 +1,7 @@
<?xml version="1.0"?>
<antlib>
+ <taskdef name="selfsignedcert" classname="net.shibboleth.idp.installer.ant.impl.SelfSignedCertificateGeneratorTask"/>
+ <taskdef name="mergeproperties" classname="net.shibboleth.idp.installer.ant.impl.MergePropertiesTask"/>
+ <taskdef name="rewriteproperties" classname="net.shibboleth.idp.installer.ant.impl.RewritePropertiesTask"/>
<taskdef name="v4install" classname="net.shibboleth.idp.installer.ant.impl.V4InstallTask"/>
</antlib>
\ No newline at end of file
diff --git a/idp-installer/src/main/resources/net/shibboleth/idp/installer/metadata-generator-ant.xml b/idp-installer/src/main/resources/net/shibboleth/idp/installer/metadata-generator-ant.xml
new file mode 100644
index 0000000..d739eb0
--- /dev/null
+++ b/idp-installer/src/main/resources/net/shibboleth/idp/installer/metadata-generator-ant.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:c="http://www.springframework.org/schema/c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean
+ class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+ p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+ <context:property-placeholder />
+
+ <bean id="IdPConfiguration"
+ class="net.shibboleth.idp.installer.metadata.impl.MetadataGeneratorParametersImpl"
+ p:encryptionCertResource="%{idp.encryption.cert}" p:signingCertResource="%{idp.signing.cert}"
+ p:entityID="%{idp.entityID}" p:scope="%{idp.scope}" />
+</beans>
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list