maspack.fileutil.jsch
Class KeyPair

java.lang.Object
  extended by maspack.fileutil.jsch.KeyPair
Direct Known Subclasses:
KeyPairDSA, KeyPairRSA

public abstract class KeyPair
extends java.lang.Object


Field Summary
static int DSA
           
static int ERROR
           
static int RSA
           
static int UNKNOWN
           
 
Constructor Summary
KeyPair()
           
 
Method Summary
 boolean decrypt(byte[] _passphrase)
           
 boolean decrypt(java.lang.String _passphrase)
           
 void dispose()
           
 void finalize()
           
abstract  byte[] forSSHAgent()
           
static KeyPair genKeyPair(int type)
           
static KeyPair genKeyPair(int type, int key_size)
           
 java.lang.String getFingerPrint()
           
abstract  int getKeyType()
           
abstract  byte[] getKeyTypeName()
           
 byte[] getPublicKeyBlob()
           
 java.lang.String getPublicKeyComment()
           
abstract  byte[] getSignature(byte[] data)
           
abstract  com.jcraft.jsch.Signature getVerifier()
           
 boolean isEncrypted()
           
static KeyPair load(byte[] prvkey, byte[] pubkey)
           
static KeyPair load(java.io.File prvfile, java.io.File pubfile)
          Loads a key from a file
static KeyPair load(java.lang.String prvkey)
           
static KeyPair load(java.lang.String prvfile, java.lang.String pubfile)
          Loads a key from a file
static KeyPair loadPPK(byte[] buf)
           
 void setPassphrase(byte[] passphrase)
           
 void setPassphrase(java.lang.String passphrase)
           
 void setPublicKeyComment(java.lang.String publicKeyComment)
           
 void writePrivateKey(java.io.OutputStream out)
           
 void writePrivateKey(java.lang.String name)
           
 void writePublicKey(java.io.OutputStream out, java.lang.String comment)
           
 void writePublicKey(java.lang.String name, java.lang.String comment)
           
 void writeSECSHPublicKey(java.io.OutputStream out, java.lang.String comment)
           
 void writeSECSHPublicKey(java.lang.String name, java.lang.String comment)
           
 
Methods inherited from class java.lang.Object
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
Constructor Detail

KeyPair

public KeyPair()
Method Detail

genKeyPair

public static KeyPair genKeyPair(int type)
                          throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException

genKeyPair

public static KeyPair genKeyPair(int type,
                                 int key_size)
                          throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException

getSignature

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

getVerifier

public abstract com.jcraft.jsch.Signature getVerifier()

forSSHAgent

public abstract byte[] forSSHAgent()
                            throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException

getPublicKeyComment

public java.lang.String getPublicKeyComment()

setPublicKeyComment

public void setPublicKeyComment(java.lang.String publicKeyComment)

writePrivateKey

public void writePrivateKey(java.io.OutputStream out)

getKeyTypeName

public abstract byte[] getKeyTypeName()

getKeyType

public abstract int getKeyType()

getPublicKeyBlob

public byte[] getPublicKeyBlob()

writePublicKey

public void writePublicKey(java.io.OutputStream out,
                           java.lang.String comment)

writePublicKey

public void writePublicKey(java.lang.String name,
                           java.lang.String comment)
                    throws java.io.FileNotFoundException,
                           java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

writeSECSHPublicKey

public void writeSECSHPublicKey(java.io.OutputStream out,
                                java.lang.String comment)

writeSECSHPublicKey

public void writeSECSHPublicKey(java.lang.String name,
                                java.lang.String comment)
                         throws java.io.FileNotFoundException,
                                java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

writePrivateKey

public void writePrivateKey(java.lang.String name)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

getFingerPrint

public java.lang.String getFingerPrint()

setPassphrase

public void setPassphrase(java.lang.String passphrase)

setPassphrase

public void setPassphrase(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(java.lang.String prvkey)
                    throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException

load

public static KeyPair load(java.lang.String prvfile,
                           java.lang.String pubfile)
                    throws com.jcraft.jsch.JSchException
Loads a key from a file

Parameters:
prvfile -
pubfile -
Returns:
loaded key pair
Throws:
com.jcraft.jsch.JSchException

load

public static KeyPair load(java.io.File prvfile,
                           java.io.File pubfile)
                    throws com.jcraft.jsch.JSchException
Loads a key from a file

Parameters:
prvfile -
pubfile -
Returns:
loaded key pair
Throws:
com.jcraft.jsch.JSchException

load

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

dispose

public void dispose()

finalize

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

loadPPK

public static KeyPair loadPPK(byte[] buf)
                       throws com.jcraft.jsch.JSchException
Throws:
com.jcraft.jsch.JSchException