[java-identity-provider] 04/09: IDP-1815 Recast IDP Installer to use the CLI infrastructure
Rod Widdowson
rdw at steadingsoftware.com
Tue May 23 08:23:12 UTC 2023
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=8c0b2adca428e8ba10cc0bc3c3bbe2db43ef60a6
commit 8c0b2adca428e8ba10cc0bc3c3bbe2db43ef60a6
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat May 20 16:16:02 2023 +0100
IDP-1815 Recast IDP Installer to use the CLI infrastructure
https://shibboleth.atlassian.net/browse/IDP-1815
This means we can also get of nearly all of our ant tasks and all
the support for ant from the command line.
---
.../src/main/resources/bin/ant-jetty.xml | 117 -----------
idp-distribution/src/main/resources/bin/ant.bat | 40 ----
idp-distribution/src/main/resources/bin/ant.sh | 84 --------
idp-distribution/src/main/resources/bin/build.xml | 29 ---
.../src/main/resources/bin/install-log.xml | 19 --
.../src/main/resources/bin/install.bat | 27 ++-
idp-distribution/src/main/resources/bin/install.sh | 48 ++++-
.../shibboleth/idp/installer/InstallerSupport.java | 6 +-
.../ant/impl/BasicKeystoreKeyStrategyTask.java | 128 ------------
.../installer/ant/impl/MergePropertiesTask.java | 128 ------------
.../installer/ant/impl/MetadataGeneratorTask.java | 218 ---------------------
.../installer/ant/impl/RewritePropertiesTask.java | 117 -----------
.../impl/SelfSignedCertificateGeneratorTask.java | 171 ----------------
.../idp/installer/ant/impl/V4InstallTask.java | 109 -----------
.../idp/installer/ant/impl/package-info.java | 21 --
.../idp/installer/impl/CopyDistribution.java | 28 +--
.../idp/installer/impl/CurrentInstallState.java | 24 +--
.../idp/installer/impl/IdPBuildArguments.java | 3 +-
.../shibboleth/idp/installer/impl/IdPBuildWar.java | 1 +
.../idp/installer/impl/IdPInstallerArguments.java | 140 +++++++++++++
.../idp/installer/impl/IdPInstallerCLI.java | 174 ++++++++++++++++
.../idp/installer/impl/InstallerProperties.java | 150 ++++----------
.../idp/installer/impl/PasswordHandler.java | 9 +-
.../shibboleth/idp/installer/impl/V5Install.java | 52 +++--
.../resources/net/shibboleth/idp/installer/ant.xml | 7 -
.../shibboleth/idp/installer/TestInstallerCLI.java | 52 ++---
26 files changed, 493 insertions(+), 1409 deletions(-)
diff --git a/idp-distribution/src/main/resources/bin/ant-jetty.xml b/idp-distribution/src/main/resources/bin/ant-jetty.xml
deleted file mode 100644
index 96636355f..000000000
--- a/idp-distribution/src/main/resources/bin/ant-jetty.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="Shibboleth IdP V3 - Jetty Container" basedir=".." default="install">
-
- <!-- This file is for automatic configuration of Jetty, primarily from the MSI installer.
-
- Names and APIS *may* change in the future, please enter an RFI if you wish to use this
- in production outside the MSI installer.
-
- TARGETS:
-
- The only top level target is "install". This in turn calls subsidiary targets.
-
- PROPERTIES:
-
- The following properties are used. They have to be provided on the command line or
- via the property file.
-
- jetty.property.file: Name of a file to fill in all or some of the below. This file is deleted after processing.
- jetty.merge.properties: The name of a property file to merge with idp.ini. This file is deleted after processing.
- idp.host.name: The host name.
- idp.uri.subject.alt.name: If we are creating certificates.
- idp.target.dir: where to install to.
-
- idp.keystore.password: password to use on the PKCS12 file for a user-facing TLS credential,
- which will be created if one does not already exist either in JKS or PKCS12 form.
- This value must also have been written to the merge properties file as
- jetty.browser.keystore.password.
-
- jetty.no.tidy: Do not delete the two above files (debug only)
-
- -->
-
- <taskdef resource="net/shibboleth/idp/installer/ant.xml" />
-
- <target name="install" depends="init, properties, keystores, directories, copyinis, reprotect, tidy" />
-
- <target name="init">
- <tstamp />
- <hostinfo />
- </target>
-
- <target name="properties">
- <property file="${jetty.property.file}" />
- <available property="idp.ini.present" file="${idp.target.dir}/jetty-base/start.d/idp.ini" />
- <available property="idp.jks.present" file="${idp.target.dir}/credentials/idp.jks" />
- <available property="idp.userfacing.p12.present" file="${idp.target.dir}/credentials/idp-userfacing.p12" />
- <condition property="generate.userfacing.p12">
- <!-- Generate the pkcs12 keystore if neither the JKS nor the P12 exist -->
- <not>
- <or>
- <istrue value="${idp.jks.present}" />
- <istrue value="${idp.userfacing.p12.present}" />
- </or>
- </not>
- </condition>
- </target>
-
- <!-- Handle keystores -->
- <target name="keystores" depends="jks, gen-userfacing" />
-
- <target name="jks" if="idp.jks.present">
- <!-- Note that this password is the old default for QI. This will overwrite what we may have put in when the merge file was created. -->
- <echo file="${jetty.merge.properties}" append="yes">
- jetty.backchannel.keystore.type=JKS
- jetty.browser.keystore.type=JKS
- jetty.backchannel.keystore.password= SeCrEt
- jetty.browser.keystore.password= SeCrEt
- jetty.backchannel.keystore.path= ${idp.target.dir}/credentials/idp.jks
- jetty.browser.keystore.path= ${idp.target.dir}/credentials/idp.jks
- </echo>
- </target>
-
- <target name="gen-userfacing" if="generate.userfacing.p12">
- <selfsignedcert hostname="${idp.host.name}" keystoreFile="${idp.target.dir}/credentials/idp-userfacing.p12" keystorePassword="${idp.keystore.password}" uriSubjectAltNames="${idp.uri.subject.alt.name}" />
- </target>
-
- <target name="directories">
- <mkdir dir="jetty-base/start.d" />
- <mkdir dir="jetty-base/logs" />
- <mkdir dir="static" />
- </target>
-
- <target name="copyinis" depends="properties, directories, copyidpini, rewriteidpini">
- <copy file="${idp.target.dir}/jetty-base/start.d.dist/idp-system.ini" toFile="${idp.target.dir}/jetty-base/start.d/idp-system.ini" overwrite="true" force="true" />
- </target>
-
- <target name="copyidpini" depends="directories" unless="idp.ini.present">
- <mergeproperties inFile="${idp.target.dir}/jetty-base/start.d.dist/idp.ini.windows" outFile="${idp.target.dir}/jetty-base/start.d/idp.ini" mergeFile="${jetty.merge.properties}" />
- </target>
-
- <target name="rewriteidpini" depends="directories" if="idp.ini.present">
- <rewriteproperties inFile="${idp.target.dir}/jetty-base/start.d/idp.ini" outFile="${idp.target.dir}/jetty-base/start.d/idp.ini" propertyNameFile="${idp.target.dir}/jetty-base/start.d.dist/idp.ini.rewrite.property.names" />
- </target>
-
-
- <target name="reprotect">
- <chmod perm="600" dir="jetty-base/start.d" includes="**/*.key"/>
- <chmod perm="444" dir="jetty-base/etc" includes="**/*"/>
- <chmod perm="444" dir="jetty-base/lib" includes="**/*"/>
- <chmod perm="444" dir="jetty-base/webapps" includes="**/*"/>
- <attrib readonly="true">
- <fileset dir="jetty-base/etc" includes="**/*"/>
- </attrib>
- <attrib readonly="true">
- <fileset dir="jetty-base/lib" includes="**/*"/>
- </attrib>
- <attrib readonly="true">
- <fileset dir="jetty-base/webapps" includes="**/*"/>
- </attrib>
- </target>
-
- <target name="tidy" unless="jetty.no.tidy">
- <delete file="${jetty.merge.properties}" failonerror="false" />
- <delete file="${jetty.property.file}" failonerror="false" />
- </target>
-
-</project>
diff --git a/idp-distribution/src/main/resources/bin/ant.bat b/idp-distribution/src/main/resources/bin/ant.bat
deleted file mode 100644
index c08a94822..000000000
--- a/idp-distribution/src/main/resources/bin/ant.bat
+++ /dev/null
@@ -1,40 +0,0 @@
- at echo off
-setlocal
-
-REM Find the necessary resources
-set ANT_HOME=%~dp0
-
-REM strip trailing backslash - it confuses java.
-REM do it like this because embedding the strip inside an if causes problems if the name has a ")" in it.
-if "%ANT_HOME:~-1%" NEQ "\" (
- goto nostrip
-)
-set ANT_HOME=%ANT_HOME:~0,-1%
-:nostrip
-
-if defined INSTALL_LOG_FILE (
- goto got_log
-)
-set INSTALL_LOG_FILE=%ANT_HOME%\install-log.xml
-:got_log
-
-REM We need a JVM
-if not defined JAVA_HOME (
- echo Error: JAVA_HOME is not defined.
- exit /b
-)
-
-if not defined JAVACMD (
- set JAVACMD="%JAVA_HOME%\bin\java.exe"
-)
-
-if not exist %JAVACMD% (
- echo Error: JAVA_HOME is not defined correctly.
- echo Cannot execute %JAVACMD%
- exit /b
-)
-
-REM add in the dependency .jar files
-set LOCALCLASSPATH=%ANT_HOME%\..\bin\lib\*;%ANT_HOME%\..\webapp\WEB-INF\lib\*;%ANT_HOME%\..\dist\webapp\WEB-INF\lib\*;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\classes.zip;%CLASSPATH%
-
-%JAVACMD% -cp "%LOCALCLASSPATH%" -Dlogback.configurationFile="%INSTALL_LOG_FILE%" -Dant.home="%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main -e -f "%ANT_HOME%/build.xml" %*
diff --git a/idp-distribution/src/main/resources/bin/ant.sh b/idp-distribution/src/main/resources/bin/ant.sh
deleted file mode 100755
index 658f20702..000000000
--- a/idp-distribution/src/main/resources/bin/ant.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#! /bin/sh
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- Darwin*) darwin=true ;;
-esac
-
-#Find the necessary resources
-ANT_HOME=$0
-ANT_HOME=${ANT_HOME%/*}
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD=$JAVA_HOME/jre/sh/java
- else
- JAVACMD=$JAVA_HOME/bin/java
- fi
- else
- JAVACMD=$(which java)
- fi
-fi
-
-if [ -z "$INSTALL_LOG_FILE" ] ; then
- INSTALL_LOG_FILE=$ANT_HOME/install-log.xml
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly."
- echo " We cannot execute $JAVACMD"
- exit 1
-fi
-
-if [ -n "$CLASSPATH" ] ; then
- LOCALCLASSPATH=$CLASSPATH
-fi
-
-# add in the dependency .jar files
-LOCALCLASSPATH="${ANT_HOME}/../webapp/WEB-INF/lib/*":$LOCALCLASSPATH
-LOCALCLASSPATH="${ANT_HOME}/../dist/webapp/WEB-INF/lib/*":$LOCALCLASSPATH
-LOCALCLASSPATH="${ANT_HOME}/../bin/lib/*":$LOCALCLASSPATH
-
-if [ -n "$JAVA_HOME" ] ; then
- if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
- LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar
- fi
-
- if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
- LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip
- fi
-
- # OSX hack to make Ant work with jikes
- if $darwin ; then
- OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes"
- if [ -d ${OSXHACK} ] ; then
- for i in ${OSXHACK}/*.jar
- do
- JIKESPATH=$JIKESPATH:$i
- done
- fi
- fi
-fi
-
-# supply JIKESPATH to Ant as jikes.class.path
-if [ -n "$JIKESPATH" ] ; then
- if [ -n "$ANT_OPTS" ] ; then
- ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
- else
- ANT_OPTS=-Djikes.class.path=$JIKESPATH
- fi
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- ANT_HOME=`cygpath --path --windows "$ANT_HOME"`
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"`
-fi
-
-"$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Dlogback.configurationFile=$INSTALL_LOG_FILE $ANT_OPTS org.apache.tools.ant.Main -e -f "${ANT_HOME}/build.xml" "$@"
diff --git a/idp-distribution/src/main/resources/bin/build.xml b/idp-distribution/src/main/resources/bin/build.xml
deleted file mode 100644
index 000c84a38..000000000
--- a/idp-distribution/src/main/resources/bin/build.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="Shibboleth Identity Provider V4" default="install">
-
- <taskdef resource="net/shibboleth/idp/installer/ant.xml" />
-
- <!-- TARGETS:
-
- The following top level targets are implemented and supported. These in turn call subsidiary targets,
- whose use outside this file is not supported.
-
- install-nocopy: Does the installation/upgrade on a layout that has been copied (ie, the important
- stuff has been copied or overwritten from the distribution)
- A V2 upgrade will be performed if a V2 site is detected.
- build-war: Create the war file
- install: Copies files from the distribution to the specified target and then
- invokes install-nocopy
- -->
-
- <target name="install">
- <v4install task="install"/>
- </target>
- <target name="install-nocopy">
- <v4install task="install-nocopy"/>
- </target>
- <target name="build-war">
- <v4install task="build-war"/>
- </target>
-
-</project>
diff --git a/idp-distribution/src/main/resources/bin/install-log.xml b/idp-distribution/src/main/resources/bin/install-log.xml
deleted file mode 100644
index d173ee8e3..000000000
--- a/idp-distribution/src/main/resources/bin/install-log.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Logging for the installer. -->
-<configuration>
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <pattern>%-5level - %msg%n%ex{short}</pattern>
- <charset>UTF-8</charset>
- </encoder>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="STDOUT" />
- </root>
-
- <!-- Turn down some noise. -->
- <logger name="ch.qos.logback" level="WARN" />
-
-</configuration>
diff --git a/idp-distribution/src/main/resources/bin/install.bat b/idp-distribution/src/main/resources/bin/install.bat
index 0078061da..1a21999b7 100644
--- a/idp-distribution/src/main/resources/bin/install.bat
+++ b/idp-distribution/src/main/resources/bin/install.bat
@@ -1,4 +1,29 @@
@echo off
setlocal
-"%~dp0\ant.bat" %* install
+REM We need a JVM
+if not defined JAVA_HOME (
+ echo Error: JAVA_HOME is not defined.
+ exit /b
+)
+
+if not defined JAVACMD (
+ set JAVACMD="%JAVA_HOME%\bin\java.exe"
+)
+
+if not defined IDP_BASE_URL (
+ set IDP_BASE_URL="http://localhost/idp"
+)
+
+if not exist %JAVACMD% (
+ echo Error: JAVA_HOME is not defined correctly.
+ echo Cannot execute %JAVACMD%
+ exit /b
+)
+
+REM add in the dependency .jar files
+set LOCALCLASSPATH=%~dp0lib\*;%~dp0..\webapp\WEB-INF\lib\*;%JAVA_HOME%\lib\classes.zip;%CLASSPATH%
+
+REM Go to it !
+
+%JAVACMD% -cp "%LOCALCLASSPATH%" net.shibboleth.idp.installer.impl.IdPInstallerCLI --sourceDir "%~dp0\.." %*
diff --git a/idp-distribution/src/main/resources/bin/install.sh b/idp-distribution/src/main/resources/bin/install.sh
old mode 100755
new mode 100644
index 0c27088b3..ba8dbe834
--- a/idp-distribution/src/main/resources/bin/install.sh
+++ b/idp-distribution/src/main/resources/bin/install.sh
@@ -1,7 +1,53 @@
#!/usr/bin/env bash
declare LOCATION
+declare COMMAND
+declare JAVACMD
+declare LOCALCLASSPATH
+declare LIBDIR
LOCATION=$(dirname $0)
-$LOCATION/ant.sh "$@" install
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ else
+ JAVACMD=$(which java)
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly."
+ echo " We cannot execute $JAVACMD"
+ exit 1
+fi
+
+if [ -n "$CLASSPATH" ] ; then
+ LOCALCLASSPATH=$CLASSPATH
+fi
+
+if [ -z "$IDP_BASE_URL" ] ; then
+ IDP_BASE_URL="http://localhost/idp"
+fi
+
+# add in the dependency .jar files
+
+LOCALCLASSPATH="$LOCATION/../webapp/WEB-INF/lib/*":$LOCALCLASSPATH
+LOCALCLASSPATH="$LOCATION/lib/*":$LOCALCLASSPATH
+
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
+ LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar
+ fi
+
+ if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
+ LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip
+ fi
+fi
+
+"$JAVACMD" '-classpath' "$LOCALCLASSPATH" net.shibboleth.idp.installer.impl.IdPInstallerCLI --ansi --sourceDir "$LOCATION/.." "$@"
\ No newline at end of file
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerSupport.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerSupport.java
index 0c2561d4c..e9b8f814e 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerSupport.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/InstallerSupport.java
@@ -21,6 +21,8 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import javax.annotation.Nonnull;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Chmod;
@@ -35,7 +37,7 @@ import org.apache.tools.ant.types.selectors.PresentSelector;
import org.apache.tools.ant.types.selectors.PresentSelector.FilePresence;
import org.slf4j.Logger;
-import net.shibboleth.idp.installer.impl.InstallationLogger;
+import net.shibboleth.shared.primitive.LoggerFactory;
/** General common names and helper functions for the Installer.
* This is not intended for general use.
@@ -52,7 +54,7 @@ public final class InstallerSupport {
private static final Project ANT_PROJECT = new Project();
/** Log. */
- private static Logger log = InstallationLogger.getLogger(InstallerSupport.class);
+ @Nonnull private static Logger log = LoggerFactory.getLogger(InstallerSupport.class);
/** Private Constructor. */
private InstallerSupport() {}
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
deleted file mode 100644
index b507c129e..000000000
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/BasicKeystoreKeyStrategyTask.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.annotation.constraint.Positive;
-import net.shibboleth.shared.security.impl.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
deleted file mode 100644
index 5470ab416..000000000
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MergePropertiesTask.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.shared.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
deleted file mode 100644
index 494bbd2f9..000000000
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/MetadataGeneratorTask.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * 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 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.idp.installer.metadata.impl.MetadataGenerator;
-import net.shibboleth.idp.installer.metadata.impl.MetadataGeneratorParameters;
-import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.spring.util.ApplicationContextBuilder;
-
-/**
- * Task to generate metadata.
- */
-public class MetadataGeneratorTask extends Task {
-
- /** 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(@Nonnull 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() {
- final File file = outputFile;
- if (file == null) {
- log("Build Failed - output file not provided", Project.MSG_ERR);
- throw new BuildException("Build Failed - output file not provided");
- }
- final String dns = dnsName;
- if (dns == null) {
- log("Build Failed - DNS Name not provided", Project.MSG_ERR);
- throw new BuildException("DNS Name - output file not provided");
- }
- try {
- final MetadataGeneratorParameters parameters;
-
- final Resource resource = new ClassPathResource("net/shibboleth/idp/installer/metadata-generator-ant.xml");
-
- final GenericApplicationContext context = new ApplicationContextBuilder()
- .setName(MetadataGeneratorTask.class.getName())
- .setServiceConfigurations(CollectionSupport.singletonList(resource))
- .setContextInitializer(new Initializer())
- .build();
-
- parameters = context.getBean("IdPConfiguration", MetadataGeneratorParameters.class);
-
- parameters.setBackchannelCert(backchannelCert);
- parameters.setDnsName(dns);
- parameters.initialize();
-
- final MetadataGenerator generator = new MetadataGenerator();
- generator.setSAML2AttributeQueryCommented(saml2AttributeQueryCommented);
- generator.setSAML2LogoutCommented(saml2LogoutCommented);
- generator.setParameters(parameters);
- generator.setOutput(file);
- 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) {
- final String result = idpHome;
- if (null == result) {
- return super.selectSearchLocation(applicationContext);
- }
- return result;
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public String getSearchLocation() {
- final String result = idpHome;
- if (null == result) {
- return super.getSearchLocation();
- }
- return result;
- }
-
- }
-}
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
deleted file mode 100644
index b5d139fa1..000000000
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/RewritePropertiesTask.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.shared.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
deleted file mode 100644
index 238121318..000000000
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/SelfSignedCertificateGeneratorTask.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.shared.annotation.constraint.NonnullElements;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.annotation.constraint.Positive;
-import net.shibboleth.shared.primitive.StringSupport;
-import net.shibboleth.shared.security.impl.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);
- }
-
- /** {@inheritDoc}. */
- @Override
- 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/java/net/shibboleth/idp/installer/ant/impl/V4InstallTask.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/V4InstallTask.java
deleted file mode 100644
index 16df4edf9..000000000
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/V4InstallTask.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import javax.annotation.Nonnull;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.slf4j.Logger;
-
-import net.shibboleth.idp.installer.impl.BuildWar;
-import net.shibboleth.idp.installer.impl.CopyDistribution;
-import net.shibboleth.idp.installer.impl.CurrentInstallState;
-import net.shibboleth.idp.installer.impl.InstallerProperties;
-import net.shibboleth.idp.installer.impl.V5Install;
-import net.shibboleth.idp.installer.metadata.impl.MetadataGenerator;
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.primitive.StringSupport;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * A thin veneer around the V4 installer.
- */
-public class V4InstallTask extends Task {
-
- /** What to do?*/
- private String task;
-
- /** set what to do.
- * @param what the value to set. One of "install", "install-nocopy", "build-war"
- */
- public void setTask(@Nonnull final String what) {
- task = Constraint.isNotNull(StringSupport.trimOrNull(what), "Task must be non-null").toLowerCase();
- }
-
- @Override public void execute() {
- final Logger log = LoggerFactory.getLogger(V4InstallTask.class);
- boolean copyInstall = false;
- boolean doInstall = false;
- if ("install".equals(task)) {
- copyInstall = true;
- doInstall = true;
- } else if ("install-nocopy".equals(task)) {
- doInstall = true;
- } else if (!"build-war".equals(task)) {
- log.error("Parameter must be \"install\", \"install-nocopy\" or \"build-war\" was \"{}\"", task);
- throw new BuildException("Invalid parameter to task");
- }
- try {
- final InstallerProperties ip = new InstallerProperties(!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(),
- CollectionSupport.warningMergeFunction("InstallerProperties", true))));
-
- final CurrentInstallState is;
- ip.initialize();
- is = new CurrentInstallState(ip);
- is.initialize();
- if (copyInstall) {
- final CopyDistribution dist = new CopyDistribution(ip, is);
- dist.initialize();
- dist.execute();
- }
-
- if (doInstall) {
- final V5Install inst = new V5Install(ip, is);
- inst.setMetadataGenerator(new MetadataGenerator());
- inst.initialize();
- inst.execute();
- }
-
- final BuildWar bw = new BuildWar(ip.getTargetDir());
- bw.initialize();
- bw.execute();
- } catch (final ComponentInitializationException e) {
- log.error("Could set up state", e);
- throw new BuildException(e);
- }
- }
-}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/package-info.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/package-info.java
deleted file mode 100644
index 93116d335..000000000
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/ant/impl/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-/**
- * Targets for Ant.
- */
-
-package net.shibboleth.idp.installer.ant.impl;
\ No newline at end of file
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CopyDistribution.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CopyDistribution.java
index ff820f6ae..7b4393ff1 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CopyDistribution.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CopyDistribution.java
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
import net.shibboleth.idp.installer.InstallerSupport;
import net.shibboleth.shared.component.AbstractInitializableComponent;
import net.shibboleth.shared.component.UninitializedComponentException;
-import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Copy the distribution to the final location. Prior to doing so
@@ -39,27 +39,20 @@ import net.shibboleth.shared.logic.Constraint;
public final class CopyDistribution extends AbstractInitializableComponent {
/** Log. */
- private final Logger log = InstallationLogger.getLogger(CopyDistribution.class);
+ private final Logger log = LoggerFactory.getLogger(CopyDistribution.class);
/** Properties for the job. */
@Nonnull private final InstallerProperties installerProps;
- /** The state of the current install. */
- @Nonnull private final CurrentInstallState installState;
-
/** Constructor.
* @param props The environment for the work.
* @param state Where we are right now.
*/
- public CopyDistribution(@Nonnull final InstallerProperties props, @Nonnull final CurrentInstallState state) {
+ public CopyDistribution(@Nonnull final InstallerProperties props) {
+ installerProps = props;
if (!props.isInitialized()) {
throw new UninitializedComponentException("Installer Properties not Initialized");
}
- if (!state.isInitialized()) {
- throw new UninitializedComponentException("Installer State not Initialized");
- }
- installerProps = Constraint.isNotNull(props, "Installer Properties should be non null");
- installState = Constraint.isNotNull(state, "Current state should be non-null");
}
/** Copy the distribution from the dstribution to their new locations, having
@@ -70,7 +63,7 @@ public final class CopyDistribution extends AbstractInitializableComponent {
checkComponentActive();
deleteOld();
copyDist();
- copyBinDocSystem();
+ copyBinDoc();
}
/** Helper for the {@link #deleteOld()} method.
@@ -100,12 +93,12 @@ public final class CopyDistribution extends AbstractInitializableComponent {
final Path system = installerProps.getTargetDir().resolve("system");
if (Files.exists(system)) {
InstallerSupport.setReadOnly(system, false);
+ delete(system, null);
}
- delete(system, null);
}
/** Helper for the {@link #copyDist()} and
- * {@link #copyBinDocSystem()} methods.
+ * {@link #copyBinDoc()} methods.
* @param srcDist the source distribution.
* @param dist the dist directory
* @param to the subfolder name
@@ -123,7 +116,7 @@ public final class CopyDistribution extends AbstractInitializableComponent {
}
/** Helper for the {@link #copyDist()} and
- * {@link #copyBinDocSystem()} methods.
+ * {@link #copyBinDoc()} methods.
* @param srcDist the source distribution.
* @param dist the dist directory
* @param to the subfolder name
@@ -151,11 +144,8 @@ public final class CopyDistribution extends AbstractInitializableComponent {
/** Populate the per distribution (but non dist) folders.
* @throws BuildException if badness occurs
*/
- protected void copyBinDocSystem() {
+ protected void copyBinDoc() {
distCopy(installerProps.getSourceDir(), installerProps.getTargetDir(), "bin/lib", true);
distCopy(installerProps.getSourceDir(), installerProps.getTargetDir(), "doc");
- if (installState.isSystemPresent()) {
- distCopy(installerProps.getSourceDir(), installerProps.getTargetDir(), "system");
- }
}
}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallState.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallState.java
index cd1a0f6b1..091106e71 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallState.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallState.java
@@ -61,7 +61,7 @@ import net.shibboleth.shared.primitive.LoggerFactory;
public final class CurrentInstallState extends AbstractInitializableComponent {
/** Class logger. */
- @Nonnull private final Logger log = InstallationLogger.getLogger(CurrentInstallState.class);
+ @Nonnull private final Logger log = LoggerFactory.getLogger(CurrentInstallState.class);
/** Where we are installing to. */
@Nonnull private final Path targetDir;
@@ -78,9 +78,6 @@ public final class CurrentInstallState extends AbstractInitializableComponent {
/** Whether the LDAP properties file exists.*/
private boolean ldapPropertiesPresent;
- /** Whether system is present. */
- private boolean systemPresent;
-
/** Old Version. */
private String oldVersion;
@@ -107,10 +104,10 @@ public final class CurrentInstallState extends AbstractInitializableComponent {
private void findPreviousVersion() throws ComponentInitializationException {
final Path conf = targetDir.resolve("conf");
final Path currentInstall = targetDir.resolve("dist").resolve(InstallerSupport.VERSION_NAME);
- final Path rp = conf.resolve("idp.properties");
- if (!Files.exists(rp)) {
- // No relying party, no install
- log.debug("No idp.properties file detetected at {} . Inferring a clean install", rp);
+ final Path ip = conf.resolve("idp.properties");
+ if (!Files.exists(ip)) {
+ // No idp.properties, no install
+ log.debug("No idp.properties file detetected at {} . Inferring a clean install", ip);
oldVersion = null;
} else if (!Files.exists(currentInstall)) {
throw new ComponentInitializationException("V3 Installation detected");
@@ -205,7 +202,11 @@ public final class CurrentInstallState extends AbstractInitializableComponent {
idpPropertiesPresent = Files.exists(targetDir.resolve("conf").resolve("idp.properties"));
ldapPropertiesPresent = Files.exists(targetDir.resolve("conf").resolve("ldap.properties"));
- systemPresent = Files.exists(targetDir.resolve("system"));
+ if (Files.exists(targetDir.resolve("system"))) {
+ log.error("'system' folder exists emove this and make appropriate changes to web.xml before proceeding");
+ log.error("see https://shibboleth.atlassian.net/wiki/spaces/IDP5/pages/3199500925/Upgrading");
+ throw new ComponentInitializationException("'systems folder exists");
+ }
findPreviousVersion();
setupPreviousProps();
findEnabledModules();
@@ -255,11 +256,6 @@ public final class CurrentInstallState extends AbstractInitializableComponent {
return pathsToDelete;
}
- /** {@inheritDoc} */
- public boolean isSystemPresent() {
- return systemPresent;
- }
-
/** {@inheritDoc} */
@Nonnull public Collection<String> getEnabledModules() {
return enabledModules;
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildArguments.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildArguments.java
index ccd35fe6d..7d99ae834 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildArguments.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildArguments.java
@@ -25,6 +25,7 @@ import javax.annotation.Nullable;
import org.slf4j.Logger;
import net.shibboleth.idp.cli.AbstractIdPHomeAwareCommandLineArguments;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Command line arguments for the "build" verb.
@@ -37,7 +38,7 @@ public class IdPBuildArguments extends AbstractIdPHomeAwareCommandLineArguments
/** {@inheritDoc} */
public @Nonnull Logger getLog() {
if (log == null) {
- log = InstallationLogger.getLogger(IdPBuildArguments.class);
+ log = LoggerFactory.getLogger(IdPBuildArguments.class);
}
assert log != null;
return log;
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildWar.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildWar.java
index d86a4c59c..9b00ab0d5 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildWar.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPBuildWar.java
@@ -80,6 +80,7 @@ public class IdPBuildWar extends AbstractCommandLine<IdPBuildArguments> {
}
final Path idpHome = Path.of(args.getIdPHome());
+ assert idpHome!=null;
if (!Files.exists(idpHome)) {
getLogger().error("Could not find {}", idpHome);
return RC_INIT;
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerArguments.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerArguments.java
new file mode 100644
index 000000000..e2d7501bf
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerArguments.java
@@ -0,0 +1,140 @@
+/*
+ * 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.impl;
+
+import java.io.PrintStream;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.security.httpclient.HttpClientSecurityParameters;
+import org.slf4j.Logger;
+
+import com.beust.jcommander.Parameter;
+
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.cli.AbstractCommandLineArguments;
+import net.shibboleth.shared.primitive.LoggerFactory;
+
+/**
+ * Command line argumebnts for the "install" verb.
+ */
+public class IdPInstallerArguments extends AbstractCommandLineArguments {
+
+ /** Logger. */
+ @Nullable private Logger log;
+
+ /** The PluginId - usually used to drive the update. */
+ @Parameter(names= {"-s", "--sourceDir"})
+ @Nullable private String sourceDir;
+
+ /** The PluginId - usually used to drive the update. */
+ @Parameter(names= {"-t", "--targetDir"})
+ @Nullable private String targetDir;
+
+ /** Suppress Prompts. */
+ @Parameter(names= {"--noPrompt"})
+ private boolean noPrompt;
+
+ /** Import Property File. */
+ @Parameter(names= {"--propertyFile"})
+ private String propertyFile;
+
+ /** Name for the {@link org.apache.hc.client5.http.classic.HttpClient} . */
+ @Parameter(names= {"-hc", "--http-client"})
+ @Nullable @NotEmpty private String httpClientName;
+
+ /** Name for the {@link HttpClientSecurityParameters} . */
+ @Parameter(names= {"-hs", "--http-security"})
+ @Nullable @NotEmpty private String httpClientSecurityParametersName;
+
+ /** {@inheritDoc} */
+ public @Nonnull Logger getLog() {
+ if (log == null) {
+ log = LoggerFactory.getLogger(IdPInstallerArguments.class);
+ }
+ assert log != null;
+ return log;
+ }
+
+ /** Are we doing an unattended install?
+ *
+ * @return whether we're doing an unattended install
+ */
+ public boolean isUnattended() {
+ return noPrompt;
+ }
+
+ /** Get the target Directory.
+ *
+ * @return {@link #targetDir}
+ */
+ @Nullable public String getTargetDirectory() {
+ return targetDir;
+ }
+
+ /** Get the source Directory.
+ *
+ * @return {@link #sourceDir}
+ */
+ @Nullable public String getSourceDir() {
+ return sourceDir;
+ }
+
+ /** Get the propertyFile.
+ * @return {@link #propertyFile}
+ */
+ @Nullable public String getPropertyFile() {
+ return propertyFile;
+ }
+
+ /**
+ * Get bean name for the {@link org.apache.hc.client5.http.classic.HttpClient} (if specified).
+ *
+ * @return the name or null
+ */
+ @Nullable @NotEmpty public String getHttpClientName() {
+ return httpClientName;
+ }
+
+ /**
+ * Get bean name for the {@link HttpClientSecurityParameters} (if specified).
+ *
+ * @return the name or null
+ */
+ @Nullable @NotEmpty public String getHttpClientSecurityParametersName() {
+ return httpClientSecurityParametersName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void printHelp(final @Nonnull PrintStream out) {
+ out.println("Install");
+ out.println("Installs or upgrades an IdP");
+ out.println();
+ out.println(" Install [options] springConfiguration");
+ out.println();
+ out.println(" springConfiguration name of Spring configuration resource to use");
+ super.printHelp(out);
+ out.println();
+ out.println(String.format(" %-22s %s", "-t, --targetDir", "Where to install the IdP or location to update"));
+ out.println(String.format(" %-22s %s", "--propertyFile", "Property file containing other parameterization"));
+ out.println(String.format(" %-22s %s", "--noPrompt", "Unattended Install"));
+ out.println();
+ }
+
+}
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
new file mode 100644
index 000000000..71a94e7ab
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java
@@ -0,0 +1,174 @@
+/*
+ * 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.impl;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.tools.ant.BuildException;
+import org.opensaml.security.httpclient.HttpClientSecurityParameters;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+
+import net.shibboleth.idp.Version;
+import net.shibboleth.shared.cli.AbstractCommandLine;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.LoggerFactory;
+
+/**
+ * Command line installer.
+ */
+public class IdPInstallerCLI extends AbstractCommandLine<IdPInstallerArguments> {
+
+ @Nullable private Logger log;
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull
+ protected Class<IdPInstallerArguments> getArgumentClass() {
+ // TODO Auto-generated method stub
+ return IdPInstallerArguments.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull
+ protected String getVersion() {
+ final String result = Version.getVersion();
+ assert result != null;
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull
+ protected Logger getLogger() {
+ Logger localLog = log;
+ if (localLog == null) {
+ localLog = log = LoggerFactory.getLogger(IdPInstallerCLI.class);
+ }
+ return localLog;
+ }
+
+ /** {@inheritDoc} */
+ protected int doRun(@Nonnull final IdPInstallerArguments args) {
+
+ super.doRun(args);
+
+ final Path source = Path.of(args.getSourceDir());
+ assert source!=null;
+ if (!Files.exists(source)) {
+ getLogger().error("Could not find {}", source);
+ return RC_INIT;
+ }
+
+ String clientName = args.getHttpClientName();
+ if (clientName == null) {
+ clientName = "shibboleth.InternalHttpClient";
+ }
+
+ @Nonnull final HttpClient httpClient;
+ try {
+ httpClient = getApplicationContext().getBean(clientName, HttpClient.class);
+ } catch (final NoSuchBeanDefinitionException e) {
+ getLogger().error("Could not locate HttpClient '{}'", args.getHttpClientName());
+ return RC_IO;
+ }
+
+ final String securityParametersName = args.getHttpClientSecurityParametersName();
+ HttpClientSecurityParameters clientSecurityParameters = null;
+ if (securityParametersName != null) {
+ try {
+ clientSecurityParameters =
+ getApplicationContext().getBean(securityParametersName, HttpClientSecurityParameters.class);
+ } catch (final NoSuchBeanDefinitionException e) {
+ getLogger().error("Could not locate HttpClientSecurityParameters '{}'",
+ args.getHttpClientSecurityParametersName());
+ return RC_IO;
+ }
+ }
+
+ if (args.isUnattended()) {
+ System.setProperty(InstallerProperties.NO_PROMPT, "true");
+ }
+
+ final String propFile = args.getPropertyFile();
+ if (propFile!=null) {
+ System.setProperty(InstallerProperties.PROPERTY_SOURCE_FILE, propFile);
+ }
+
+ final String target = args.getTargetDirectory();
+ if (target!=null) {
+ System.setProperty(InstallerProperties.TARGET_DIR, target);
+ }
+
+ try {
+ final InstallerProperties ip = new InstallerProperties(source);
+ ip.initialize();
+ final CurrentInstallState ic = new CurrentInstallState(ip);
+ ic.initialize();
+
+ final CopyDistribution cd = new CopyDistribution(ip);
+ cd.initialize();
+ cd.execute();
+
+ final V5Install install = new V5Install(ip, ic, httpClient, clientSecurityParameters);
+ install.initialize();
+ install.execute();
+
+ final BuildWar bw = new BuildWar(ip.getTargetDir());
+ bw.initialize();
+ bw.execute();
+
+ } catch (final ComponentInitializationException e) {
+ getLogger().error("Installation setup failed", e);
+ return RC_IO;
+ } catch (final BuildException e) {
+ getLogger().error("Installation run failed", e);
+ return RC_IO;
+ }
+ return RC_OK;
+ }
+
+ /** Shim for CLI entry point: Allows the code to be run from a test.
+ *
+ * @return one of the predefines {@link AbstractCommandLine#RC_INIT},
+ * {@link AbstractCommandLine#RC_IO}, {@link AbstractCommandLine#RC_OK}
+ * or {@link AbstractCommandLine#RC_UNKNOWN}
+ *
+ * @param args arguments
+ */
+ public static int runMain(@Nonnull final String[] args) {
+ final IdPInstallerCLI cli = new IdPInstallerCLI();
+
+ return cli.run(args);
+ }
+
+ /**
+ * CLI entry point.
+ * @param args arguments
+ */
+ public static void main(@Nonnull final String[] args) {
+ System.exit(runMain(args));
+ }
+
+}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerProperties.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerProperties.java
index a5202bf3f..cee2bddaa 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerProperties.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerProperties.java
@@ -28,7 +28,6 @@ import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -39,16 +38,15 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.input.DefaultInputHandler;
import org.apache.tools.ant.input.InputHandler;
import org.apache.tools.ant.input.InputRequest;
-import org.apache.tools.ant.launch.Launcher;
import org.slf4j.Logger;
-import net.shibboleth.idp.installer.ant.impl.PasswordHandler;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.AbstractInitializableComponent;
import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.NonnullSupplier;
import net.shibboleth.shared.primitive.StringSupport;
@@ -59,9 +57,6 @@ import net.shibboleth.shared.primitive.StringSupport;
*/
public class InstallerProperties extends AbstractInitializableComponent {
- /** The base directory, inherited and shared with ant. */
- public static final String ANT_BASE_DIR = Launcher.ANTHOME_PROPERTY;
-
/** The name of a property file to fill in some or all of the above. This file is deleted after processing. */
public static final String PROPERTY_SOURCE_FILE = "idp.property.file";
@@ -77,9 +72,6 @@ public class InstallerProperties extends AbstractInitializableComponent {
/** Where to install to. Default is basedir */
public static final String TARGET_DIR = "idp.target.dir";
- /** Where to install from (installs only). */
- public static final String SOURCE_DIR = "idp.src.dir";
-
/** The entity ID. */
public static final String ENTITY_ID = "idp.entityID";
@@ -124,10 +116,7 @@ public class InstallerProperties extends AbstractInitializableComponent {
public static final int DEFAULT_KEY_SIZE = 3072;
/** Class logger. */
- @Nonnull private final Logger log = InstallationLogger.getLogger(InstallerProperties.class);
-
- /** The base directory. */
- @NonnullAfterInit private Path baseDir;
+ @Nonnull private final Logger log = LoggerFactory.getLogger(InstallerProperties.class);
/** The properties driving the install. */
@NonnullAfterInit private Properties installerProperties;
@@ -136,14 +125,11 @@ public class InstallerProperties extends AbstractInitializableComponent {
private Path targetDir;
/** The sourceDirectory. */
- private Path srcDir;
+ @Nonnull private final Path srcDir;
/** Do we allow prompting?*/
private boolean noPrompt;
- /** Is a source Dir needed? */
- private final boolean needSourceDir;
-
/** The entity ID. */
private String entityID;
@@ -174,9 +160,6 @@ public class InstallerProperties extends AbstractInitializableComponent {
/** credentials key file mode. */
private String credentialsKeyFileMode;
- /** Local overload of properties (to deal with nested calling). */
- private Map<String, String> inheritedProperties;
-
/** Input handler from the prompting. */
private final InputHandler inputHandler;
@@ -191,75 +174,41 @@ public class InstallerProperties extends AbstractInitializableComponent {
* Constructor.
* @param copiedDistribution Has the distribution been copied? If no we don't need the source dir.
*/
- public InstallerProperties(final boolean copiedDistribution) {
- needSourceDir = !copiedDistribution;
+ public InstallerProperties(@Nonnull final Path sourceDir) {
+ srcDir = sourceDir;
inputHandler = getInputHandler();
- inheritedProperties = CollectionSupport.emptyMap();
}
/** Get an {@link InputHandler} for the prompting.
* @return an input handler */
protected InputHandler getInputHandler() {
return new DefaultInputHandler() {
- // we wants the prompts to be more obviously prompts
+ // we want the prompts to be more obviously prompts
protected String getPrompt(final InputRequest request) {
return super.getPrompt(request) + " ? ";
}
};
}
- /** 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());
+ if (!Files.exists(srcDir)) {
+ log.error("Source dir {} did not exist", srcDir.toAbsolutePath());
+ throw new ComponentInitializationException(srcDir.toString() + " must exist");
}
+ log.debug("Source dir {}", srcDir);
- final String antBase = installerProperties.getProperty(ANT_BASE_DIR);
- if (antBase == null) {
- throw new ComponentInitializationException(ANT_BASE_DIR + " must be specified");
- }
- try {
- baseDir = Path.of(antBase).resolve("..").toRealPath();
- } catch (final IOException e) {
- throw new ComponentInitializationException(e);
- }
- if (!Files.exists(baseDir)) {
- log.error("Base dir {} did not exist", baseDir.toAbsolutePath());
- throw new ComponentInitializationException(ANT_BASE_DIR + " must exist");
- }
- log.debug("base dir {}", baseDir);
- final String noTidy = installerProperties.getProperty(NO_TIDY);
- tidy = noTidy == null;
- final String setModeString = installerProperties.getProperty(PERFORM_SET_MODE);
- if (setModeString != null) {
- setGroupAndMode = Boolean.valueOf(setModeString);
- }
-
- final String propertyFile = installerProperties.getProperty(PROPERTY_SOURCE_FILE);
+ final Path propertyFile = getMergeFile(PROPERTY_SOURCE_FILE);
if (propertyFile != null) {
- final Path file = baseDir.resolve(propertyFile);
- if (!Files.exists(file)) {
- log.error("Property file {} did not exist", file.toAbsolutePath());
- throw new ComponentInitializationException(file + " must exist");
- }
- log.debug("Loading properties from {}", file.toAbsolutePath());
-
/* The file specified in the system file idp.property.file (if present). */
- final File idpPropertyFile = file.toFile();
+ final File idpPropertyFile = propertyFile.toFile();
try(final FileInputStream stream = new FileInputStream(idpPropertyFile)) {
installerProperties.load(stream);
} catch (final IOException e) {
- log.error("Could not load {}: {}", file.toAbsolutePath(), e.getMessage());
+ log.error("Could not load {}: {}", propertyFile.toAbsolutePath(), e.getMessage());
throw new ComponentInitializationException(e);
}
if (!isNoTidy()) {
@@ -267,18 +216,16 @@ public class InstallerProperties extends AbstractInitializableComponent {
}
}
+ final String noTidy = installerProperties.getProperty(NO_TIDY);
+ tidy = noTidy == null;
+ final String setModeString = installerProperties.getProperty(PERFORM_SET_MODE);
+ if (setModeString != null) {
+ setGroupAndMode = Boolean.valueOf(setModeString);
+ }
+
String value = installerProperties.getProperty(NO_PROMPT);
noPrompt = value != null;
- if (needSourceDir) {
- final String baseDirAsString = baseDir.toString();
- assert baseDirAsString!=null;
- value = getValue(SOURCE_DIR, "Source (Distribution) Directory (press <enter> to accept default):",
- () -> baseDirAsString);
- srcDir = Path.of(value);
- log.debug("Source directory {}", srcDir.toAbsolutePath());
- }
-
value = installerProperties.getProperty(KEY_SIZE);
if (value == null) {
keySize = DEFAULT_KEY_SIZE;
@@ -356,16 +303,7 @@ public class InstallerProperties extends AbstractInitializableComponent {
if (targetDir != null) {
return targetDir;
}
- final String defTarget;
- if (needSourceDir) {
- // Source is not "here"
- defTarget = "/opt/shibboleth-idp";
- } else {
- // build-war or Windows so "here" is also "where"
- defTarget = baseDir.toAbsolutePath().toString();
- assert defTarget!=null;
- }
- final Path td = targetDir = Path.of(getValue(TARGET_DIR, "Installation Directory:", () -> defTarget));
+ final Path td = targetDir = Path.of(getValue(TARGET_DIR, "Installation Directory:", () -> "/opt/shibboleth-idp"));
assert td != null;
return td;
}
@@ -615,45 +553,31 @@ public class InstallerProperties extends AbstractInitializableComponent {
/** 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
+ * @return null if the property is not provided a {@link Path} otherwise
* @throws BuildException if the property is supplied but the file doesn't exist.
*/
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 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");
- }
- 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");
- }
+ Path path = Path.of(propValue);
+ if (Files.exists(path)) {
+ log.debug("Property '{}' had value '{}' Path exists ", propName, propValue);
+ } else {
+ path = srcDir.resolve(path);
+ if (!Files.exists(path)) {
+ log.debug("Property '{}' had value '{}' neither '{}' nor '{}' exist", propName, propValue, path);
+ log.error("Path '{}' supplied for '{}' does not exist", propValue, propName);
+ throw new BuildException("Property file not found");
}
+ log.debug("Property '{}' had value '{}' Path {} exists ", propName, propValue, path);
}
- return result;
+ if (Files.isDirectory(path)) {
+ log.error("Path '{}' supplied by property '{}' was not a file", path, propName);
+ throw new BuildException("No a file");
+ }
+ return path;
}
/** Get the a file to merge with idp.properties or null.
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/PasswordHandler.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/PasswordHandler.java
index d271817b1..a350ecc88 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/PasswordHandler.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/PasswordHandler.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package net.shibboleth.idp.installer.ant.impl;
+package net.shibboleth.idp.installer.impl;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,9 +29,14 @@ import org.apache.tools.ant.input.SecureInputHandler;
import net.shibboleth.idp.installer.PropertiesWithComments;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import org.slf4j.Logger;
+
/** Ant helper class to ask for passwords, rejecting zero length passwords and asking for confirmation. */
public class PasswordHandler extends SecureInputHandler {
+
+ @Nonnull final private Logger log = LoggerFactory.getLogger(PasswordHandler.class);
/** Spool the file to a {@link PropertiesWithComments}, read it in again as a {@link Properties} and check
* for equivalence.
@@ -60,7 +65,7 @@ public class PasswordHandler extends SecureInputHandler {
// test
return password.equals(loadProps.getProperty(propertyName));
} catch (final IOException e) {
- System.console().printf("Internal error :\n" + e.getStackTrace() + "\n");
+ log.error("Internal error", e);
return false;
}
}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/V5Install.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/V5Install.java
index 39a899a91..f1e3d6fbc 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/V5Install.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/V5Install.java
@@ -37,8 +37,11 @@ import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.tools.ant.BuildException;
+import org.opensaml.security.httpclient.HttpClientSecurityParameters;
import org.slf4j.Logger;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
@@ -62,6 +65,7 @@ import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.AbstractInitializableComponent;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.component.UninitializedComponentException;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.security.impl.BasicKeystoreKeyStrategyTool;
import net.shibboleth.shared.security.impl.SelfSignedCertificateGenerator;
@@ -74,7 +78,7 @@ import net.shibboleth.shared.spring.util.ApplicationContextBuilder;
public class V5Install extends AbstractInitializableComponent {
/** Log. */
- private final Logger log = InstallationLogger.getLogger(V5Install.class);
+ private final Logger log = LoggerFactory.getLogger(V5Install.class);
/** Installer Properties. */
@Nonnull private final InstallerProperties installerProps;
@@ -86,13 +90,20 @@ public class V5Install extends AbstractInitializableComponent {
@Nonnull private final KeyManagement keyManager;
/** What will generate metadata? */
- private MetadataGenerator metadataGenerator;
+ @Nonnull private final MetadataGenerator metadataGenerator = new MetadataGenerator();
+
+ /** The HttpClient to use.*/
+ @Nonnull private final HttpClient httpClient;
+
+ /** The Injected security parameters. */
+ @Nullable private final HttpClientSecurityParameters httpClientSecurityParameters;
/** Constructor.
* @param props The properties to drive the installs.
* @param installState The current install.
*/
- public V5Install(@Nonnull final InstallerProperties props, @Nonnull final CurrentInstallState installState) {
+ public V5Install(@Nonnull final InstallerProperties props, @Nonnull final CurrentInstallState installState,
+ @Nonnull final HttpClient client, @Nullable final HttpClientSecurityParameters securityParams) {
if (!props.isInitialized()) {
throw new UninitializedComponentException("Installer Properties not Initialized");
}
@@ -101,6 +112,8 @@ public class V5Install extends AbstractInitializableComponent {
}
installerProps = props;
currentState = installState;
+ httpClient = client;
+ httpClientSecurityParameters = securityParams;
keyManager = new KeyManagement(installerProps, currentState);
}
@@ -108,9 +121,6 @@ public class V5Install extends AbstractInitializableComponent {
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
keyManager.initialize();
- if (metadataGenerator == null) {
- log.warn("No MetadataGenerator configured.");
- }
}
/** Method to do the work. It assumes that the distribution has been copied.
@@ -129,17 +139,6 @@ public class V5Install extends AbstractInitializableComponent {
generateMetadata();
reprotect();
}
-
- /** Set the {@link MetadataGenerator}.
- * @param what what to set. This need not have been initialized yet
- * {@link MetadataGenerator#setOutput(File)} and
- * {@link MetadataGenerator#setParameters(MetadataGeneratorParameters)} are called
- * prior to initialization.
- */
- public void setMetadataGenerator(final MetadataGenerator what) {
- checkSetterPreconditions();
- metadataGenerator = what;
- }
/** Check for any preconditions to the install.
* @throws BuildException if one is broken.
@@ -162,6 +161,7 @@ public class V5Install extends AbstractInitializableComponent {
try {
log.debug("Considering Plugin {}, version {}", pluginId, pluginVersion);
final PluginState state = new PluginState(plugin, CollectionSupport.emptyList());
+ state.setHttpClient(httpClient);
state.initialize();
if (!state.getPluginInfo().isSupportedWithIdPVersion(pluginVersion, idpVersion)) {
log.warn("Installed Plugin {} version {} is not supported with IdP Version {}, continuing.",
@@ -181,11 +181,11 @@ public class V5Install extends AbstractInitializableComponent {
final String installedVersion = currentState.getInstalledVersion();
String currentVersion = Version.getVersion();
if (null == currentVersion) {
- currentVersion = "4Generic";
+ currentVersion = "5Generic";
}
if (null == installedVersion) {
log.info("New Install. Version: {}", currentVersion);
- } else if (currentVersion == installedVersion) {
+ } else if (currentVersion.equals(installedVersion)) {
log.info("Reinstall of version {}", currentVersion);
} else {
log.info("Update from version {} to version {}", installedVersion, currentVersion);
@@ -384,6 +384,8 @@ public class V5Install extends AbstractInitializableComponent {
final String targetDir = installerProps.getTargetDir().toString();
assert targetDir!=null;
final ModuleContext moduleContext = new ModuleContext(targetDir);
+ moduleContext.setHttpClient(httpClient);
+ moduleContext.setHttpClientSecurityParameters(httpClientSecurityParameters);
final Iterator<IdPModule> modules = ServiceLoader.load(IdPModule.class).iterator();
while (modules.hasNext()) {
@@ -412,6 +414,8 @@ public class V5Install extends AbstractInitializableComponent {
final String targetDir = installerProps.getTargetDir().toString();
assert targetDir!=null;
final ModuleContext moduleContext = new ModuleContext(targetDir);
+ moduleContext.setHttpClient(httpClient);
+ moduleContext.setHttpClientSecurityParameters(httpClientSecurityParameters);
final Iterator<IdPModule> modules = ServiceLoader.load(IdPModule.class).iterator();
while (modules.hasNext()) {
@@ -462,10 +466,6 @@ public class V5Install extends AbstractInitializableComponent {
* @throws BuildException if badness occurs
*/
protected void generateMetadata() throws BuildException {
- if (metadataGenerator == null) {
- log.debug("No Metadata generator specified.");
- return;
- }
final Path parentDir = installerProps.getTargetDir().resolve("metadata");
final File metadataFile = parentDir.resolve("idp-metadata.xml").toFile();
@@ -506,15 +506,9 @@ public class V5Install extends AbstractInitializableComponent {
InstallerSupport.setReadOnly(installerProps.getTargetDir().resolve("dist"), true);
InstallerSupport.setReadOnly(pluginContents, false);
InstallerSupport.setReadOnly(pluginWebapp, false);
- if (currentState.isSystemPresent()) {
- InstallerSupport.setReadOnly(installerProps.getTargetDir().resolve("system"), true);
- }
if (installerProps.isSetGroupAndMode()) {
InstallerSupport.setMode(installerProps.getTargetDir().resolve("bin"), "755", "**/*.sh");
- if (currentState.isSystemPresent()) {
- InstallerSupport.setMode(installerProps.getTargetDir().resolve("system"), "444", "**/*");
- }
InstallerSupport.setMode(installerProps.getTargetDir().resolve("dist"), "444", "**/*");
InstallerSupport.setMode(pluginContents, "640", "**/*");
InstallerSupport.setMode(pluginWebapp, "640", "**/*");
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
deleted file mode 100644
index 5f801747f..000000000
--- a/idp-installer/src/main/resources/net/shibboleth/idp/installer/ant.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?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/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java
index 97d625e3c..43b40c59b 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,54 +17,28 @@
package net.shibboleth.idp.installer;
-import java.io.IOException;
+import org.testng.annotations.Test;
-import net.shibboleth.idp.installer.impl.BuildWar;
-import net.shibboleth.idp.installer.impl.CopyDistribution;
-import net.shibboleth.idp.installer.impl.CurrentInstallState;
+import net.shibboleth.idp.installer.impl.IdPInstallerCLI;
import net.shibboleth.idp.installer.impl.InstallerProperties;
-import net.shibboleth.idp.installer.impl.V5Install;
-import net.shibboleth.idp.installer.metadata.impl.MetadataGenerator;
-import net.shibboleth.shared.component.ComponentInitializationException;
/**
*
*/
-public class Test {
+public class TestInstallerCLI {
- /**
- * @param args ...
- *
- * @throws IOException ...
- * @throws ComponentInitializationException ...
- */
- public static void main(String[] args) throws IOException, ComponentInitializationException {
+ @Test(enabled = false)
+ public void install() {
- //System.setProperty(InstallerPropertiesImpl.TARGET_DIR,"H:\\Downloads\\idp");
- System.setProperty(InstallerProperties.SOURCE_DIR,
- "h:\\Perforce\\Juno\\V5\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-5.0.0-SNAPSHOT");
- System.setProperty(InstallerProperties.ANT_BASE_DIR,
- "h:\\Perforce\\Juno\\V5\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-5.0.0-SNAPSHOT\\bin");
System.setProperty(InstallerProperties.KEY_STORE_PASSWORD, "p1");
System.setProperty(InstallerProperties.SEALER_PASSWORD, "p1");
System.setProperty(InstallerProperties.HOST_NAME, "machine.org.uk");
-
- final InstallerProperties ip = new InstallerProperties(false);
- ip.initialize();
- final CurrentInstallState is = new CurrentInstallState(ip);
- is.initialize();
-
- final CopyDistribution dist = new CopyDistribution(ip, is);
- dist.initialize();
- dist.execute();
-
- final V5Install inst = new V5Install(ip, is);
- inst.setMetadataGenerator(new MetadataGenerator());
- inst.initialize();
- inst.execute();
-
- final BuildWar bw = new BuildWar(ip.getTargetDir());
- bw.initialize();
- bw.execute();
+
+ IdPInstallerCLI.runMain(new String[] {
+ "-s",
+ "h:\\Perforce\\Juno\\V5\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-5.0.0-SNAPSHOT",
+ "--home", "classpath:/net/shibboleth/idp/module",
+ "-t",
+ "h:\\downloads\\idp",
+ });
}
-
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list