Interface KeyPairProvider

    • Field Detail

      • SSH_RSA

        static final java.lang.String SSH_RSA
        SSH identifier for RSA keys
        See Also:
        Constant Field Values
      • SSH_DSS

        static final java.lang.String SSH_DSS
        SSH identifier for DSA keys
        See Also:
        Constant Field Values
      • SSH_ED25519

        static final java.lang.String SSH_ED25519
        SSH identifier for ED25519 elliptic curve keys
        See Also:
        Constant Field Values
      • ECDSA_SHA2_NISTP256

        static final java.lang.String ECDSA_SHA2_NISTP256
        SSH identifier for EC keys in NIST curve P-256
      • ECDSA_SHA2_NISTP384

        static final java.lang.String ECDSA_SHA2_NISTP384
        SSH identifier for EC keys in NIST curve P-384
      • ECDSA_SHA2_NISTP521

        static final java.lang.String ECDSA_SHA2_NISTP521
        SSH identifier for EC keys in NIST curve P-521
    • Method Detail

      • loadKey

        default java.security.KeyPair loadKey​(SessionContext session,
                                              java.lang.String type)
                                       throws java.io.IOException,
                                              java.security.GeneralSecurityException
        Load a key of the specified type which can be "ssh-rsa", "ssh-dss", or "ecdsa-sha2-nistp{256,384,521}". If there is no key of this type, return null
        Parameters:
        session - The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool).
        type - the type of key to load
        Returns:
        a valid key pair or null if this type of key is not available
        Throws:
        java.io.IOException - If failed to read/parse the keys data
        java.security.GeneralSecurityException - If failed to generate the keys
      • getKeyTypes

        default java.lang.Iterable<java.lang.String> getKeyTypes​(SessionContext session)
                                                          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).
        Returns:
        The available Iterable key types in preferred order - never null
        Throws:
        java.io.IOException - If failed to read/parse the keys data
        java.security.GeneralSecurityException - If failed to generate the keys
      • wrap

        static KeyPairProvider wrap​(java.lang.Iterable<java.security.KeyPair> pairs)
        Wrap the provided KeyPairs into a KeyPairProvider
        Parameters:
        pairs - The available pairs Iterable - ignored if null (i.e., returns EMPTY_KEYPAIR_PROVIDER)
        Returns:
        The provider wrapper