public class PrivateKeyReader extends Object
PrivateKeyReader is a utility class for reading private keys.| Modifier and Type | Field and Description |
|---|---|
static String |
BEGIN_PRIVATE_KEY_PREFIX
The Constant BEGIN_PRIVATE_KEY_PREFIX.
|
static String |
BEGIN_RSA_PRIVATE_KEY_PREFIX
The Constant BEGIN_RSA_PRIVATE_KEY_PREFIX.
|
static String |
END_PRIVATE_KEY_SUFFIX
The Constant END_PRIVATE_KEY_SUFFIX.
|
static String |
END_RSA_PRIVATE_KEY_SUFFIX
The Constant END_RSA_PRIVATE_KEY_SUFFIX.
|
static String |
RSA_PRIVATE_KEY
The Constant RSA_PRIVATE_KEY.
|
| Constructor and Description |
|---|
PrivateKeyReader() |
| Modifier and Type | Method and Description |
|---|---|
static String |
readPemFileAsBase64(File file)
Read the private key from a pem file as base64 encoded
String value. |
static PrivateKey |
readPemPrivateKey(File file,
SecurityProvider securityProvider)
Read pem private key.
|
static PrivateKey |
readPrivateKey(byte[] privateKeyBytes,
SecurityProvider securityProvider)
Read private key.
|
static PrivateKey |
readPrivateKey(byte[] privateKeyBytes,
String provider)
Read private key.
|
static PrivateKey |
readPrivateKey(byte[] privateKeyBytes,
String provider,
String algorithm)
Read private key.
|
static PrivateKey |
readPrivateKey(File file)
Read private key.
|
static PrivateKey |
readPrivateKey(File file,
SecurityProvider securityProvider)
Read private key.
|
static PrivateKey |
readPrivateKey(File file,
String provider)
Read private key.
|
public static final String RSA_PRIVATE_KEY
public static final String BEGIN_PRIVATE_KEY_PREFIX
public static final String END_PRIVATE_KEY_SUFFIX
public static final String BEGIN_RSA_PRIVATE_KEY_PREFIX
public static final String END_RSA_PRIVATE_KEY_SUFFIX
public static PrivateKey readPrivateKey(File file) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
file - the fileIOException - Signals that an I/O exception has occurred.NoSuchAlgorithmException - is thrown if instantiation of the cypher object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchProviderException - is thrown if the specified provider is not registered in the security provider
list.public static PrivateKey readPrivateKey(File file, String provider) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
file - the fileprovider - the security providerIOException - Signals that an I/O exception has occurred.NoSuchAlgorithmException - is thrown if instantiation of the cypher object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchProviderException - is thrown if the specified provider is not registered in the security provider
list.public static PrivateKey readPrivateKey(File file, SecurityProvider securityProvider) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
file - the filesecurityProvider - the security providerIOException - Signals that an I/O exception has occurred.NoSuchAlgorithmException - is thrown if instantiation of the cypher object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchProviderException - is thrown if the specified provider is not registered in the security provider
list.public static PrivateKey readPrivateKey(byte[] privateKeyBytes, String provider) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
privateKeyBytes - the private key bytesprovider - the providerNoSuchAlgorithmException - is thrown if instantiation of the cypher object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchProviderException - is thrown if the specified provider is not registered in the security provider
list.public static PrivateKey readPrivateKey(byte[] privateKeyBytes, String provider, String algorithm) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
privateKeyBytes - the private key bytesprovider - the provideralgorithm - the algorithm for the KeyFactoryNoSuchAlgorithmException - is thrown if instantiation of the cypher object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchProviderException - is thrown if the specified provider is not registered in the security provider
list.public static PrivateKey readPemPrivateKey(File file, SecurityProvider securityProvider) throws Exception
file - the filesecurityProvider - the security providerException - is thrown if if a security error occurpublic static String readPemFileAsBase64(File file) throws IOException
String value.file - the file in pem format that contains the private key.String value.IOException - Signals that an I/O exception has occurred.public static PrivateKey readPrivateKey(byte[] privateKeyBytes, SecurityProvider securityProvider) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
privateKeyBytes - the private key bytessecurityProvider - the security providerNoSuchAlgorithmException - the no such algorithm exceptionInvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchProviderException - is thrown if the specified provider is not registered in the security provider
list.Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.