Package net.shibboleth.idp.installer

# Class InstallerSupport

java.lang.Object
net.shibboleth.idp.installer.InstallerSupport

public final class InstallerSupport extends Object
General common names and helper functions for the IdP and Plugin Installers. This is not intended for general use.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`InstallerSupport.InstallerQuery`
Predicate to ask the user if they want to install the trust store provided.
`private static final class`
`InstallerSupport.NameClashVisitor`
A @{link `FileVisitor` which detects (and logs) whether a copy would overwrite.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final org.apache.tools.ant.Project`
`ANT_PROJECT`
A psuedo ant-project as parent.
`private static org.slf4j.Logger`
`log`
Log.
`static final String`
`PREVIOUS_VERSION_NAME`
The name of the file and the property with the previous installation value.
`static final String`
`VERSION_NAME`
The name of the file and the property with the current V4 installation value.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`InstallerSupport()`
Private Constructor.

## Method Summary

Modifier and Type
Method
Description
`static Path`
`canonicalPath(Path from)`
Return the canonical path.
`static void`
`copyDirIfNotPresent(Path from, Path to)`
Populate a with all the missing files.
`static void`
`copyWithLogging(Path from, Path to, List<Path> pathsCopied)`
Copy a directory tree and keep a log of what has changed.
`static void`
`createDirectory(Path dir)`
Method to create a directory and log same.
`static org.apache.tools.ant.taskdefs.Jar`
`createJarTask(Path baseDir, Path destFile)`
Return a `Jar` task.
`static void`
`deleteTree(Path where)`
Delete the tree.
`static void`
`deleteTree(Path where, String excludes)`
Delete the tree.
`static boolean`
`detectDuplicates(Path from, Path to)`
Traverse "from" looking to see if any of the files are already in "to".
`static void`
`download(HTTPResource baseResource, HttpClientSecurityContextHandler handler, Path downloadDirectory, String fileName)`
Download helper method.
`static String`
`getBestHostName()`
Find the most apposite network connector, taken from Ant.
`static org.apache.tools.ant.taskdefs.Copy`
`getCopyTask(Path from, Path to)`
Copy files.
`static org.apache.tools.ant.taskdefs.Copy`
`getCopyTask(Path from, Path to, String excludes)`
Copy files.
`private static boolean`
`hasHostName(InetAddress addr)`
Is this address named?
`static final Path`
`pathOf(String pathString)`
A version of `Path.of(String, String...)` that throw a catchable exception.
`static void`
`renameToTree(Path fromBase, Path toBase, List<Path> fromFiles, List<Pair<Path,Path>> renames)`
Rename Files into the provided tree.
`static void`
`setGroup(Path directory, String group, String includes)`
On Non Windows sets the files (only) group.
`static void`
`setMode(Path directory, String permissions, String includes)`
On Non Windows sets the file mode.
`static void`
`setReadOnly(Path path, boolean readOnly)`
On Windows sets the readOnly attribute on a file or recursively on a directory.
`static void`
`setReadOnlyDir(Path directory, boolean readOnly)`
On Windows sets the readOnly attribute recursively on a directory.
`private static void`
`setReadOnlyFile(Path file, boolean readOnly)`
On Windows sets the readOnly attribute on a file.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### VERSION_NAME

@Nonnull @NotEmpty public static final String VERSION_NAME
The name of the file and the property with the current V4 installation value.

See Also:
  - Constant Field Values

### PREVIOUS_VERSION_NAME

@Nonnull @NotEmpty public static final String PREVIOUS_VERSION_NAME
The name of the file and the property with the previous installation value.

See Also:
  - Constant Field Values

### ANT_PROJECT

@Nonnull private static final org.apache.tools.ant.Project ANT_PROJECT
A psuedo ant-project as parent.

### log

@Nonnull private static org.slf4j.Logger log
Log.

## Constructor Details

### InstallerSupport

private InstallerSupport()
Private Constructor.

## Method Details

### createDirectory

public static void createDirectory(@Nonnull Path dir) throws org.apache.tools.ant.BuildException
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 than `Files.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 from
  `to` - where to copy to
Returns:
  a partially populated `Copy` task

### 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 than `Files.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 from
  `to` - where to copy to
  `excludes` - pattern to exclude
Returns:
  a partially populated `Copy` task

### 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 from
  `to` - 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` - where
  `readOnly` - 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` - where
  `readOnly` - 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` - where
  `readOnly` - 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` - where
  `permissions` - what to set
  `includes` - 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` - where
  `group` - what to set
  `includes` - what to include
Throws:
  `org.apache.tools.ant.BuildException` - if badness occurs

### deleteTree

public static void deleteTree(@Nullable Path where) throws org.apache.tools.ant.BuildException
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` - where
  `excludes` - wildcards to exclude
Throws:
  `org.apache.tools.ant.BuildException` - if badness occurs

### createJarTask

public static org.apache.tools.ant.taskdefs.Jar createJarTask(Path baseDir, Path destFile)
Return a `Jar` task.

Parameters:
  `baseDir` - where from
  `destFile` - where to
Returns:
  the jar task

### download

public static void download(@Nonnull HTTPResource baseResource, @Nonnull HttpClientSecurityContextHandler handler, @Nonnull Path downloadDirectory, @Nonnull String fileName) throws IOException
Download helper method.

Parameters:
  `baseResource` - where to go for the file
  `handler` - HttpClientSecurityContextHandler to use
  `downloadDirectory` - where to download to
  `fileName` - the file name
Throws:
  `IOException` - as required

### canonicalPath

@Nonnull public static Path canonicalPath(@Nonnull Path from) throws IOException
Return the canonical path.

Parameters:
  `from` - the path we get given
Returns:
  the canonicalized one
Throws:
  `IOException` - as from `File.getCanonicalFile()`

### renameToTree

public static void renameToTree(@Nonnull Path fromBase, @Nonnull Path toBase, @Nonnull List<Path> fromFiles, @Nonnull @Live List<Pair<Path,Path>> renames) throws IOException
Rename Files into the provided tree.

Parameters:
  `fromBase` - The root directory of the from files
  `toBase` - The root directory to rename to
  `fromFiles` - The list of files (inside fromBase) to rename
  `renames` - 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 directory
  `to` - target directory
Returns:
  true if there was a match
Throws:
  `org.apache.tools.ant.BuildException` - if anything threw and `IOException`

### 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 directory
  `to` - target directory
  `pathsCopied` - the list of files copied up (including if there was a failure)
Throws:
  `org.apache.tools.ant.BuildException` - from the copy

### pathOf

@Nonnull public static final Path pathOf(@Nonnull String pathString) throws org.apache.tools.ant.BuildException
A version of `Path.of(String, String...)` that throw a catchable exception.

Parameters:
  `pathString` - the path as a string
Returns:
  the Path
Throws:
  `org.apache.tools.ant.BuildException` - if `Path.of(String, String...)` threw an exception.

### hasHostName

private static boolean hasHostName(InetAddress addr)
Is this address named?

Helper method for `getBestHostName()`.

Parameters:
  `addr` - what to look at
Returns:
  true unless the name is the canonical name

### getBestHostName

@Nonnull public static String getBestHostName()
Find the most apposite network connector, taken from Ant.

Returns:
  the best name we can work out