public final class IdentityUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
IdentityUtils.LazyDefaultUserHomeFolderHolder |
Modifier | Constructor and Description |
---|---|
private |
IdentityUtils() |
Modifier and Type | Method and Description |
---|---|
static KeyPairProvider |
createKeyPairProvider(java.util.Map<java.lang.String,java.security.KeyPair> ids,
boolean supportedOnly) |
static java.lang.String |
getIdentityFileName(java.lang.String prefix,
java.lang.String type,
java.lang.String suffix) |
static java.nio.file.Path |
getUserHomeFolder() |
static java.util.Map<java.lang.String,java.security.KeyPair> |
loadIdentities(java.util.Map<java.lang.String,? extends java.nio.file.Path> paths,
FilePasswordProvider provider,
java.nio.file.OpenOption... options) |
public static java.nio.file.Path getUserHomeFolder()
Path
to the currently running user homepublic static java.lang.String getIdentityFileName(java.lang.String prefix, java.lang.String type, java.lang.String suffix)
prefix
- The file name prefix - ignored if null
/emptytype
- The identity type - ignored if null
/emptysuffix
- The file name suffix - ignored if null
/emptynull
if no namepublic static KeyPairProvider createKeyPairProvider(java.util.Map<java.lang.String,java.security.KeyPair> ids, boolean supportedOnly)
ids
- A Map
of the loaded identities where key=the identity type,
value=the matching KeyPair
- ignored if null
/emptysupportedOnly
- If true
then ignore identities that are not
supported internallyKeyPair
for the identities - null
if no identities
available (e.g., after filtering unsupported ones)BuiltinIdentities
public static java.util.Map<java.lang.String,java.security.KeyPair> loadIdentities(java.util.Map<java.lang.String,? extends java.nio.file.Path> paths, FilePasswordProvider provider, java.nio.file.OpenOption... options) throws java.io.IOException, java.security.GeneralSecurityException
paths
- A Map
of the identities where key=identity type (case
insensitive), value=the Path
of file with the identity keyprovider
- A FilePasswordProvider
- may be null
if the loaded keys are guaranteed not to be encrypted. The argument
to FilePasswordProvider.getPassword(String)
is the path of the
file whose key is to be loadedoptions
- The OpenOption
s to use when reading the key dataMap
of the identities where key=identity type (case
insensitive), value=the KeyPair
of the identityjava.io.IOException
- If failed to access the file systemjava.security.GeneralSecurityException
- If failed to load the keysSecurityUtils.loadKeyPairIdentity(String, InputStream, FilePasswordProvider)