public final class ClientIdentity extends Object
id_rsa
SecurityUtils.getKeyPairResourceParser()
Modifier and Type | Field and Description |
---|---|
static String |
ID_FILE_PREFIX |
static String |
ID_FILE_SUFFIX |
static Function<String,String> |
ID_GENERATOR |
Modifier and Type | Method and Description |
---|---|
static String |
getIdentityFileName(NamedResource r) |
static String |
getIdentityFileName(String type) |
static String |
getIdentityType(String name) |
static Map<String,KeyPair> |
loadDefaultIdentities(boolean strict,
FilePasswordProvider provider,
LinkOption... options) |
static Map<String,KeyPair> |
loadDefaultIdentities(Path dir,
boolean strict,
FilePasswordProvider provider,
LinkOption... options) |
static KeyPairProvider |
loadDefaultKeyPairProvider(boolean strict,
boolean supportedOnly,
FilePasswordProvider provider,
LinkOption... options) |
static KeyPairProvider |
loadDefaultKeyPairProvider(Path dir,
boolean strict,
boolean supportedOnly,
FilePasswordProvider provider,
LinkOption... options) |
static Map<String,KeyPair> |
loadIdentities(SessionContext session,
Path dir,
boolean strict,
Collection<String> types,
Function<? super String,String> idGenerator,
FilePasswordProvider provider,
LinkOption... options)
Scans a folder and loads all available identity files
|
static Map<String,Path> |
scanIdentitiesFolder(Path dir,
boolean strict,
Collection<String> types,
Function<? super String,String> idGenerator,
LinkOption... options)
Scans a folder for possible identity files
|
public static final String ID_FILE_PREFIX
public static final String ID_FILE_SUFFIX
public static String getIdentityType(String name)
name
- The file name - ignored if null
/emptynull
if cannot determine it - e.g.,
does not start with the ID_FILE_PREFIX
public static String getIdentityFileName(NamedResource r)
public static String getIdentityFileName(String type)
type
- The identity type - e.g., rsa
- ignored
if null
/emptynull
if no nameID_FILE_PREFIX
,
ID_FILE_SUFFIX
,
IdentityUtils.getIdentityFileName(String, String, String)
public static KeyPairProvider loadDefaultKeyPairProvider(boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException
strict
- If true
then files that do not have the required
access rights are excluded from considerationsupportedOnly
- If true
then ignore identities that are not
supported internallyprovider
- A FilePasswordProvider
- may be null
if the loaded keys are guaranteed not to be encrypted. The argument
to FilePasswordProvider#getPassword
is the path of the
file whose key is to be loadedoptions
- The LinkOption
s to apply when checking
for existenceKeyPair
for the identities - null
if no identities
available (e.g., after filtering unsupported ones or strict permissions)IOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keysPublicKeyEntry.getDefaultKeysFolderPath()
,
loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
public static KeyPairProvider loadDefaultKeyPairProvider(Path dir, boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException
dir
- The folder to scan for the built-in identitiesstrict
- If true
then files that do not have the required
access rights are excluded from considerationsupportedOnly
- If true
then ignore identities that are not
supported internallyprovider
- A FilePasswordProvider
- may be null
if the loaded keys are guaranteed not to be encrypted. The argument
to FilePasswordProvider#getPassword
is the path of the
file whose key is to be loadedoptions
- The LinkOption
s to apply when checking
for existenceKeyPair
for the identities - null
if no identities
available (e.g., after filtering unsupported ones or strict permissions)IOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keysloadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
,
IdentityUtils.createKeyPairProvider(Map, boolean)
public static Map<String,KeyPair> loadDefaultIdentities(boolean strict, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException
strict
- If true
then files that do not have the required
access rights are excluded from considerationprovider
- A FilePasswordProvider
- may be null
if the loaded keys are guaranteed not to be encrypted. The argument
to FilePasswordProvider#getPassword
is the path of the
file whose key is to be loadedoptions
- The LinkOption
s to apply when checking
for existenceMap
of the found files where key=identity type (case
insensitive), value=the KeyPair
of the identityIOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keysPublicKeyEntry.getDefaultKeysFolderPath()
,
loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
public static Map<String,KeyPair> loadDefaultIdentities(Path dir, boolean strict, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException
dir
- The folder to scan for the built-in identitiesstrict
- If true
then files that do not have the required
access rights are excluded from considerationprovider
- A FilePasswordProvider
- may be null
if the loaded keys are guaranteed not to be encrypted. The argument
to FilePasswordProvider#getPassword
is the path of the
file whose key is to be loadedoptions
- The LinkOption
s to apply when checking
for existenceMap
of the found files where key=identity type (case
insensitive), value=the KeyPair
of the identityIOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keysBuiltinIdentities
public static Map<String,KeyPair> loadIdentities(SessionContext session, Path dir, boolean strict, Collection<String> types, Function<? super String,String> idGenerator, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException
session
- The SessionContext
for invoking this load command - may
be null
if not invoked within a session context (e.g., offline tool or session unknown).dir
- The Path
of the folder to scan - ignored if not existsstrict
- If true
then files that do not have the required
access rights are excluded from considerationtypes
- The identity types - ignored if null
/emptyidGenerator
- A Function
to derive the file name
holding the specified typeprovider
- A FilePasswordProvider
- may be null
if the loaded keys are guaranteed not to be encrypted. The argument
to FilePasswordProvider#getPassword
is the path of the
file whose key is to be loadedoptions
- The LinkOption
s to apply when checking
for existenceMap
of the found files where key=identity type (case
insensitive), value=the KeyPair
of the identityIOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keyspublic static Map<String,Path> scanIdentitiesFolder(Path dir, boolean strict, Collection<String> types, Function<? super String,String> idGenerator, LinkOption... options) throws IOException
dir
- The Path
of the folder to scan - ignored if not existsstrict
- If true
then files that do not have the required
access rights are excluded from considerationtypes
- The identity types - ignored if null
/emptyidGenerator
- A Function
to derive the file name
holding the specified typeoptions
- The LinkOption
s to apply when checking
for existenceMap
of the found files where key=identity type (case
insensitive), value=the Path
of the file holding the keyIOException
- If failed to access the file systemKeyUtils.validateStrictKeyFilePermissions(Path, LinkOption...)
Copyright © 2008–2022 The Apache Software Foundation. All rights reserved.