public class PublicKeyReader extends Object
PublicKeyReader is a utility class for reading public keys.| Modifier and Type | Field and Description |
|---|---|
static String |
BEGIN_PUBLIC_KEY_PREFIX
The Constant BEGIN_PUBLIC_KEY_PREFIX.
|
static String |
END_PUBLIC_KEY_SUFFIX
The Constant END_PUBLIC_KEY_SUFFIX.
|
| Constructor and Description |
|---|
PublicKeyReader() |
| Modifier and Type | Method and Description |
|---|---|
static String |
readPemFileAsBase64(File file)
Read the public key from a pem file as base64 encoded
String value. |
static PublicKey |
readPemPublicKey(File file)
reads a public key from a file.
|
static PublicKey |
readPemPublicKey(File file,
SecurityProvider securityProvider)
reads a public key from a file.
|
static PublicKey |
readPublicKey(byte[] publicKeyBytes,
SecurityProvider securityProvider)
Read public key.
|
static PublicKey |
readPublicKey(byte[] publicKeyBytes,
String provider)
Read public key.
|
static PublicKey |
readPublicKey(byte[] publicKeyBytes,
String provider,
String algorithm)
Read public key.
|
static PublicKey |
readPublicKey(File file)
Read public key.
|
public static final String END_PUBLIC_KEY_SUFFIX
public static final String BEGIN_PUBLIC_KEY_PREFIX
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, 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 PublicKey readPublicKey(byte[] publicKeyBytes, String provider, String algorithm) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
publicKeyBytes - the public 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 PublicKey readPemPublicKey(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 public key.String value.IOException - Signals that an I/O exception has occurred.Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.