Class IdentityUtils


  • public final class IdentityUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private IdentityUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method 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.util.NavigableMap<java.lang.String,​java.security.KeyPair> loadIdentities​(SessionContext session, java.util.Map<java.lang.String,​? extends java.nio.file.Path> paths, FilePasswordProvider provider, java.nio.file.OpenOption... options)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IdentityUtils

        private IdentityUtils()
    • Method Detail

      • getIdentityFileName

        public static java.lang.String getIdentityFileName​(java.lang.String prefix,
                                                           java.lang.String type,
                                                           java.lang.String suffix)
        Parameters:
        prefix - The file name prefix - ignored if null/empty
        type - The identity type - ignored if null/empty
        suffix - The file name suffix - ignored if null/empty
        Returns:
        The identity file name or null if no name
      • createKeyPairProvider

        public static KeyPairProvider createKeyPairProvider​(java.util.Map<java.lang.String,​java.security.KeyPair> ids,
                                                            boolean supportedOnly)
        Parameters:
        ids - A Map of the loaded identities where key=the identity type, value=the matching KeyPair - ignored if null/empty
        supportedOnly - If true then ignore identities that are not supported internally
        Returns:
        A KeyPair for the identities - null if no identities available (e.g., after filtering unsupported ones)
        See Also:
        BuiltinIdentities
      • loadIdentities

        public static java.util.NavigableMap<java.lang.String,​java.security.KeyPair> loadIdentities​(SessionContext session,
                                                                                                          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
        Parameters:
        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).
        paths - A Map of the identities where key=identity type (case insensitive), value=the Path of file with the identity key
        provider - 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 loaded
        options - The OpenOptions to use when reading the key data
        Returns:
        A NavigableMap of the identities where key=identity type (case insensitive), value=the KeyPair of the identity
        Throws:
        java.io.IOException - If failed to access the file system
        java.security.GeneralSecurityException - If failed to load the keys