com.jcraft.jsch
Class KeyPair

java.lang.Object
  extended by com.jcraft.jsch.KeyPair
Direct Known Subclasses:
KeyPairDSA, KeyPairRSA

public abstract class KeyPair
extends java.lang.Object


Field Summary
static int DSA
           
static int ERROR
           
protected  java.lang.String publicKeyComment
           
static int RSA
           
static int UNKNOWN
           
 
Constructor Summary
KeyPair(JSch jsch)
           
 
Method Summary
 boolean decrypt(byte[] _passphrase)
           
 boolean decrypt(java.lang.String _passphrase)
           
 void dispose()
           
 void finalize()
           
abstract  byte[] forSSHAgent()
           
static KeyPair genKeyPair(JSch jsch, int type)
           
static KeyPair genKeyPair(JSch jsch, int type, int key_size)
           
 java.lang.String getFingerPrint()
          Returns the finger-print of the public key.
abstract  int getKeyType()
           
 byte[] getPublicKeyBlob()
          Returns the blob of the public key.
 java.lang.String getPublicKeyComment()
           
abstract  byte[] getSignature(byte[] data)
           
abstract  Signature getVerifier()
           
 boolean isEncrypted()
           
static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey)
           
static KeyPair load(JSch jsch, java.lang.String prvkey)
           
static KeyPair load(JSch jsch, java.lang.String prvfile, java.lang.String pubfile)
           
 void setPassphrase(byte[] passphrase)
          Deprecated. use #writePrivateKey(String name, byte[] passphrase)
 void setPassphrase(java.lang.String passphrase)
          Deprecated. use #writePrivateKey(java.io.OutputStream out, byte[] passphrase)
 void setPublicKeyComment(java.lang.String publicKeyComment)
           
 void writePrivateKey(java.io.OutputStream out)
          Writes the plain private key to the given output stream.
 void writePrivateKey(java.io.OutputStream out, byte[] passphrase)
          Writes the cyphered private key to the given output stream.
 void writePrivateKey(java.lang.String name)
          Writes the plain private key to the file.
 void writePrivateKey(java.lang.String name, byte[] passphrase)
          Writes the cyphered private key to the file.
 void writePublicKey(java.io.OutputStream out, java.lang.String comment)
          Writes the public key with the specified comment to the output stream.
 void writePublicKey(java.lang.String name, java.lang.String comment)
          Writes the public key with the specified comment to the file.
 void writeSECSHPublicKey(java.io.OutputStream out, java.lang.String comment)
          Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txt
 void writeSECSHPublicKey(java.lang.String name, java.lang.String comment)
          Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txt
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
See Also:
Constant Field Values

DSA

public static final int DSA
See Also:
Constant Field Values

RSA

public static final int RSA
See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

publicKeyComment

protected java.lang.String publicKeyComment
Constructor Detail

KeyPair

public KeyPair(JSch jsch)
Method Detail

genKeyPair

public static KeyPair genKeyPair(JSch jsch,
                                 int type)
                          throws JSchException
Throws:
JSchException

genKeyPair

public static KeyPair genKeyPair(JSch jsch,
                                 int type,
                                 int key_size)
                          throws JSchException
Throws:
JSchException

getSignature

public abstract byte[] getSignature(byte[] data)

getVerifier

public abstract Signature getVerifier()

forSSHAgent

public abstract byte[] forSSHAgent()
                            throws JSchException
Throws:
JSchException

getPublicKeyComment

public java.lang.String getPublicKeyComment()

setPublicKeyComment

public void setPublicKeyComment(java.lang.String publicKeyComment)

writePrivateKey

public void writePrivateKey(java.io.OutputStream out)
Writes the plain private key to the given output stream.

Parameters:
out - output stream
See Also:
writePrivateKey(java.io.OutputStream out, byte[] passphrase)

writePrivateKey

public void writePrivateKey(java.io.OutputStream out,
                            byte[] passphrase)
Writes the cyphered private key to the given output stream.

Parameters:
out - output stream
passphrase - a passphrase to encrypt the private key

getKeyType

public abstract int getKeyType()

getPublicKeyBlob

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

Returns:
blob of the public key

writePublicKey

public void writePublicKey(java.io.OutputStream out,
                           java.lang.String comment)
Writes the public key with the specified comment to the output stream.

Parameters:
out - output stream
comment - comment

writePublicKey

public void writePublicKey(java.lang.String name,
                           java.lang.String comment)
                    throws java.io.FileNotFoundException,
                           java.io.IOException
Writes the public key with the specified comment to the file.

Parameters:
name - file name
comment - comment
Throws:
java.io.FileNotFoundException
java.io.IOException
See Also:
writePublicKey(java.io.OutputStream out, String comment)

writeSECSHPublicKey

public void writeSECSHPublicKey(java.io.OutputStream out,
                                java.lang.String comment)
Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txt

Parameters:
out - output stream
comment - comment

writeSECSHPublicKey

public void writeSECSHPublicKey(java.lang.String name,
                                java.lang.String comment)
                         throws java.io.FileNotFoundException,
                                java.io.IOException
Writes the public key with the specified comment to the output stream in the format defined in http://www.ietf.org/rfc/rfc4716.txt

Parameters:
name - file name
comment - comment
Throws:
java.io.FileNotFoundException
java.io.IOException
See Also:
writeSECSHPublicKey(java.io.OutputStream out, String comment)

writePrivateKey

public void writePrivateKey(java.lang.String name)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Writes the plain private key to the file.

Parameters:
name - file name
Throws:
java.io.FileNotFoundException
java.io.IOException
See Also:
writePrivateKey(String name, byte[] passphrase)

writePrivateKey

public void writePrivateKey(java.lang.String name,
                            byte[] passphrase)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Writes the cyphered private key to the file.

Parameters:
name - file name
passphrase - a passphrase to encrypt the private key
Throws:
java.io.FileNotFoundException
java.io.IOException
See Also:
writePrivateKey(java.io.OutputStream out, byte[] passphrase)

getFingerPrint

public java.lang.String getFingerPrint()
Returns the finger-print of the public key.

Returns:
finger print

setPassphrase

public void setPassphrase(java.lang.String passphrase)
Deprecated. use #writePrivateKey(java.io.OutputStream out, byte[] passphrase)


setPassphrase

public void setPassphrase(byte[] passphrase)
Deprecated. use #writePrivateKey(String name, byte[] passphrase)


isEncrypted

public boolean isEncrypted()

decrypt

public boolean decrypt(java.lang.String _passphrase)

decrypt

public boolean decrypt(byte[] _passphrase)

load

public static KeyPair load(JSch jsch,
                           java.lang.String prvkey)
                    throws JSchException
Throws:
JSchException

load

public static KeyPair load(JSch jsch,
                           java.lang.String prvfile,
                           java.lang.String pubfile)
                    throws JSchException
Throws:
JSchException

load

public static KeyPair load(JSch jsch,
                           byte[] prvkey,
                           byte[] pubkey)
                    throws JSchException
Throws:
JSchException

dispose

public void dispose()

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object