Package com.jcraft.jsch
Interface Identity
public interface Identity
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Disposes internally allocated data, like byte array for the private key.default booleandecrypt()Deprecated.Returns the name of the key algorithm.getName()Returns the name of this identity.byte[]Returns the public-key blob.byte[]getSignature(byte[] data) Signs on data with this identity, and returns the result.default byte[]getSignature(byte[] data, String alg) Signs on data with this identity, and returns the result.booleanReturnstrueif this identity is cyphered.booleansetPassphrase(byte[] passphrase) Decrypts this identity with the specified pass-phrase.
-
Method Details
-
setPassphrase
Decrypts this identity with the specified pass-phrase.- Parameters:
passphrase- the pass-phrase for this identity.- Returns:
trueif 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:
ThegetSignature(byte[], String)method should be overridden to ensuressh-rsatype public keys function with thersa-sha2-256orrsa-sha2-512signature algorithms.- Parameters:
data- data to be signed- Returns:
- the signature
- See Also:
-
getSignature
Signs on data with this identity, and returns the result.IMPORTANT NOTE:
The default implementation of this method simply callsgetSignature(byte[]), which will fail withssh-rsatype public keys when utilized with thersa-sha2-256orrsa-sha2-512signature algorithms:
it exists only to maintain backwards compatibility of this interface.This default method should be overridden by implementations to ensure the
rsa-sha2-256andrsa-sha2-512signature algorithms function correctly.- Parameters:
data- data to be signedalg- signature algorithm to use- Returns:
- the signature
- Since:
- 0.1.57
- See Also:
-
decrypt
Deprecated.The decryption should be done automatically insetPassphrase(byte[])This method is deprecated and the default implmentation of this method will throw anUnsupportedOperationException.- Returns:
trueif the decryption is succeeded or this identity is not cyphered.- See Also:
-
getAlgName
String getAlgName()Returns the name of the key algorithm.- Returns:
- the name of the key algorithm
-
getName
String getName()Returns the name of this identity. It will be useful to identify this object in theIdentityRepository.- Returns:
- the name of this identity
-
isEncrypted
boolean isEncrypted()Returnstrueif this identity is cyphered.- Returns:
trueif this identity is cyphered.
-
clear
void clear()Disposes internally allocated data, like byte array for the private key.
-
setPassphrase(byte[])