maspack.fileutil.jsch
Class IdentityFile

java.lang.Object
  extended by maspack.fileutil.jsch.IdentityFile
All Implemented Interfaces:
com.jcraft.jsch.Identity

public class IdentityFile
extends java.lang.Object
implements com.jcraft.jsch.Identity

Holds contents of a private ssh key. If it is encrypted and requires a passphrase


Method Summary
 void clear()
          Disposes internally allocated data, like byte array for the private key.
 boolean decrypt()
          Deprecated. This method should not be invoked.
 java.lang.String getAlgName()
          Returns the name of the key algorithm.
 KeyPair getKeyPair()
          Returns an instance of KeyPair used in this Identity.
 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.
 boolean isEncrypted()
          Returns true if this identity is cyphered.
static IdentityFile newInstance(java.io.File prvfile, java.io.File pubfile)
           
static IdentityFile newInstance(java.lang.String name, byte[] prvkey, byte[] pubkey)
           
static IdentityFile newInstance(java.lang.String prvfile, java.lang.String pubfile)
           
 boolean setPassphrase(byte[] passphrase)
          Decrypts this identity with the specified pass-phrase.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static IdentityFile newInstance(java.io.File prvfile,
                                       java.io.File pubfile)
                                throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException

newInstance

public static IdentityFile newInstance(java.lang.String prvfile,
                                       java.lang.String pubfile)
                                throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException

newInstance

public static IdentityFile newInstance(java.lang.String name,
                                       byte[] prvkey,
                                       byte[] pubkey)
                                throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException

setPassphrase

public boolean setPassphrase(byte[] passphrase)
                      throws com.jcraft.jsch.JSchException
Decrypts this identity with the specified pass-phrase.

Specified by:
setPassphrase in interface com.jcraft.jsch.Identity
Parameters:
passphrase - the pass-phrase for this identity.
Returns:
true if the decryption is succeeded or this identity is not cyphered.
Throws:
com.jcraft.jsch.JSchException

getPublicKeyBlob

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

Specified by:
getPublicKeyBlob in interface com.jcraft.jsch.Identity
Returns:
the public-key blob

getSignature

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

Specified by:
getSignature in interface com.jcraft.jsch.Identity
Parameters:
data - data to be signed
Returns:
the signature

decrypt

public boolean decrypt()
Deprecated. This method should not be invoked.

Specified by:
decrypt in interface com.jcraft.jsch.Identity
See Also:
setPassphrase(byte[] passphrase)

getAlgName

public java.lang.String getAlgName()
Returns the name of the key algorithm.

Specified by:
getAlgName in interface com.jcraft.jsch.Identity
Returns:
"ssh-rsa" or "ssh-dss"

getName

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

Specified by:
getName in interface com.jcraft.jsch.Identity

isEncrypted

public boolean isEncrypted()
Returns true if this identity is cyphered.

Specified by:
isEncrypted in interface com.jcraft.jsch.Identity
Returns:
true if this identity is cyphered.

clear

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

Specified by:
clear in interface com.jcraft.jsch.Identity

getKeyPair

public KeyPair getKeyPair()
Returns an instance of KeyPair used in this Identity.

Returns:
an instance of KeyPair used in this Identity.