[java-identity-provider] 04/06: IDP-1499 conf dir pre-overlay and edit-webapp contents
Rod Widdowson
rdw at steadingsoftware.com
Thu Oct 24 12:00:33 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=b496e35682e58bfd16543a1e64218672777cbd35
commit b496e35682e58bfd16543a1e64218672777cbd35
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Oct 23 14:50:21 2019 +0100
IDP-1499 conf dir pre-overlay and edit-webapp contents
https://issues.shibboleth.net/jira/browse/IDP-1499
idp.conf.preoverlay and idp.initial.edit-webapp drive the operation
---
.../idp/installer/InstallerProperties.java | 21 +++-
.../idp/installer/InstallerPropertiesImpl.java | 108 ++++++++++++---------
.../net/shibboleth/idp/installer/V4Install.java | 63 +++++++-----
3 files changed, 121 insertions(+), 71 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
index 07ab8fe..4de3254 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerProperties.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerProperties.java
@@ -17,7 +17,6 @@
package net.shibboleth.idp.installer;
-import java.io.File;
import java.nio.file.Path;
import javax.annotation.Nonnull;
@@ -110,12 +109,26 @@ public interface InstallerProperties extends InitializableComponent {
* @return the file or null if it none required.
* @throws BuildException if badness happens
*/
- @Nullable public File getIdPMergePropertiesFile() throws BuildException;
+ @Nullable public Path getIdPMergeProperties() throws BuildException;
/** Get the a file to merge with ldap.properties or null.
*
- * @return the file or null if it none required.
+ * @return the path or null if it none required.
+ * @throws BuildException if badness happens
+ */
+ @Nullable public Path getLDAPMergeProperties() throws BuildException;
+
+ /** Get a directory to use to "pre-overlay" the conf directory.
+ * Files will be copied from here if they don't already exist in conf,
+ * <b>before</b> the files are copied from the distribution.
+ * @return the path or null if non specified.
+ * @throws BuildException if badness happens
+ */
+ @Nullable public Path getConfPreOverlay() throws BuildException;
+
+ /** Get a path to use to do the initial edit-webapp populate.
+ * @return the path or null if non specified.
* @throws BuildException if badness happens
*/
- public File getLDAPMergePropertiesFile() throws BuildException;
+ @Nullable public Path getInitialEditWeb() throws BuildException;
}
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 dd986f6..e7b6a13 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
@@ -45,38 +45,7 @@ import net.shibboleth.utilities.java.support.component.AbstractInitializableComp
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
-/** Class implement {@link InstallerProperties} with properties/UI driven values.
- *
- * Mostly it interrogates the system environment for properties, but will load a file if one
- * is supplied (via a property name).<p/>Property names :
- * <ul>
- * <li> idp.src.dir (update only): Where to install from. Default is basedir. Not used for build-war</li>
- * <li> idp.target.dir (all): where to install to. Default is basedir for build war /opt/shibboleth-idp otherwise.</li>
- * <li> idp.host.name: If we are creating certificates</li>
- * <li> idp.uri.subject.alt.name: If we are creating certificates. Defaulted</li>
- * <li> idp.sealer.password:</li>
- * <li> idp.sealer.alias:</li>
- * <li> idp.keystore.password:</li>
- * <li> idp.keysize: to change from the the default of 3072</li>
- * <li> idp.scope: The scope to assert. If present this should also be present in idp.merge.properties</li>
- * <li> idp.merge.properties: The name of a property file to merge with idp.properties. This file is only
- * used when doing the initial create of idp.properties, and is deleted after processing</li>
- * <ul><li> if idp.noprompt is set, then this file should contain a line setting idp.entityID. </li>
- * <li> if idp.sealer.password is set, then this file should contain a line setting
- * idp.sealer.storePassword and idp.sealer.keyPassword</li>
- * <li> if idp.scope is present, then this file should contain a line setting idp.scope
- * services.merge.properties: The name of a property file to merge with services.properties</li>
- * <li> if idp.is.V2 is set, then this file should contain a line setting
- * idp.service.relyingparty.resources=shibboleth.LegacyRelyingPartyResolverResources</li></ul>
- * <li> idp.property.file: The name of a property file to fill in some or all of the above.
- This file is deleted after processing.</li>
- * <li> idp.no.tidy: Do not delete the two above files (debug only)</li>
- * <li> ldap.merge.properties: The name of a property file to merge with ldap.properties</li>
- * <li> idp.conf.filemode (default "600"): The permissions to mark the files in conf with (UNIX only).</li>
- * <li> idp.conf.credentials.filemode (default "600"): The permissions to mark the files in conf with (UNIX only).</li>
- * <li> idp.noprompt will cause a failure rather than a prompt.</li>
- * </ul>
- */
+/** Class implement {@link InstallerProperties} with properties/UI driven values. */
public class InstallerPropertiesImpl extends AbstractInitializableComponent implements InstallerProperties {
/** The base directory, inherited and shared with ant. */
@@ -91,6 +60,12 @@ public class InstallerPropertiesImpl extends AbstractInitializableComponent impl
/** The name of a property file to merge with ldap.properties. */
public static final String LDAP_PROPERTIES_MERGE = "ldap.merge.properties";
+ /** The name of a directory to overlay "under" the distribution conf. */
+ public static final String CONF_PRE_OVERLAY = "idp.conf.preoverlay";
+
+ /** The name of a directory to use to populate the initial webapp. */
+ public static final String INITIAL_EDIT_WEBAPP = "idp.initial.edit-webapp";
+
/** Where to install to. Default is basedir */
public static final String TARGET_DIR = "idp.target.dir";
@@ -516,32 +491,75 @@ public class InstallerPropertiesImpl extends AbstractInitializableComponent impl
return keySize;
}
- /** Get the property file as a File, or null if it doesn't exist.
- * Also delete it at the end if we are deleting.
+ /** Get the directory specified as the property as a File, or null if it doesn't exist.
+ * @param propName the name to lookup;
+ * @return null if the property is not provided a {@link File} otherwise
+ * @throws BuildException if the property is supplied but the file doesn't exist.
+ */
+ protected Path getMergeDir(final String propName) throws BuildException {
+ return getMergePath(propName, true);
+ }
+
+ /** Get the file specified as the property as a File, or null if it doesn't exist.
* @param propName the name to lookup;
* @return null if the property is not provided a {@link File} otherwise
* @throws BuildException if the property is supplied but the file doesn't exist.
*/
- protected File getMergePropertiesFile(final String propName) throws BuildException {
+ protected Path getMergeFile(final String propName) throws BuildException {
+ return getMergePath(propName, false);
+ }
+
+ /** Get the {@link Path} specified as the property as a File, or null if it doesn't exist.
+ * Police for type if required
+ * @param propName the name to lookup;
+ * @param mustBeDir if null do not policy. Otherwise policy according to value
+ * @return null if the property is not provided a {@link File} otherwise
+ * @throws BuildException if the property is supplied but the file doesn't exist.
+ */
+ private Path getMergePath(final String propName, final Boolean mustBeDir) throws BuildException {
final String propValue = installerProperties.getProperty(propName);
if (propValue == null) {
return null;
}
- final Path path = baseDir.resolve(propValue);
- if (!Files.exists(path)) {
- log.error("Could not find specified property file {}", path );
+ final Path result = baseDir.resolve(propValue);
+ log.debug("Property '{}' had value '{}' returning path '{}'", propName, propValue, result);
+ if (!Files.exists(result)) {
+ log.error("Could not find specified file specified by property {} ({})", propName, result );
throw new BuildException("Property file not found");
}
- return path.toFile();
+ if (mustBeDir != null) {
+ if (mustBeDir) {
+ if (!Files.isDirectory(result)) {
+ log.error("Path '{}' supplied by property '{}' was not a directory", result, propName);
+ throw new BuildException("No a directory");
+ }
+ } else {
+ if (!Files.isDirectory(result)) {
+ log.error("Path '{}' supplied by property '{}' was not a file", result, propName);
+ throw new BuildException("No a file");
+ }
+ }
+ }
+ return result;
}
- /** {@inheritDoc}. Default to the file pointed to by {@value #IDP_PROPERTIES_MERGE}. */
- @Override public File getIdPMergePropertiesFile() throws BuildException {
- return getMergePropertiesFile(IDP_PROPERTIES_MERGE);
+ /** {@inheritDoc}. */
+ @Override public Path getIdPMergeProperties() throws BuildException {
+ return getMergeFile(IDP_PROPERTIES_MERGE);
}
- /** {@inheritDoc}. Default to the file pointed to by {@value #LDAP_PROPERTIES_MERGE}. */
- @Override public File getLDAPMergePropertiesFile() throws BuildException {
- return getMergePropertiesFile(LDAP_PROPERTIES_MERGE);
+ /** {@inheritDoc}. */
+ @Override public Path getLDAPMergeProperties() throws BuildException {
+ return getMergeFile(LDAP_PROPERTIES_MERGE);
+ }
+
+ /** {@inheritDoc}. */
+ @Override public Path getConfPreOverlay() throws BuildException {
+ return getMergeFile(CONF_PRE_OVERLAY);
+ }
+
+ /** {@inheritDoc}. */
+ @Override public Path getInitialEditWeb() throws BuildException {
+ return getMergeFile(INITIAL_EDIT_WEBAPP);
}
}
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 1f9b7d5..cf7981c 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
@@ -194,16 +194,20 @@ public class V4Install extends AbstractInitializableComponent {
if (Files.exists(target)) {
throw new BuildException("Internal error - idp.properties");
}
- final File mergeFile = installerProps.getIdPMergePropertiesFile();
+ final Path mergePath = installerProps.getIdPMergeProperties();
final Path source = dstConf.resolve("idp.properties");
if (!Files.exists(source)) {
throw new BuildException("missing idp.properties in dist");
}
final PropertiesWithComments propertiesToReWrite = new PropertiesWithComments();
final Properties replacements;
- if (mergeFile != null) {
- log.debug("Creating {} from {} and {}", target, source, mergeFile);
+ if (mergePath != null) {
+ log.debug("Creating {} from {} and {}", target, source, mergePath);
replacements = new Properties();
+ final File mergeFile = mergePath.toFile();
+ if (!installerProps.isNoTidy()) {
+ mergeFile.deleteOnExit();
+ }
replacements.load(new FileInputStream(mergeFile));
} else {
replacements = getIdPReplacements(sealerCreated);
@@ -217,8 +221,8 @@ public class V4Install extends AbstractInitializableComponent {
}
}
- final File ldapMergeFile = installerProps.getLDAPMergePropertiesFile();
- if (ldapMergeFile != null && !currentState.isLDAPPropertiesPresent() ) {
+ final Path ldapMergePath = installerProps.getLDAPMergeProperties();
+ if (ldapMergePath != null && !currentState.isLDAPPropertiesPresent() ) {
log.debug("Merging {} with ldap.properties", ldapMergePath);
try {
final Path target = conf.resolve("ldap.properties");
@@ -229,10 +233,14 @@ public class V4Install extends AbstractInitializableComponent {
if (!Files.exists(source)) {
throw new BuildException("missing ldap.properties in dist");
}
- log.debug("Creating {} from {} and {}", target, source, ldapMergeFile);
+ log.debug("Creating {} from {} and {}", target, source, ldapMergePath);
final PropertiesWithComments propertiesToReWrite = new PropertiesWithComments();
final Properties replacements = new Properties();
- replacements.load(new FileInputStream(ldapMergeFile));
+ final File mergeFile = ldapMergePath.toFile();
+ if (!installerProps.isNoTidy()) {
+ mergeFile.deleteOnExit();
+ }
+ replacements.load(new FileInputStream(mergeFile));
propertiesToReWrite.load(new FileInputStream(source.toFile()));
propertiesToReWrite.replaceProperties(replacements);
propertiesToReWrite.store(new FileOutputStream(target.toFile()));
@@ -274,21 +282,28 @@ public class V4Install extends AbstractInitializableComponent {
if (Files.exists(editWebApp)) {
return;
}
- InstallerSupport.createDirectory(editWebApp);
- final Path css = editWebApp.resolve("css");
- InstallerSupport.createDirectory(css);
- final Path images = editWebApp.resolve("images");
- InstallerSupport.createDirectory(images);
- InstallerSupport.createDirectory(editWebApp.resolve("WEB-INF"));
- InstallerSupport.createDirectory(editWebApp.resolve("WEB-INF").resolve("lib"));
- InstallerSupport.createDirectory(editWebApp.resolve("WEB-INF").resolve("classes"));
- final Path distEditWebApp = installerProps.getTargetDir().resolve("dist").resolve("webapp");
- final Copy cssCopy = InstallerSupport.getCopyTask(distEditWebApp.resolve("css"), css);
- cssCopy.setFailOnError(false);
- cssCopy.execute();
- final Copy imagesCopy = InstallerSupport.getCopyTask(distEditWebApp.resolve("images"), images);
- imagesCopy.setFailOnError(false);
- imagesCopy.execute();
+ final Path suppliedInput = installerProps.getInitialEditWeb();
+ if (suppliedInput != null) {
+ final Copy copy = InstallerSupport.getCopyTask(suppliedInput, editWebApp);
+ copy.setFailOnError(false);
+ copy.execute();
+ } else {
+ InstallerSupport.createDirectory(editWebApp);
+ final Path css = editWebApp.resolve("css");
+ InstallerSupport.createDirectory(css);
+ final Path images = editWebApp.resolve("images");
+ InstallerSupport.createDirectory(images);
+ InstallerSupport.createDirectory(editWebApp.resolve("WEB-INF"));
+ InstallerSupport.createDirectory(editWebApp.resolve("WEB-INF").resolve("lib"));
+ InstallerSupport.createDirectory(editWebApp.resolve("WEB-INF").resolve("classes"));
+ final Path distEditWebApp = installerProps.getTargetDir().resolve("dist").resolve("webapp");
+ final Copy cssCopy = InstallerSupport.getCopyTask(distEditWebApp.resolve("css"), css);
+ cssCopy.setFailOnError(false);
+ cssCopy.execute();
+ final Copy imagesCopy = InstallerSupport.getCopyTask(distEditWebApp.resolve("images"), images);
+ imagesCopy.setFailOnError(false);
+ imagesCopy.execute();
+ }
}
/** Create and populate (if they not exist) the "user visible" folders.
@@ -298,6 +313,10 @@ public class V4Install extends AbstractInitializableComponent {
protected void populateUserDirectories() throws BuildException {
final Path targetBase = installerProps.getTargetDir();
final Path distBase = targetBase.resolve("dist");
+ final Path preConfPath = installerProps.getConfPreOverlay();
+ if (preConfPath != null) {
+ InstallerSupport.copyDirIfNotPresent(preConfPath, targetBase.resolve("conf"));
+ }
InstallerSupport.copyDirIfNotPresent(distBase.resolve("conf"), targetBase.resolve("conf"));
InstallerSupport.copyDirIfNotPresent(distBase.resolve("flows"), targetBase.resolve("flows"));
InstallerSupport.copyDirIfNotPresent(distBase.resolve("views"), targetBase.resolve("views"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list