Package net.shibboleth.idp.installer
Class InstallerPropertiesImpl
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.idp.installer.InstallerPropertiesImpl
-
- All Implemented Interfaces:
InstallerProperties,Component,DestructableComponent,InitializableComponent
public class InstallerPropertiesImpl extends AbstractInitializableComponent implements InstallerProperties
Class implementInstallerPropertieswith properties/UI driven values. NOTE Updated to this properties should be reflected in the "PropertyDriverInstallation" wiki page."/
-
-
Field Summary
Fields Modifier and Type Field Description static StringANT_BASE_DIRThe base directory, inherited and shared with ant.private PathbaseDirThe base directory.static StringCONF_PRE_OVERLAYThe name of a directory to overlay "under" the distribution conf.private StringcredentialsKeyFileModecredentials key file mode.static intDEFAULT_KEY_SIZEWhether to tidy up after ourselves.static StringENTITY_IDThe entity ID.private StringentityIDThe entity ID.static StringGROUP_CONF_CREDENTIALSGroup to set on files in the credential and conf directories.static StringHOST_NAMEWhat is the installer host name?private StringhostnameHostname.static StringIDP_PROPERTIES_MERGEThe name of a property file to merge with idp.properties.private Map<String,String>inheritedPropertiesLocal overload of properties (to deal with nested calling).static StringINITIAL_EDIT_WEBAPPThe name of a directory to use to populate the initial webapp.static StringINITIAL_INSTALL_MODULESWhich modules to enable on initial install.private org.apache.tools.ant.input.InputHandlerinputHandlerInput handler from the prompting.private PropertiesinstallerPropertiesThe properties driving the install.static StringKEY_SIZEThe the key size to generate.static StringKEY_STORE_PASSWORDThe keystore password to use.private intkeySizeKey Size.private StringkeyStorePasswordKeystore Password.static StringLDAP_PASSWORDThe LDAP Password (usually associated with a username in ldap.properties).static StringLDAP_PROPERTIES_MERGEThe name of a property file to merge with ldap.properties.private org.slf4j.LoggerlogClass logger.static StringMODE_CREDENTIAL_KEYSMode to set on credential *key files.private booleanneedSourceDirIs a source Dir needed?static StringNO_PROMPTDo we cause a failure rather than a prompt.static StringNO_TIDYWhether to tidy up after ourselves.private booleannoPromptDo we allow prompting?static StringPERFORM_SET_MODEDo we do any chgrp/chmod work?static StringPROPERTY_SOURCE_FILEThe name of a property file to fill in some or all of the above.private Stringscopescope.static StringSCOPEThe scope to assert.static StringSEALER_ALIASThe sealer alias to use.static StringSEALER_PASSWORDThe sealer password to use.private StringsealerAliasSealer Alias.private StringsealerPasswordSealer Password.private booleansetGroupAndModewhether to tidy up.static StringSOURCE_DIRWhere to install from (installs only).private PathsrcDirThe sourceDirectory.static StringTARGET_DIRWhere to install to.private PathtargetDirThe target Directory.private booleantidywhether to tidy up.-
Fields inherited from interface net.shibboleth.idp.installer.InstallerProperties
DEFAULT_MODULES
-
-
Constructor Summary
Constructors Constructor Description InstallerPropertiesImpl(boolean copiedDistribution)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StringbestHostName()Find the most apposite network connector.protected StringdefaultScope()Evaluate the default scope value.protected voiddoInitialize()PathgetConfPreOverlay()Get a directory to use to "pre-overlay" the conf directory.StringgetCredentialsGroup()Group to set on all files in credentials and conf.StringgetCredentialsKeyFileMode()Mode to set on all files in credentials.StringgetEntityID()Get the EntityId for this install.StringgetHostName()Get the host name for this install.PathgetIdPMergeProperties()Get the a file to merge with idp.properties or null.PathgetInitialEditWeb()Get a path to use to do the initial edit-webapp populate.protected org.apache.tools.ant.input.InputHandlergetInputHandler()Get anInputHandlerfor the prompting.intgetKeySize()Get the key size for signing, encryption and backchannel.StringgetKeyStorePassword()Get the password for the keystore for this installation.PathgetLDAPMergeProperties()Get the a file to merge with ldap.properties or null.StringgetLDAPPassword()Get the LDAP password iff one was provided.protected PathgetMergeDir(String propName)Get the directory specified as the property as a File, or null if it doesn't exist.protected PathgetMergeFile(String propName)Get the file specified as the property as a File, or null if it doesn't exist.private PathgetMergePath(String propName, Boolean mustBeDir)Get thePathspecified as the property as a File, or null if it doesn't exist.Set<String>getModulesToEnable()Get the modules to enable after first install.protected StringgetPassword(String propertyName, String prompt)Lookup a property.StringgetScope()Get the scope for this installation.StringgetSealerAlias()Get the alias for the sealer key.StringgetSealerPassword()Get the password for the sealer for this installation.PathgetSourceDir()Where is the install coming from?StringgetSubjectAltName()Get the SubjectAltName for the certificates.PathgetTargetDir()Get where we are installing/updating/building the war.protected StringgetValue(String propertyName, String prompt, Supplier<String> defaultSupplier)Lookup a property.private booleanhasHostName(InetAddress addr)Is this address named? Helper method forbestHostName()booleanisNoTidy()Does the user want us to *not* tidy up.booleanisSetGroupAndMode()Do we set the mode?voidsetInheritedProperties(Map<String,String> props)Set any properties inherited from the base environment.-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
ANT_BASE_DIR
public static final String ANT_BASE_DIR
The base directory, inherited and shared with ant.- See Also:
- Constant Field Values
-
PROPERTY_SOURCE_FILE
public static final String PROPERTY_SOURCE_FILE
The name of a property file to fill in some or all of the above. This file is deleted after processing.- See Also:
- Constant Field Values
-
IDP_PROPERTIES_MERGE
public static final String IDP_PROPERTIES_MERGE
The name of a property file to merge with idp.properties.- See Also:
- Constant Field Values
-
LDAP_PROPERTIES_MERGE
public static final String LDAP_PROPERTIES_MERGE
The name of a property file to merge with ldap.properties.- See Also:
- Constant Field Values
-
LDAP_PASSWORD
public static final String LDAP_PASSWORD
The LDAP Password (usually associated with a username in ldap.properties).- See Also:
- Constant Field Values
-
CONF_PRE_OVERLAY
public static final String CONF_PRE_OVERLAY
The name of a directory to overlay "under" the distribution conf.- See Also:
- Constant Field Values
-
INITIAL_EDIT_WEBAPP
public static final String INITIAL_EDIT_WEBAPP
The name of a directory to use to populate the initial webapp.- See Also:
- Constant Field Values
-
TARGET_DIR
public static final String TARGET_DIR
Where to install to. Default is basedir- See Also:
- Constant Field Values
-
SOURCE_DIR
public static final String SOURCE_DIR
Where to install from (installs only).- See Also:
- Constant Field Values
-
ENTITY_ID
public static final String ENTITY_ID
The entity ID.- See Also:
- Constant Field Values
-
NO_PROMPT
public static final String NO_PROMPT
Do we cause a failure rather than a prompt.- See Also:
- Constant Field Values
-
HOST_NAME
public static final String HOST_NAME
What is the installer host name?- See Also:
- Constant Field Values
-
SCOPE
public static final String SCOPE
The scope to assert.- See Also:
- Constant Field Values
-
KEY_STORE_PASSWORD
public static final String KEY_STORE_PASSWORD
The keystore password to use.- See Also:
- Constant Field Values
-
SEALER_PASSWORD
public static final String SEALER_PASSWORD
The sealer password to use.- See Also:
- Constant Field Values
-
SEALER_ALIAS
public static final String SEALER_ALIAS
The sealer alias to use.- See Also:
- Constant Field Values
-
KEY_SIZE
public static final String KEY_SIZE
The the key size to generate.- See Also:
- Constant Field Values
-
MODE_CREDENTIAL_KEYS
public static final String MODE_CREDENTIAL_KEYS
Mode to set on credential *key files.- See Also:
- Constant Field Values
-
GROUP_CONF_CREDENTIALS
public static final String GROUP_CONF_CREDENTIALS
Group to set on files in the credential and conf directories.- See Also:
- Constant Field Values
-
PERFORM_SET_MODE
public static final String PERFORM_SET_MODE
Do we do any chgrp/chmod work?- See Also:
- Constant Field Values
-
NO_TIDY
public static final String NO_TIDY
Whether to tidy up after ourselves.- See Also:
- Constant Field Values
-
INITIAL_INSTALL_MODULES
public static final String INITIAL_INSTALL_MODULES
Which modules to enable on initial install.- Since:
- 4.1.0
- See Also:
- Constant Field Values
-
DEFAULT_KEY_SIZE
public static final int DEFAULT_KEY_SIZE
Whether to tidy up after ourselves.- See Also:
- Constant Field Values
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
baseDir
@NonnullAfterInit private Path baseDir
The base directory.
-
installerProperties
@NonnullAfterInit private Properties installerProperties
The properties driving the install.
-
targetDir
private Path targetDir
The target Directory.
-
srcDir
private Path srcDir
The sourceDirectory.
-
noPrompt
private boolean noPrompt
Do we allow prompting?
-
needSourceDir
private final boolean needSourceDir
Is a source Dir needed?
-
entityID
private String entityID
The entity ID.
-
hostname
private String hostname
Hostname.
-
scope
private String scope
scope.
-
keyStorePassword
private String keyStorePassword
Keystore Password.
-
sealerPassword
private String sealerPassword
Sealer Password.
-
sealerAlias
private String sealerAlias
Sealer Alias.
-
keySize
private int keySize
Key Size. (for signing, encryption and backchannel).
-
tidy
private boolean tidy
whether to tidy up.
-
setGroupAndMode
private boolean setGroupAndMode
whether to tidy up.
-
credentialsKeyFileMode
private String credentialsKeyFileMode
credentials key file mode.
-
inheritedProperties
private Map<String,String> inheritedProperties
Local overload of properties (to deal with nested calling).
-
inputHandler
private final org.apache.tools.ant.input.InputHandler inputHandler
Input handler from the prompting.
-
-
Method Detail
-
getInputHandler
protected org.apache.tools.ant.input.InputHandler getInputHandler()
Get anInputHandlerfor the prompting.- Returns:
- an input handler
-
setInheritedProperties
public void setInheritedProperties(Map<String,String> props)
Set any properties inherited from the base environment.- Parameters:
props- what to set
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
getValue
protected String getValue(String propertyName, String prompt, Supplier<String> defaultSupplier) throws org.apache.tools.ant.BuildException
Lookup a property. If it isn't defined then ask the user (if we are allowed). This is used by most (but all) getters that redirect through a property- Parameters:
propertyName- the property to lookup.prompt- what to say to the userdefaultSupplier- how to get the default value. Using a Supplier allows this to be a reasonably heavyweight operation.- Returns:
- the value
- Throws:
org.apache.tools.ant.BuildException- of anything goes wrong
-
getPassword
protected String getPassword(String propertyName, String prompt) throws org.apache.tools.ant.BuildException
Lookup a property. If it isn't defined then ask the user (if we are allowed) via a no-echo interface. Note that this does not work within a debugger.- Parameters:
propertyName- the property to lookup.prompt- what to say to the user- Returns:
- the value. this is not repeated to the screen
- Throws:
org.apache.tools.ant.BuildException- of anything goes wrong
-
getTargetDir
@Nonnull public Path getTargetDir() throws org.apache.tools.ant.BuildException
Get where we are installing/updating/building the war. This is slightly complicated because the default depends on what we are doing.- Specified by:
getTargetDirin interfaceInstallerProperties- Returns:
- the target directory
- Throws:
org.apache.tools.ant.BuildException- if something goes awry.
-
getSourceDir
@Nullable public Path getSourceDir()
Where is the install coming from?- Specified by:
getSourceDirin interfaceInstallerProperties- Returns:
- the source directory
-
getEntityID
@Nonnull public String getEntityID()
Get the EntityId for this install. Defaults to information pulled from {getHostName().- Specified by:
getEntityIDin interfaceInstallerProperties- Returns:
- the name.
-
isNoTidy
public boolean isNoTidy()
Does the user want us to *not* tidy up.- Specified by:
isNoTidyin interfaceInstallerProperties- Returns:
- do we not tidy up?
-
hasHostName
private boolean hasHostName(InetAddress addr)
Is this address named? Helper method forbestHostName()- Parameters:
addr- what to look at- Returns:
- true unless the name is the canonical name...
-
bestHostName
private String bestHostName()
Find the most apposite network connector. Taken from Ant.- Returns:
- the best name we can work out
-
getHostName
@Nonnull public String getHostName()
Get the host name for this install. Defaults to information pulled from the network.- Specified by:
getHostNamein interfaceInstallerProperties- Returns:
- the host name.
-
getCredentialsKeyFileMode
@Nonnull public String getCredentialsKeyFileMode()
Mode to set on all files in credentials.- Specified by:
getCredentialsKeyFileModein interfaceInstallerProperties- Returns:
- the mode
-
getCredentialsGroup
@Nullable public String getCredentialsGroup()
Group to set on all files in credentials and conf.- Specified by:
getCredentialsGroupin interfaceInstallerProperties- Returns:
- the mode or null if none to be set
-
isSetGroupAndMode
public boolean isSetGroupAndMode()
Do we set the mode?- Specified by:
isSetGroupAndModein interfaceInstallerProperties- Returns:
- do we the mode
-
defaultScope
@Nonnull protected String defaultScope()
Evaluate the default scope value.- Returns:
- everything after the first '.' in
getHostName()
-
getScope
@Nonnull public String getScope()
Get the scope for this installation..- Specified by:
getScopein interfaceInstallerProperties- Returns:
- The scope.
-
getLDAPPassword
@Nullable public String getLDAPPassword() throws org.apache.tools.ant.BuildException
Get the LDAP password iff one was provided. DO NOT PROMPT.- Specified by:
getLDAPPasswordin interfaceInstallerProperties- Returns:
- the password if provided by a properties
- Throws:
org.apache.tools.ant.BuildException- if badness happens
-
getSubjectAltName
@Nonnull public String getSubjectAltName()
Get the SubjectAltName for the certificates..- Specified by:
getSubjectAltNamein interfaceInstallerProperties- Returns:
- the SubjectAltName
-
getKeyStorePassword
@Nonnull public String getKeyStorePassword()
Get the password for the keystore for this installation..- Specified by:
getKeyStorePasswordin interfaceInstallerProperties- Returns:
- the password.
-
getSealerPassword
@Nonnull public String getSealerPassword()
Get the password for the sealer for this installation..- Specified by:
getSealerPasswordin interfaceInstallerProperties- Returns:
- the password.
-
getModulesToEnable
@Nonnull public Set<String> getModulesToEnable()
Get the modules to enable after first install.- Specified by:
getModulesToEnablein interfaceInstallerProperties- Returns:
- the modules
-
getSealerAlias
@Nonnull public String getSealerAlias()
Get the alias for the sealer key..- Specified by:
getSealerAliasin interfaceInstallerProperties- Returns:
- the alias
-
getKeySize
public int getKeySize()
Get the key size for signing, encryption and backchannel.. default is 3072.- Specified by:
getKeySizein interfaceInstallerProperties- Returns:
- the keysize
-
getMergeDir
protected Path getMergeDir(String propName) throws org.apache.tools.ant.BuildException
Get the directory specified as the property as a File, or null if it doesn't exist.- Parameters:
propName- the name to lookup;- Returns:
- null if the property is not provided a
Fileotherwise - Throws:
org.apache.tools.ant.BuildException- if the property is supplied but the file doesn't exist.
-
getMergeFile
protected Path getMergeFile(String propName) throws org.apache.tools.ant.BuildException
Get the file specified as the property as a File, or null if it doesn't exist.- Parameters:
propName- the name to lookup;- Returns:
- null if the property is not provided a
Fileotherwise - Throws:
org.apache.tools.ant.BuildException- if the property is supplied but the file doesn't exist.
-
getMergePath
private Path getMergePath(String propName, Boolean mustBeDir) throws org.apache.tools.ant.BuildException
Get thePathspecified as the property as a File, or null if it doesn't exist. Police for type if required- Parameters:
propName- the name to lookup;mustBeDir- if null do not policy. Otherwise policy according to value- Returns:
- null if the property is not provided a
Fileotherwise - Throws:
org.apache.tools.ant.BuildException- if the property is supplied but the file doesn't exist.
-
getIdPMergeProperties
public Path getIdPMergeProperties() throws org.apache.tools.ant.BuildException
Get the a file to merge with idp.properties or null..- Specified by:
getIdPMergePropertiesin interfaceInstallerProperties- Returns:
- the file or null if it none required.
- Throws:
org.apache.tools.ant.BuildException- if badness happens
-
getLDAPMergeProperties
public Path getLDAPMergeProperties() throws org.apache.tools.ant.BuildException
Get the a file to merge with ldap.properties or null..- Specified by:
getLDAPMergePropertiesin interfaceInstallerProperties- Returns:
- the path or null if it none required.
- Throws:
org.apache.tools.ant.BuildException- if badness happens
-
getConfPreOverlay
public Path getConfPreOverlay() throws org.apache.tools.ant.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, before the files are copied from the distribution..- Specified by:
getConfPreOverlayin interfaceInstallerProperties- Returns:
- the path or null if non specified.
- Throws:
org.apache.tools.ant.BuildException- if badness happens
-
getInitialEditWeb
public Path getInitialEditWeb() throws org.apache.tools.ant.BuildException
Get a path to use to do the initial edit-webapp populate..- Specified by:
getInitialEditWebin interfaceInstallerProperties- Returns:
- the path or null if non specified.
- Throws:
org.apache.tools.ant.BuildException- if badness happens
-
-