Interface Identity


  • public interface Identity
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      void clear()
      Disposes internally allocated data, like byte array for the private key.
      default boolean decrypt()
      Deprecated.
      The decryption should be done automatically in setPassphrase(byte[])
      java.lang.String getAlgName()
      Returns the name of the key algorithm.
      java.lang.String getName()
      Returns the name of this identity.
      byte[] getPublicKeyBlob()
      Returns the public-key blob.
      byte[] getSignature​(byte[] data)
      Signs on data with this identity, and returns the result.
      default byte[] getSignature​(byte[] data, java.lang.String alg)
      Signs on data with this identity, and returns the result.
      boolean isEncrypted()
      Returns true if this identity is cyphered.
      boolean setPassphrase​(byte[] passphrase)
      Decrypts this identity with the specified pass-phrase.
    • Method Detail

      • setPassphrase

        boolean setPassphrase​(byte[] passphrase)
                       throws JSchException
        Decrypts this identity with the specified pass-phrase.
        Parameters:
        passphrase - the pass-phrase for this identity.
        Returns:
        true if the decryption is succeeded or this identity is not cyphered.
        Throws:
        JSchException
      • getPublicKeyBlob

        byte[] getPublicKeyBlob()
        Returns the public-key blob.
        Returns:
        the public-key blob
      • getSignature

        byte[] getSignature​(byte[] data)
        Signs on data with this identity, and returns the result.

        IMPORTANT NOTE:
        The getSignature(byte[], String) method should be overridden to ensure ssh-rsa type public keys function with the rsa-sha2-256 or rsa-sha2-512 signature algorithms.

        Parameters:
        data - data to be signed
        Returns:
        the signature
        See Also:
        getSignature(byte[], String)
      • getSignature

        default byte[] getSignature​(byte[] data,
                                    java.lang.String alg)
        Signs on data with this identity, and returns the result.

        IMPORTANT NOTE:
        The default implementation of this method simply calls getSignature(byte[]), which will fail with ssh-rsa type public keys when utilized with the rsa-sha2-256 or rsa-sha2-512 signature algorithms:
        it exists only to maintain backwards compatibility of this interface.

        This default method should be overridden by implementations to ensure the rsa-sha2-256 and rsa-sha2-512 signature algorithms function correctly.

        Parameters:
        data - data to be signed
        alg - signature algorithm to use
        Returns:
        the signature
        Since:
        0.1.57
        See Also:
        getSignature(byte[])
      • decrypt

        @Deprecated
        default boolean decrypt()
        Deprecated.
        The decryption should be done automatically in setPassphrase(byte[])
        This method is deprecated and the default implmentation of this method will throw an UnsupportedOperationException.
        Returns:
        true if the decryption is succeeded or this identity is not cyphered.
        See Also:
        setPassphrase(byte[])
      • getAlgName

        java.lang.String getAlgName()
        Returns the name of the key algorithm.
        Returns:
        the name of the key algorithm
      • getName

        java.lang.String getName()
        Returns the name of this identity. It will be useful to identify this object in the IdentityRepository.
        Returns:
        the name of this identity
      • isEncrypted

        boolean isEncrypted()
        Returns true if this identity is cyphered.
        Returns:
        true if this identity is cyphered.
      • clear

        void clear()
        Disposes internally allocated data, like byte array for the private key.