edu.vt.middleware.crypt.io
Class PrivateKeyCredentialReader
java.lang.Object
edu.vt.middleware.crypt.io.AbstractEncodedCredentialReader<PrivateKey>
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
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PrivateKeyCredentialReader
public PrivateKeyCredentialReader()
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.