edu.vt.middleware.crypt.io
Class PrivateKeyCredentialReader

java.lang.Object
  extended by edu.vt.middleware.crypt.io.AbstractEncodedCredentialReader<PrivateKey>
      extended by edu.vt.middleware.crypt.io.PrivateKeyCredentialReader
All Implemented Interfaces:
CredentialReader<PrivateKey>

public class PrivateKeyCredentialReader
extends AbstractEncodedCredentialReader<PrivateKey>

Reads encoded private keys in PKCS#8 or OpenSSL "traditional" format. Both PEM and DER encodings are supported.

Version:
$Revision: 2744 $
Author:
Middleware Services

Field Summary
 
Fields inherited from class edu.vt.middleware.crypt.io.AbstractEncodedCredentialReader
DSA_ID, EC_ID, logger, RSA_ID
 
Constructor Summary
PrivateKeyCredentialReader()
           
 
Method Summary
protected  PrivateKey decode(byte[] encoded)
          Decodes an encoded representation of a credential into a corresponding object.
 PrivateKey read(File file, char[] password)
          Reads an encrypted private key in PKCS#8 or OpenSSL "traditional" format from a file into a PrivateKey object.
 PrivateKey read(InputStream in, char[] password)
          Reads an encrypted private key in PKCS#8 or OpenSSL "traditional" format from a file into a PrivateKey object.
 
Methods inherited from class edu.vt.middleware.crypt.io.AbstractEncodedCredentialReader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrivateKeyCredentialReader

public PrivateKeyCredentialReader()
Method Detail

read

public PrivateKey read(File file,
                       char[] password)
                throws IOException,
                       CryptException
Reads an encrypted private key in PKCS#8 or OpenSSL "traditional" format from a file into a PrivateKey object. Both DER and PEM encoded keys are supported.

Parameters:
file - Private key file.
password - Password to decrypt private key.
Returns:
Private key containing data read from file.
Throws:
CryptException - On key format errors.
IOException - On key read errors.

read

public PrivateKey read(InputStream in,
                       char[] password)
                throws CryptException,
                       IOException
Reads an encrypted private key in PKCS#8 or OpenSSL "traditional" format from a file into a PrivateKey object. Both DER and PEM encoded keys are supported.

Parameters:
in - Input stream containing private key data.
password - Password to decrypt private key; MUST NOT be null.
Returns:
Private key containing data read from file.
Throws:
IOException - On IO errors.
CryptException - On cryptography errors such as invalid formats, unsupported ciphers, illegal settings.

decode

protected PrivateKey decode(byte[] encoded)
                     throws CryptException
Decodes an encoded representation of a credential into a corresponding object.

Specified by:
decode in class AbstractEncodedCredentialReader<PrivateKey>
Parameters:
encoded - Encoded representation of credential.
Returns:
Decoded credential.
Throws:
CryptException - On decoding errors.


Copyright © 2003-2013 Virginia Tech. All Rights Reserved.