org.globus.gsi.bc
Class BouncyCastleOpenSSLKey

java.lang.Object
  extended by org.globus.gsi.OpenSSLKey
      extended by org.globus.gsi.bc.BouncyCastleOpenSSLKey

public class BouncyCastleOpenSSLKey
extends OpenSSLKey

BouncyCastle-based implementation of OpenSSLKey.

Since:
1.0
Version:
${version}

Constructor Summary
BouncyCastleOpenSSLKey(java.io.InputStream is)
          Reads a OpenSSL private key from the specified input stream.
BouncyCastleOpenSSLKey(java.security.PrivateKey key)
          Converts a RSAPrivateCrtKey into OpenSSL key.
BouncyCastleOpenSSLKey(java.lang.String file)
          Reads a OpenSSL private key from the specified file.
BouncyCastleOpenSSLKey(java.lang.String algorithm, byte[] data)
          Initializes the OpenSSL key from raw byte array.
 
Method Summary
protected  byte[] getEncoded(java.security.PrivateKey key)
           
protected  java.security.PrivateKey getKey(java.lang.String alg, byte[] data)
           
protected  java.lang.String getProvider()
           
 
Methods inherited from class org.globus.gsi.OpenSSLKey
decrypt, decrypt, encrypt, encrypt, getEncoded, getPrivateKey, isEncrypted, setEncryptionAlgorithm, writeTo, writeTo, writeTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(java.io.InputStream is)
                       throws java.io.IOException,
                              java.security.GeneralSecurityException
Reads a OpenSSL private key from the specified input stream. The private key must be PEM encoded and can be encrypted.

Parameters:
is - input stream with OpenSSL key in PEM format.
Throws:
java.io.IOException - if I/O problems.
java.security.GeneralSecurityException - if problems with the key

BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(java.lang.String file)
                       throws java.io.IOException,
                              java.security.GeneralSecurityException
Reads a OpenSSL private key from the specified file. The private key must be PEM encoded and can be encrypted.

Parameters:
file - file containing the OpenSSL key in PEM format.
Throws:
java.io.IOException - if I/O problems.
java.security.GeneralSecurityException - if problems with the key

BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(java.security.PrivateKey key)
Converts a RSAPrivateCrtKey into OpenSSL key.

Parameters:
key - private key - must be a RSAPrivateCrtKey

BouncyCastleOpenSSLKey

public BouncyCastleOpenSSLKey(java.lang.String algorithm,
                              byte[] data)
                       throws java.security.GeneralSecurityException
Initializes the OpenSSL 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.
Throws:
java.security.GeneralSecurityException - if any security problems.
Method Detail

getKey

protected java.security.PrivateKey getKey(java.lang.String alg,
                                          byte[] data)
                                   throws java.security.GeneralSecurityException
Specified by:
getKey in class OpenSSLKey
Throws:
java.security.GeneralSecurityException

getEncoded

protected byte[] getEncoded(java.security.PrivateKey key)
Specified by:
getEncoded in class OpenSSLKey

getProvider

protected java.lang.String getProvider()
Overrides:
getProvider in class OpenSSLKey


Copyright © 2013. All Rights Reserved.