public class KeyExtensions extends Object
KeyExtensions holds utility methods for read public and private keys from
files.| Modifier and Type | Field and Description |
|---|---|
static int |
AES_KEY_LENGTH
The Constant AES_KEY_LENGTH.
|
static String |
BEGIN_PRIVATE_KEY_PREFIX
The Constant BEGIN_PRIVATE_KEY_PREFIX.
|
static String |
BEGIN_PUBLIC_KEY_PREFIX
The Constant BEGIN_PUBLIC_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_PUBLIC_KEY_SUFFIX
The Constant END_PUBLIC_KEY_SUFFIX.
|
static String |
END_RSA_PRIVATE_KEY_SUFFIX
The Constant END_RSA_PRIVATE_KEY_SUFFIX.
|
| Constructor and Description |
|---|
KeyExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static org.bouncycastle.util.io.pem.PemObject |
getPemObject(File file)
Gets the pem object.
|
static PrivateKey |
readPemPrivateKey(File file,
de.alpharogroup.crypto.provider.SecurityProvider securityProvider)
Read pem private key.
|
static PublicKey |
readPemPublicKey(File file)
reads a public key from a file.
|
static PublicKey |
readPemPublicKey(File file,
de.alpharogroup.crypto.provider.SecurityProvider securityProvider)
reads a public key from a file.
|
static PrivateKey |
readPrivateKey(byte[] privateKeyBytes,
de.alpharogroup.crypto.provider.SecurityProvider securityProvider)
Read private key.
|
static PrivateKey |
readPrivateKey(byte[] privateKeyBytes,
String provider)
Read private key.
|
static PrivateKey |
readPrivateKey(File file)
Read private key.
|
static PublicKey |
readPublicKey(byte[] publicKeyBytes,
de.alpharogroup.crypto.provider.SecurityProvider securityProvider)
Read public key.
|
static PublicKey |
readPublicKey(byte[] publicKeyBytes,
String provider)
Read public key.
|
static PublicKey |
readPublicKey(File file)
Read public key.
|
public static final int AES_KEY_LENGTH
public static final String END_PUBLIC_KEY_SUFFIX
public static final String BEGIN_PUBLIC_KEY_PREFIX
public static final String END_PRIVATE_KEY_SUFFIX
public static final String BEGIN_PRIVATE_KEY_PREFIX
public static final String END_RSA_PRIVATE_KEY_SUFFIX
public static final String BEGIN_RSA_PRIVATE_KEY_PREFIX
public static org.bouncycastle.util.io.pem.PemObject getPemObject(File file) throws IOException
file - the fileIOException - Signals that an I/O exception has occurred.public static PublicKey readPublicKey(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 PublicKey readPublicKey(byte[] publicKeyBytes, de.alpharogroup.crypto.provider.SecurityProvider securityProvider) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
publicKeyBytes - the public key bytessecurityProvider - the security 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 PublicKey readPublicKey(byte[] publicKeyBytes, String provider) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
publicKeyBytes - the public 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(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(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 readPemPrivateKey(File file, de.alpharogroup.crypto.provider.SecurityProvider securityProvider) throws Exception
file - the filesecurityProvider - the security providerException - is thrown if if a security error occurpublic static PrivateKey readPrivateKey(byte[] privateKeyBytes, de.alpharogroup.crypto.provider.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.public static PublicKey readPemPublicKey(File file, de.alpharogroup.crypto.provider.SecurityProvider securityProvider) throws Exception
file - the filesecurityProvider - the security providerException - is thrown if if a security error occurCopyright © 2015–2016 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.