Package net.shibboleth.idp.installer
Class InstallerSupport
java.lang.Object
net.shibboleth.idp.installer.InstallerSupport
General common names and helper functions for the IdP and Plugin Installers.
This is not intended for general use.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPredicate to ask the user if they want to install the trust store provided.private static final classA @{linkFileVisitorwhich detects (and logs) whether a copy would overwrite. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.tools.ant.ProjectA psuedo ant-project as parent.private static org.slf4j.LoggerLog.static final StringThe name of the file and the property with the previous installation value.static final StringThe name of the file and the property with the current V4 installation value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PathcanonicalPath(Path from) Return the canonical path.static voidcopyDirIfNotPresent(Path from, Path to) Populate a with all the missing files.static voidcopyWithLogging(Path from, Path to, List<Path> pathsCopied) Copy a directory tree and keep a log of what has changed.static voidcreateDirectory(Path dir) Method to create a directory and log same.static org.apache.tools.ant.taskdefs.JarcreateJarTask(Path baseDir, Path destFile) Return aJartask.static voiddeleteTree(Path where) Delete the tree.static voiddeleteTree(Path where, String excludes) Delete the tree.static booleandetectDuplicates(Path from, Path to) Traverse "from" looking to see if any of the files are already in "to".static voiddownload(HTTPResource baseResource, HttpClientSecurityContextHandler handler, Path downloadDirectory, String fileName) Download helper method.static org.apache.tools.ant.taskdefs.CopygetCopyTask(Path from, Path to) Copy files.static org.apache.tools.ant.taskdefs.CopygetCopyTask(Path from, Path to, String excludes) Copy files.static voidRename Files into the provided tree.static voidOn Non Windows sets the files (only) group.static voidOn Non Windows sets the file mode.static voidsetReadOnly(Path path, boolean readOnly) On Windows sets the readOnly attribute on a file or recursively on a directory.static voidsetReadOnlyDir(Path directory, boolean readOnly) On Windows sets the readOnly attribute recursively on a directory.private static voidsetReadOnlyFile(Path file, boolean readOnly) On Windows sets the readOnly attribute on a file.
-
Field Details
-
VERSION_NAME
The name of the file and the property with the current V4 installation value.- See Also:
-
PREVIOUS_VERSION_NAME
The name of the file and the property with the previous installation value.- See Also:
-
ANT_PROJECT
@Nonnull private static final org.apache.tools.ant.Project ANT_PROJECTA psuedo ant-project as parent. -
log
@Nonnull private static org.slf4j.Logger logLog.
-
-
Constructor Details
-
InstallerSupport
private InstallerSupport()Private Constructor.
-
-
Method Details
-
createDirectory
Method to create a directory and log same.- Parameters:
dir- what to create- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
getCopyTask
@Nonnull public static org.apache.tools.ant.taskdefs.Copy getCopyTask(@Nonnull Path from, @Nonnull Path to) Copy files. We use ant rather thanFiles.copy(Path, Path, java.nio.file.CopyOption...)because the latter has issues with the Windows ReadOnly Attribute, and the former is tried and tested technology.- Parameters:
from- where to copy fromto- where to copy to- Returns:
- a partially populated
Copytask
-
getCopyTask
@Nonnull public static org.apache.tools.ant.taskdefs.Copy getCopyTask(@Nonnull Path from, @Nonnull Path to, @Nonnull String excludes) Copy files. We use ant rather thanFiles.copy(Path, Path, java.nio.file.CopyOption...)because the latter has issues with the Windows ReadOnly Attribute, and the former is tried and tested technology.- Parameters:
from- where to copy fromto- where to copy toexcludes- pattern to exclude- Returns:
- a partially populated
Copytask
-
copyDirIfNotPresent
public static void copyDirIfNotPresent(@Nonnull Path from, @Nonnull Path to) throws org.apache.tools.ant.BuildException Populate a with all the missing files.- Parameters:
from- where to go fromto- where to go to- Throws:
org.apache.tools.ant.BuildException- if badness occurrs Based on (for instance the following ant<!-- flows: copy from dist if not already present --> <mkdir dir="${idp.target.dir}/flows" /> <copy todir="${idp.target.dir}/flows"> <fileset dir="${idp.target.dir}/dist/flows" includes="**\/*"> <present present="srconly" targetdir="${idp.target.dir}/flows" /> </fileset > </copy>
-
setReadOnlyFile
private static void setReadOnlyFile(@Nonnull Path file, boolean readOnly) throws org.apache.tools.ant.BuildException On Windows sets the readOnly attribute on a file.- Parameters:
file- wherereadOnly- what to set it as- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
setReadOnlyDir
public static void setReadOnlyDir(@Nonnull Path directory, boolean readOnly) throws org.apache.tools.ant.BuildException On Windows sets the readOnly attribute recursively on a directory.- Parameters:
directory- wherereadOnly- what to set it as- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
setReadOnly
public static void setReadOnly(@Nonnull Path path, boolean readOnly) throws org.apache.tools.ant.BuildException On Windows sets the readOnly attribute on a file or recursively on a directory.- Parameters:
path- wherereadOnly- what to set it as- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
setMode
public static void setMode(@Nonnull Path directory, @Nonnull String permissions, @Nonnull String includes) throws org.apache.tools.ant.BuildException On Non Windows sets the file mode.- Parameters:
directory- wherepermissions- what to setincludes- what to include- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
setGroup
public static void setGroup(@Nonnull Path directory, @Nonnull String group, @Nonnull String includes) throws org.apache.tools.ant.BuildException On Non Windows sets the files (only) group.- Parameters:
directory- wheregroup- what to setincludes- what to include- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
deleteTree
Delete the tree.- Parameters:
where- where- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
deleteTree
public static void deleteTree(@Nullable Path where, @Nullable String excludes) throws org.apache.tools.ant.BuildException Delete the tree.- Parameters:
where- whereexcludes- wildcards to exclude- Throws:
org.apache.tools.ant.BuildException- if badness occurs
-
createJarTask
Return aJartask.- Parameters:
baseDir- where fromdestFile- where to- Returns:
- the jar task
-
canonicalPath
Return the canonical path.- Parameters:
from- the path we get given- Returns:
- the canonicalized one
- Throws:
IOException- as fromFile.getCanonicalFile()
-
renameToTree
public static void renameToTree(@Nonnull Path fromBase, @Nonnull Path toBase, @Nonnull List<Path> fromFiles, @Nonnull @Live List<Pair<Path, Path>> renames) throws IOExceptionRename Files into the provided tree.- Parameters:
fromBase- The root directory of the from filestoBase- The root directory to rename tofromFiles- The list of files (inside fromBase) to renamerenames- All the work as it is done- Throws:
IOException- If any of the file operations fail
-
detectDuplicates
public static boolean detectDuplicates(@Nonnull Path from, @Nullable Path to) throws org.apache.tools.ant.BuildException Traverse "from" looking to see if any of the files are already in "to".- Parameters:
from- source directoryto- target directory- Returns:
- true if there was a match
- Throws:
org.apache.tools.ant.BuildException- if anything threw andIOException
-
copyWithLogging
public static void copyWithLogging(@Nullable Path from, @Nonnull Path to, @Nonnull @Live List<Path> pathsCopied) throws org.apache.tools.ant.BuildException Copy a directory tree and keep a log of what has changed.- Parameters:
from- source directoryto- target directorypathsCopied- the list of files copied up (including if there was a failure)- Throws:
org.apache.tools.ant.BuildException- from the copy
-