Class UserAuthPublicKey

    • Constructor Detail

      • UserAuthPublicKey

        public UserAuthPublicKey()
    • Method Detail

      • init

        public void init​(ClientSession session,
                         java.lang.String service)
                  throws java.lang.Exception
        Specified by:
        init in interface UserAuth
        Overrides:
        init in class AbstractUserAuth
        Parameters:
        session - The ClientSession
        service - The requesting service name
        Throws:
        java.lang.Exception - If failed to initialize the mechanism
      • resolveAttemptedPublicKeyIdentity

        protected PublicKeyIdentity resolveAttemptedPublicKeyIdentity​(ClientSession session,
                                                                      java.lang.String service)
                                                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getDefaultSignatureAlgorithm

        protected java.lang.String getDefaultSignatureAlgorithm​(ClientSession session,
                                                                java.lang.String service,
                                                                PublicKeyIdentity identity,
                                                                java.security.KeyPair keyPair,
                                                                java.lang.String keyType)
                                                         throws java.lang.Exception
        Determines a signature algorithm name to use for the authentication request if none could be determined from the installed signature factories. If a non-null non-empty string is returned, it is used as is in the authentication.

        This is mainly intended for use with identities from an SSH agent, where the SSH agent may be able to sign the request even if there is no appropriate signature factory present in Java. Whether it makes sense to allow this depends on the application logic and how it handles e.g. SSH config PubkeyAcceptedKeyTypes (or PubkeyAcceptedAlgorithms}.

        This default implementation always returns null, skipping the key.

        Parameters:
        session - ClientSession trying to authenticate
        service - SSH service name
        identity - PublicKeyIdentity considered to be used for authentication
        keyPair - KeyPair from identity
        keyType - the key type of keyPair
        Returns:
        null or an empty string to skip this key and consider another key, if any, to use for authentication, or a non-empty signature algorithm name to use for the authentication attempt using the given identity
        Throws:
        java.lang.Exception - if an error occurs
        See Also:
        KeyAgentIdentity
      • appendSignature

        protected byte[] appendSignature​(ClientSession session,
                                         java.lang.String service,
                                         java.lang.String name,
                                         java.lang.String username,
                                         java.lang.String algo,
                                         java.security.PublicKey key,
                                         java.security.PublicKey serverKey,
                                         Buffer buffer)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • signalAuthMethodSuccess

        public void signalAuthMethodSuccess​(ClientSession session,
                                            java.lang.String service,
                                            Buffer buffer)
                                     throws java.lang.Exception
        Description copied from interface: UserAuth
        Signal reception of SSH_MSG_USERAUTH_SUCCESS message
        Specified by:
        signalAuthMethodSuccess in interface UserAuth
        Parameters:
        session - The ClientSession
        service - The requesting service name
        buffer - The Buffer containing the success message (after having consumed the relevant data from it)
        Throws:
        java.lang.Exception - If failed to handle the callback - Note: may cause session close
      • signalAuthMethodFailure

        public void signalAuthMethodFailure​(ClientSession session,
                                            java.lang.String service,
                                            boolean partial,
                                            java.util.List<java.lang.String> serverMethods,
                                            Buffer buffer)
                                     throws java.lang.Exception
        Description copied from interface: UserAuth
        Signals reception of SSH_MSG_USERAUTH_FAILURE message
        Specified by:
        signalAuthMethodFailure in interface UserAuth
        Parameters:
        session - The ClientSession
        service - The requesting service name
        partial - true if some partial authentication success so far
        serverMethods - The List of authentication methods that can continue
        buffer - The Buffer containing the failure message (after having consumed the relevant data from it)
        Throws:
        java.lang.Exception - If failed to handle the callback - Note: may cause session close
      • releaseKeys

        protected void releaseKeys()
                            throws java.io.IOException
        Throws:
        java.io.IOException