|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
org.globus.security
Class SSLeayKeyHolder
java.lang.Object | +--org.globus.security.SSLeayKeyHolder
- public class SSLeayKeyHolder
- extends java.lang.Object
Utility for decrypting and encrypting SSLeay-style PEM-formatted private keys. Currently, only RSA keys are supported, and only TripleDES encryption is supported. This is based on work done by Ming Yung at DSTC.
| Constructor Summary | |
SSLeayKeyHolder(java.io.InputStream is)
Reads a SSLeay private key from the specified input stream. |
|
SSLeayKeyHolder(java.security.PrivateKey key)
Converts a RSAPrivateCrtKey into SSLeay key. |
|
SSLeayKeyHolder(java.lang.String file)
Reads a SSLeay private key from the specified file. |
|
SSLeayKeyHolder(java.lang.String algorithm,
byte[] data)
Initializes the SSLeay key from raw byte array. |
|
| Method Summary | |
void |
decrypt(byte[] password)
Decrypts the private key with given password. |
void |
decrypt(java.lang.String password)
Decrypts the private key with given password. |
void |
encrypt(byte[] password)
Encrypts the private key with given password. |
void |
encrypt(java.lang.String password)
Encrypts the private key with given password. |
java.security.PrivateKey |
getPrivateKey()
Returns the JCE (RSAPrivateCrtKey) key. |
boolean |
isEncrypted()
Check if the key was encrypted or not. |
void |
writeTo(java.io.OutputStream output)
Writes the private key to the specified output stream in PEM format. |
void |
writeTo(java.lang.String file)
Writes the private key to the specified file in PEM format. |
void |
writeTo(java.io.Writer w)
Writes the private key to the specified writer in PEM format. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
SSLeayKeyHolder
public SSLeayKeyHolder(java.io.InputStream is)
throws java.io.IOException,
java.security.InvalidKeyException
- Reads a SSLeay private key from the specified input stream.
The private key must be PEM encoded and can be encrypted.
- Parameters:
is- input stream with ssleay key in PEM format.
SSLeayKeyHolder
public SSLeayKeyHolder(java.lang.String file)
throws java.io.IOException,
java.security.InvalidKeyException
- Reads a SSLeay private key from the specified file.
The private key must be PEM encoded and can be encrypted.
- Parameters:
file- file contaning the ssleay key in PEM format.
SSLeayKeyHolder
public SSLeayKeyHolder(java.security.PrivateKey key)
- Converts a RSAPrivateCrtKey into SSLeay key.
- Parameters:
key- private key - must be a RSAPrivateCrtKey
SSLeayKeyHolder
public SSLeayKeyHolder(java.lang.String algorithm,
byte[] data)
throws java.security.InvalidKeyException
- Initializes the SSLeay key from raw byte array.
- Parameters:
algorithm- the algorithm of the key. Currently only RSA algorithm is supported.data- the DER encoded key data. If RSA algorithm, the key must be in PKCS#1 format.
| Method Detail |
isEncrypted
public boolean isEncrypted()
- Check if the key was encrypted or not.
- Returns:
- true if the key is encrypted, false otherwise.
decrypt
public void decrypt(java.lang.String password)
throws java.security.GeneralSecurityException,
java.security.InvalidKeyException
- Decrypts the private key with given password.
Does nothing if the key is not encrypted.
- Parameters:
password- password to decrypt the key with.java.security.GeneralSecurityExceptionjava.security.InvalidKeyException
decrypt
public void decrypt(byte[] password)
throws java.security.GeneralSecurityException,
java.security.InvalidKeyException
- Decrypts the private key with given password.
Does nothing if the key is not encrypted.
- Parameters:
password- password to decrypt the key with.java.security.GeneralSecurityExceptionjava.security.InvalidKeyException
encrypt
public void encrypt(java.lang.String password)
throws java.security.GeneralSecurityException
- Encrypts the private key with given password.
Does nothing if the key is encrypted already.
- Parameters:
password- password to encrypt the key with.java.security.GeneralSecurityException
encrypt
public void encrypt(byte[] password)
throws java.security.GeneralSecurityException
- Encrypts the private key with given password.
Does nothing if the key is encrypted already.
- Parameters:
password- password to encrypt the key with.java.security.GeneralSecurityException
getPrivateKey
public java.security.PrivateKey getPrivateKey()
- Returns the JCE (RSAPrivateCrtKey) key.
- Returns:
- the private key, null if the key was not decryted yet.
writeTo
public void writeTo(java.io.OutputStream output)
throws java.io.IOException
- Writes the private key to the specified output stream in PEM
format. If the key was encrypted it will be encoded as an encyrpted
RSA key. If not, it will be encoded as a regular RSA key.
- Parameters:
output- output stream to write the key to.java.io.IOException
writeTo
public void writeTo(java.io.Writer w)
throws java.io.IOException
- Writes the private key to the specified writer in PEM format.
If the key was encrypted it will be encoded as an encyrpted
RSA key. If not, it will be encoded as a regular RSA key.
java.io.IOException
writeTo
public void writeTo(java.lang.String file)
throws java.io.IOException
- Writes the private key to the specified file in PEM format.
If the key was encrypted it will be encoded as an encyrpted
RSA key. If not, it will be encoded as a regular RSA key.
- Parameters:
file- file to write the key to.java.io.IOException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||