public final class PemSecretKeyHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static PemSecretKeyHelper |
getInstance()
Get the singleton instance of this class.
|
SecretKey |
readPrivateKeyFromPEM(String fileName,
char[] passwd)
Read a secret key from a PEM file.
|
SecretKey |
readSecretKeyFromPEM(File file,
char[] passwd)
Read a secret key from a PEM file.
|
SecretKey |
readSecretKeyFromPEM(InputStream inStream,
char[] passwd)
file Read a secret key from a stream.
|
void |
writeSecretKeyToPEM(SecretKey secretKey,
File file,
char[] passwd)
Write a Secret Key to the given file
|
void |
writeSecretKeyToPEM(SecretKey secretKey,
OutputStream outStream,
char[] passwd)
Write a Secret Key to the given output stream
|
void |
writeSecretKeyToPEM(SecretKey secretKey,
String fileName,
char[] passwd)
Write a Secret Key to the given file
|
public static PemSecretKeyHelper getInstance()
public SecretKey readPrivateKeyFromPEM(String fileName, char[] passwd) throws IOException, GeneralSecurityException
fileName - The name of the pem file if the name starts with
classpath: the file is sought on the class path.passwd - The password to decrypt the contentGeneralSecurityException - If any of the ciphers or factories failsIOException - if the resource cannot be opened or there is a read errorpublic SecretKey readSecretKeyFromPEM(File file, char[] passwd) throws IOException, GeneralSecurityException
file - The file to read frompasswd - The password to decrypt the contentGeneralSecurityException - If any of the ciphers or factories failsIOException - if the resource cannot be opened or there is a read errorpublic SecretKey readSecretKeyFromPEM(InputStream inStream, char[] passwd) throws GeneralSecurityException, IOException
inStream - The stream to read frompasswd - The password to decrypt the contentGeneralSecurityException - If any of the ciphers or factories failsIOException - if the resource cannot be opened or there is a read errorpublic void writeSecretKeyToPEM(SecretKey secretKey, String fileName, char[] passwd) throws GeneralSecurityException, IOException
secretKey - The key to writefileName - The name of the file to write topasswd - The password to encrypt the contentGeneralSecurityException - If any of the algorithms or ciphers failsIOException - If the file cannot be opened or written topublic void writeSecretKeyToPEM(SecretKey secretKey, File file, char[] passwd) throws GeneralSecurityException, IOException
secretKey - The key to writefile - The file to write topasswd - The password to encrypt the contentGeneralSecurityException - If any of the algorithms or ciphers failsIOException - If the file cannot be opened or written topublic void writeSecretKeyToPEM(SecretKey secretKey, OutputStream outStream, char[] passwd) throws GeneralSecurityException, IOException
secretKey - The key to writeoutStream - The stream to write topasswd - The password to encrypt the contentGeneralSecurityException - If any of the algorithms or ciphers failsIOException - If the file cannot be opened or written toCopyright © 2019 ADDC Infotech GmbH. All rights reserved.