[java-identity-provider] 02/02: GEN-348 Investigate and Remove implementation classes from the jetty plugin
Rod Widdowson
rdw at steadingsoftware.com
Wed Oct 23 13:18:45 UTC 2024
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=ad110666e8cd8a08760e26ab0ec8c83c79bdb896
commit ad110666e8cd8a08760e26ab0ec8c83c79bdb896
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Oct 23 13:46:13 2024 +0100
GEN-348 Investigate and Remove implementation classes from the jetty plugin
https://shibboleth.atlassian.net/browse/GEN-348
Introduce api level InstallerProperties class and put all
user visible constants into it
---
.../idp/installer/InstallerProperties.java | 83 ++++++++++++++++++
.../idp/installer/impl/IdPInstallerCLI.java | 17 ++--
.../installer/impl/InstallerPropertiesImpl.java | 98 +++++-----------------
.../shibboleth/idp/installer/TestInstallerCLI.java | 3 +-
4 files changed, 114 insertions(+), 87 deletions(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerProperties.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerProperties.java
new file mode 100644
index 000000000..bfb094d21
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerProperties.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed 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;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+
+/**
+ * Class to contain the publicly visible (and api) properties used by the installer.
+ */
+public final class InstallerProperties {
+ /** The name of a property file to fill in some or all of the above. This file is deleted after processing. */
+ @Nonnull @NotEmpty public static final String PROPERTY_SOURCE_FILE = "idp.property.file";
+
+ /** The name of a property file to merge with idp.properties. */
+ @Nonnull @NotEmpty public static final String IDP_PROPERTIES_MERGE = "idp.merge.properties";
+
+ /** The name of a property file to merge with ldap.properties. */
+ @Nonnull @NotEmpty public static final String LDAP_PROPERTIES_MERGE = "ldap.merge.properties";
+
+ /** The LDAP Password (usually associated with a username in ldap.properties). */
+ @Nonnull @NotEmpty public static final String LDAP_PASSWORD = "idp.LDAP.credential";
+
+ /** Where to install to. Default is basedir */
+ @Nonnull @NotEmpty public static final String TARGET_DIR = "idp.target.dir";
+
+ /** The entity ID. */
+ @Nonnull @NotEmpty public static final String ENTITY_ID = "idp.entityID";
+
+ /** Do we cause a failure rather than a prompt. */
+ @Nonnull @NotEmpty public static final String NO_PROMPT = "idp.noprompt";
+
+ /** What is the installer host name? */
+ @Nonnull @NotEmpty public static final String HOST_NAME = "idp.host.name";
+
+ /** The scope to assert. */
+ @Nonnull @NotEmpty public static final String SCOPE = "idp.scope";
+
+ /** The keystore password to use. */
+ @Nonnull @NotEmpty public static final String KEY_STORE_PASSWORD = "idp.keystore.password";
+
+ /** The sealer password to use. */
+ @Nonnull @NotEmpty public static final String SEALER_PASSWORD = "idp.sealer.password";
+
+ /** The sealer alias to use. */
+ @Nonnull @NotEmpty public static final String SEALER_ALIAS = "idp.sealer.alias";
+
+ /** The keysize for the sealer. */
+ @Nonnull @NotEmpty public static final String SEALER_KEYSIZE = "idp.sealer.keysize";
+
+ /** The the key size to generate. */
+ @Nonnull @NotEmpty public static final String KEY_SIZE = "idp.keysize";
+
+ /** Mode to set on credential *key files. */
+ @Nonnull @NotEmpty public static final String MODE_CREDENTIAL_KEYS = "idp.conf.credentials.filemode";
+
+ /** Group to set on files in the credential and conf directories. */
+ @Nonnull @NotEmpty public static final String GROUP_CONF_CREDENTIALS = "idp.conf.credentials.group";
+
+ /** Do we do any chgrp/chmod work? */
+ @Nonnull @NotEmpty public static final String PERFORM_SET_MODE = "idp.conf.setmode";
+
+ /** Whether to tidy up after ourselves. */
+ @Nonnull @NotEmpty public static final String NO_TIDY = "idp.no.tidy";
+
+ /** Key size for all installer-generated keys. */
+ public static final int DEFAULT_KEY_SIZE = 3072;
+
+
+}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java
index 254a9fa88..56ce22ea3 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java
@@ -30,6 +30,7 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import net.shibboleth.idp.Version;
+import net.shibboleth.idp.installer.InstallerProperties;
import net.shibboleth.shared.cli.AbstractCommandLine;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.ComponentInitializationException;
@@ -113,16 +114,16 @@ public class IdPInstallerCLI extends AbstractCommandLine<IdPInstallerArguments>
}
if (args.isUnattended()) {
- System.setProperty(InstallerPropertiesImpl.NO_PROMPT, "true");
+ System.setProperty(InstallerProperties.NO_PROMPT, "true");
}
- setIfNotNull(args.getPropertyFile(), InstallerPropertiesImpl.PROPERTY_SOURCE_FILE);
- setIfNotNull(args.getTargetDirectory(), InstallerPropertiesImpl.TARGET_DIR);
- setIfNotNull(args.getHostName(), InstallerPropertiesImpl.HOST_NAME);
- setIfNotNull(args.getScope(), InstallerPropertiesImpl.SCOPE);
- setIfNotNull(args.getEntityID(), InstallerPropertiesImpl.ENTITY_ID);
- setIfNotNull(args.getKeystorePassword(), InstallerPropertiesImpl.KEY_STORE_PASSWORD);
- setIfNotNull(args.getSealerPassword(), InstallerPropertiesImpl.SEALER_PASSWORD);
+ setIfNotNull(args.getPropertyFile(), InstallerProperties.PROPERTY_SOURCE_FILE);
+ setIfNotNull(args.getTargetDirectory(), InstallerProperties.TARGET_DIR);
+ setIfNotNull(args.getHostName(), InstallerProperties.HOST_NAME);
+ setIfNotNull(args.getScope(), InstallerProperties.SCOPE);
+ setIfNotNull(args.getEntityID(), InstallerProperties.ENTITY_ID);
+ setIfNotNull(args.getKeystorePassword(), InstallerProperties.KEY_STORE_PASSWORD);
+ setIfNotNull(args.getSealerPassword(), InstallerProperties.SEALER_PASSWORD);
try {
final InstallerPropertiesImpl ip = new InstallerPropertiesImpl(source);
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerPropertiesImpl.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerPropertiesImpl.java
index cd354d3fd..02ea43ff1 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerPropertiesImpl.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerPropertiesImpl.java
@@ -35,6 +35,7 @@ import org.apache.tools.ant.input.InputHandler;
import org.apache.tools.ant.input.InputRequest;
import org.slf4j.Logger;
+import net.shibboleth.idp.installer.InstallerProperties;
import net.shibboleth.idp.installer.InstallerSupport;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
@@ -55,67 +56,10 @@ import net.shibboleth.shared.primitive.StringSupport;
*/
public class InstallerPropertiesImpl {
- /** The name of a property file to fill in some or all of the above. This file is deleted after processing. */
- @Nonnull @NotEmpty public static final String PROPERTY_SOURCE_FILE = "idp.property.file";
-
- /** The name of a property file to merge with idp.properties. */
- @Nonnull @NotEmpty public static final String IDP_PROPERTIES_MERGE = "idp.merge.properties";
-
- /** The name of a property file to merge with ldap.properties. */
- @Nonnull @NotEmpty public static final String LDAP_PROPERTIES_MERGE = "ldap.merge.properties";
-
- /** The LDAP Password (usually associated with a username in ldap.properties). */
- @Nonnull @NotEmpty public static final String LDAP_PASSWORD = "idp.LDAP.credential";
-
- /** Where to install to. Default is basedir */
- @Nonnull @NotEmpty public static final String TARGET_DIR = "idp.target.dir";
-
- /** The entity ID. */
- @Nonnull @NotEmpty public static final String ENTITY_ID = "idp.entityID";
-
- /** Do we cause a failure rather than a prompt. */
- @Nonnull @NotEmpty public static final String NO_PROMPT = "idp.noprompt";
-
- /** What is the installer host name? */
- @Nonnull @NotEmpty public static final String HOST_NAME = "idp.host.name";
-
- /** The scope to assert. */
- @Nonnull @NotEmpty public static final String SCOPE = "idp.scope";
-
- /** The keystore password to use. */
- @Nonnull @NotEmpty public static final String KEY_STORE_PASSWORD = "idp.keystore.password";
-
- /** The sealer password to use. */
- @Nonnull @NotEmpty public static final String SEALER_PASSWORD = "idp.sealer.password";
-
- /** The sealer alias to use. */
- @Nonnull @NotEmpty public static final String SEALER_ALIAS = "idp.sealer.alias";
-
- /** The keysize for the sealer. */
- @Nonnull @NotEmpty public static final String SEALER_KEYSIZE = "idp.sealer.keysize";
-
- /** The the key size to generate. */
- @Nonnull @NotEmpty public static final String KEY_SIZE = "idp.keysize";
-
- /** Mode to set on credential *key files. */
- @Nonnull @NotEmpty public static final String MODE_CREDENTIAL_KEYS = "idp.conf.credentials.filemode";
-
- /** Group to set on files in the credential and conf directories. */
- @Nonnull @NotEmpty public static final String GROUP_CONF_CREDENTIALS = "idp.conf.credentials.group";
-
- /** Do we do any chgrp/chmod work? */
- @Nonnull @NotEmpty public static final String PERFORM_SET_MODE = "idp.conf.setmode";
-
- /** Whether to tidy up after ourselves. */
- @Nonnull @NotEmpty public static final String NO_TIDY = "idp.no.tidy";
-
/** Which modules to enable on initial install.
* @since 4.1.0 */
@Nonnull @NotEmpty public static final String INITIAL_INSTALL_MODULES = "idp.initial.modules";
- /** Whether to tidy up after ourselves. */
- public static final int DEFAULT_KEY_SIZE = 3072;
-
/** Those modules which are "core". */
@Nonnull public static final Set<String> CORE_MODULES =
CollectionSupport.setOf("idp.Core", "idp.EditWebApp", "idp.CommandLine");
@@ -211,7 +155,7 @@ public class InstallerPropertiesImpl {
}
log.debug("Source dir {}", srcDir);
- final Path propertyFile = getMergeFile(PROPERTY_SOURCE_FILE);
+ final Path propertyFile = getMergeFile(InstallerProperties.ENTITY_ID);
if (propertyFile != null) {
/* The file specified in the system file idp.property.file (if present). */
final File idpPropertyFile = propertyFile.toFile();
@@ -226,19 +170,19 @@ public class InstallerPropertiesImpl {
}
}
- final String noTidy = installerProperties.getProperty(NO_TIDY);
+ final String noTidy = installerProperties.getProperty(InstallerProperties.NO_TIDY);
tidy = noTidy == null;
- final String setModeString = installerProperties.getProperty(PERFORM_SET_MODE);
+ final String setModeString = installerProperties.getProperty(InstallerProperties.PERFORM_SET_MODE);
if (setModeString != null) {
setGroupAndMode = Boolean.valueOf(setModeString);
}
- String value = installerProperties.getProperty(NO_PROMPT);
+ String value = installerProperties.getProperty(InstallerProperties.NO_PROMPT);
noPrompt = value != null;
- value = installerProperties.getProperty(KEY_SIZE);
+ value = installerProperties.getProperty(InstallerProperties.KEY_SIZE);
if (value == null) {
- keySize = DEFAULT_KEY_SIZE;
+ keySize = InstallerProperties.DEFAULT_KEY_SIZE;
} else {
keySize = Integer.parseInt(value);
}
@@ -325,7 +269,7 @@ public class InstallerPropertiesImpl {
return targetDir;
}
final Path td = targetDir =
- Path.of(getValue(TARGET_DIR, "Installation Directory:", () -> "/opt/shibboleth-idp"));
+ Path.of(getValue(InstallerProperties.TARGET_DIR, "Installation Directory:", () -> "/opt/shibboleth-idp"));
assert td != null;
return td;
}
@@ -348,7 +292,7 @@ public class InstallerPropertiesImpl {
String result = entityID;
if (result == null) {
entityID = result =
- getValue(ENTITY_ID, "SAML EntityID:", () -> "https://" + getHostName() + "/idp/shibboleth");
+ getValue(InstallerProperties.ENTITY_ID, "SAML EntityID:", () -> "https://" + getHostName() + "/idp/shibboleth");
}
return result;
}
@@ -372,7 +316,7 @@ public class InstallerPropertiesImpl {
@Nonnull public String getHostName() {
String result = hostname;
if (result == null) {
- result = hostname = getValue(HOST_NAME, "Host Name:", () -> InstallerSupport.getBestHostName());
+ result = hostname = getValue(InstallerProperties.HOST_NAME, "Host Name:", () -> InstallerSupport.getBestHostName());
}
return result;
}
@@ -387,7 +331,7 @@ public class InstallerPropertiesImpl {
if (result != null) {
return result;
}
- result = credentialsKeyFileMode = installerProperties.getProperty(MODE_CREDENTIAL_KEYS, "600");
+ result = credentialsKeyFileMode = installerProperties.getProperty(InstallerProperties.MODE_CREDENTIAL_KEYS, "600");
assert result != null;
return result;
}
@@ -398,7 +342,7 @@ public class InstallerPropertiesImpl {
* @return the mode or null if none to be set
*/
@Nullable public String getCredentialsGroup() {
- return installerProperties.getProperty(GROUP_CONF_CREDENTIALS);
+ return installerProperties.getProperty(InstallerProperties.GROUP_CONF_CREDENTIALS);
}
/**
@@ -434,7 +378,7 @@ public class InstallerPropertiesImpl {
@Nonnull public String getScope() {
String result = scope;
if (result == null) {
- result = scope = getValue(SCOPE, "Attribute Scope:", () -> defaultScope());
+ result = scope = getValue(InstallerProperties.SCOPE, "Attribute Scope:", () -> defaultScope());
}
return result;
}
@@ -446,7 +390,7 @@ public class InstallerPropertiesImpl {
* @throws BuildException if badness happens
*/
@Nullable public String getLDAPPassword() throws BuildException {
- return installerProperties.getProperty(LDAP_PASSWORD);
+ return installerProperties.getProperty(InstallerProperties.LDAP_PASSWORD);
}
/**
@@ -466,7 +410,7 @@ public class InstallerPropertiesImpl {
@Nonnull public String getKeyStorePassword() {
String result = keyStorePassword;
if (keyStorePassword == null) {
- result = keyStorePassword = getPassword(KEY_STORE_PASSWORD, "Backchannel PKCS12 Password:");
+ result = keyStorePassword = getPassword(InstallerProperties.KEY_STORE_PASSWORD, "Backchannel PKCS12 Password:");
}
assert result != null;
return result;
@@ -480,7 +424,7 @@ public class InstallerPropertiesImpl {
@Nonnull public String getSealerPassword() {
String result = sealerPassword;
if (result == null) {
- result = sealerPassword = getPassword(SEALER_PASSWORD, "Cookie Encryption Key Password:");
+ result = sealerPassword = getPassword(InstallerProperties.SEALER_PASSWORD, "Cookie Encryption Key Password:");
}
return result;
}
@@ -526,7 +470,7 @@ public class InstallerPropertiesImpl {
* @throws BuildException if the size was not an integer
*/
@Nullable Integer getSealerKeySize() throws BuildException {
- final String val = installerProperties.getProperty(SEALER_KEYSIZE);
+ final String val = installerProperties.getProperty(InstallerProperties.SEALER_KEYSIZE);
if (val == null) {
return null;
}
@@ -535,7 +479,7 @@ public class InstallerPropertiesImpl {
result = Integer.valueOf(val);
}
catch (final NumberFormatException e) {
- log.error("Provided value for property {} ({}') was not an integer", SEALER_ALIAS, val);
+ log.error("Provided value for property {} ({}') was not an integer", InstallerProperties.SEALER_ALIAS, val);
throw new BuildException(e);
}
return result;
@@ -549,7 +493,7 @@ public class InstallerPropertiesImpl {
@Nonnull public String getSealerAlias() {
String result = sealerAlias;
if (result == null) {
- result = sealerAlias = installerProperties.getProperty(SEALER_ALIAS);
+ result = sealerAlias = installerProperties.getProperty(InstallerProperties.SEALER_ALIAS);
}
if (result == null) {
result = sealerAlias = "secret";
@@ -607,7 +551,7 @@ public class InstallerPropertiesImpl {
* @throws BuildException if badness happens
*/
@Nullable public Path getIdPMergeProperties() throws BuildException {
- return getMergeFile(IDP_PROPERTIES_MERGE);
+ return getMergeFile(InstallerProperties.IDP_PROPERTIES_MERGE);
}
/**
@@ -618,7 +562,7 @@ public class InstallerPropertiesImpl {
* @throws BuildException if badness happens
*/
@Nullable public Path getLDAPMergeProperties() throws BuildException {
- return getMergeFile(LDAP_PROPERTIES_MERGE);
+ return getMergeFile(InstallerProperties.LDAP_PROPERTIES_MERGE);
}
}
\ No newline at end of file
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java
index 540ce5906..e0643a673 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java
@@ -17,7 +17,6 @@ package net.shibboleth.idp.installer;
import org.testng.annotations.Test;
import net.shibboleth.idp.installer.impl.IdPInstallerCLI;
-import net.shibboleth.idp.installer.impl.InstallerPropertiesImpl;
import net.shibboleth.idp.installer.impl.UpdateIdPCLI;
//import net.shibboleth.idp.installer.impl.UpdateIdPCLI;
/**
@@ -27,7 +26,7 @@ public class TestInstallerCLI {
@Test(enabled = false)
public void install() {
- System.setProperty(InstallerPropertiesImpl.HOST_NAME, "machine.org.uk");
+ System.setProperty(InstallerProperties.HOST_NAME, "machine.org.uk");
IdPInstallerCLI.runMain(new String[] {
"-t", "h:\\downloads\\idp",
"-s",
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list