[java-identity-provider] 01/02: IDP-1499 Insert ant properties into inherited properties for installl
Rod Widdowson
rdw at steadingsoftware.com
Sun Nov 10 07:59:35 EST 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=7b2671cdf19e76046844c77c6b1827998eba86dc
commit 7b2671cdf19e76046844c77c6b1827998eba86dc
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Nov 10 12:51:57 2019 +0000
IDP-1499 Insert ant properties into inherited properties for installl
https://issues.shibboleth.net/jira/browse/IDP-1499
---
.../idp/installer/InstallerPropertiesImpl.java | 21 +++++++++++++++++++--
.../net/shibboleth/idp/installer/V4Install.java | 12 ++++++------
.../idp/installer/ant/impl/V4InstallTask.java | 17 +++++++++++++++--
3 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerPropertiesImpl.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerPropertiesImpl.java
index 73d5cf4..f73654c 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerPropertiesImpl.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerPropertiesImpl.java
@@ -26,6 +26,7 @@ import java.net.SocketException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
+import java.util.Map;
import java.util.Properties;
import java.util.function.Supplier;
@@ -168,6 +169,9 @@ public class InstallerPropertiesImpl extends AbstractInitializableComponent impl
/** credentials key file mode. */
private String credentialsKeyFileMode;
+ /** Local overload of properties (to deal with nested calling). */
+ private Map<String, String> inheritedProperties = Collections.EMPTY_MAP;
+
/**
* Constructor.
* @param copiedDistribution Has the distribution been copied? If no we don't need the source dir.
@@ -176,10 +180,22 @@ public class InstallerPropertiesImpl extends AbstractInitializableComponent impl
needSourceDir = !copiedDistribution;
}
+ /** Set any properties inherited from the base environment.
+ * @param props what to set
+ */
+ public void setInheritedProperties(final Map<String,String> props) {
+ inheritedProperties = props;
+ }
+
/** {@inheritDoc} */
// CheckStyle: CyclomaticComplexity OFF
protected void doInitialize() throws ComponentInitializationException {
installerProperties = new Properties(System.getProperties());
+
+ for (final Map.Entry<String,String> entry:inheritedProperties.entrySet()) {
+ installerProperties.setProperty(entry.getKey(), entry.getValue());
+ }
+
final String antBase = installerProperties.getProperty(ANT_BASE_DIR);
if (antBase == null) {
throw new ComponentInitializationException(ANT_BASE_DIR + " must be specified");
@@ -233,10 +249,11 @@ public class InstallerPropertiesImpl extends AbstractInitializableComponent impl
log.debug("Source directory {}", srcDir.toAbsolutePath());
}
- if (!installerProperties.contains(KEY_SIZE)) {
+ value = installerProperties.getProperty(KEY_SIZE);
+ if (value == null) {
keySize = DEFAULT_KEY_SIZE;
} else {
- keySize = Integer.parseInt(installerProperties.getProperty(KEY_SIZE));
+ keySize = Integer.parseInt(value);
}
}
// CheckStyle: CyclomaticComplexity ON
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 8e7bba0..8b89b84 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
@@ -478,8 +478,8 @@ public class V4Install extends AbstractInitializableComponent {
generator.setKeySize(installerProps.getKeySize());
generator.setHostName(installerProps.getHostName());
generator.setURISubjectAltNames(Collections.singletonList(installerProps.getSubjectAltName()));
- log.info("Creating {}, CN = {} URI = {}", fileBase,
- installerProps.getHostName(), installerProps.getSubjectAltName());
+ log.info("Creating {}, CN = {} URI = {}, keySize={}", fileBase,
+ installerProps.getHostName(), installerProps.getSubjectAltName(), installerProps.getKeySize());
try {
generator.generate();
} catch (final Exception e) {
@@ -519,8 +519,8 @@ public class V4Install extends AbstractInitializableComponent {
generator.setHostName(installerProps.getHostName());
generator.setURISubjectAltNames(Collections.singletonList(installerProps.getSubjectAltName()));
generator.setKeystorePassword(installerProps.getKeyStorePassword());
- log.info("Creating backchannel keystore, CN = {} URI = {}",
- installerProps.getHostName(), installerProps.getSubjectAltName());
+ log.info("Creating backchannel keystore, CN = {} URI = {}, keySize={}",
+ installerProps.getHostName(), installerProps.getSubjectAltName(), installerProps.getKeySize());
try {
generator.generate();
} catch (final Exception e) {
@@ -558,8 +558,8 @@ public class V4Install extends AbstractInitializableComponent {
generator.setVersionFile(versionFile.toFile());
generator.setKeyAlias(installerProps.getSealerAlias());
generator.setKeystorePassword(installerProps.getSealerPassword());
- log.info("Creating backchannel keystore, CN = {} URI = {}",
- installerProps.getHostName(), installerProps.getSubjectAltName());
+ log.info("Creating backchannel keystore, CN = {} URI = {}, keySize={}",
+ installerProps.getHostName(), installerProps.getSubjectAltName(),installerProps.getKeySize());
try {
generator.changeKey();
} catch (final Exception e) {
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/V4InstallTask.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/V4InstallTask.java
index 4a7c17d..459398d 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/V4InstallTask.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/V4InstallTask.java
@@ -17,6 +17,9 @@
package net.shibboleth.idp.installer.ant.impl;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
import javax.annotation.Nonnull;
import org.apache.tools.ant.BuildException;
@@ -26,7 +29,6 @@ import org.slf4j.LoggerFactory;
import net.shibboleth.idp.installer.BuildWar;
import net.shibboleth.idp.installer.CopyDistribution;
-import net.shibboleth.idp.installer.InstallerProperties;
import net.shibboleth.idp.installer.InstallerPropertiesImpl;
import net.shibboleth.idp.installer.V4Install;
import net.shibboleth.idp.installer.impl.CurrentInstallStateImpl;
@@ -63,7 +65,18 @@ public class V4InstallTask extends Task {
throw new BuildException("Invalid parameter to task");
}
try {
- final InstallerProperties ip = new InstallerPropertiesImpl(!copyInstall);
+ final InstallerPropertiesImpl ip = new InstallerPropertiesImpl(!copyInstall);
+
+ // Grab the ant properties and plug in. Note Java V2 to V11 conversion.
+ ip.setInheritedProperties(
+ getProject().
+ getProperties().
+ entrySet().
+ stream().
+ filter(e -> System.getProperty(e.getKey()) == null).
+ filter(e -> e.getValue() instanceof String).
+ collect(Collectors.toUnmodifiableMap(Entry::getKey, e-> (String) e.getValue())));
+
final CurrentInstallStateImpl is;
ip.initialize();
is = new CurrentInstallStateImpl(ip);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list