public class PrivateKeys extends Object
| Modifier and Type | Method and Description |
|---|---|
static PrivateKey |
loadFromKeyStore(InputStream keyStream,
String storePass,
String alias,
String keyPass)
Retrieves the private key from the specified key store stream using default key store.
|
static PrivateKey |
loadFromKeyStore(KeyStore keyStore,
InputStream keyStream,
String storePass,
String alias,
String keyPass)
Retrieves the private key from the specified key store stream and specified key store.
|
static PrivateKey |
loadFromP12File(File p12File,
String storePass,
String alias,
String keyPass)
Reads a
PKCS#12 format private key from a given file. |
static PrivateKey |
loadFromPk8File(File file)
Deprecated.
(scheduled to be removed in 1.14) Use
loadFromPkcs8PemFile(java.io.File) instead. Note
that the file formatting requirements for loadFromPkcs8PemFile(java.io.File) are
stricter than this method's requirements. |
static PrivateKey |
loadFromPkcs8PemFile(File pemFile)
Reads a
PEM formatted PKCS8 encoded private key from a given file. |
static byte[] |
readFromPemFormattedFile(File file)
Reads a
PEM formatted private key from a given file. |
public static PrivateKey loadFromKeyStore(InputStream keyStream, String storePass, String alias, String keyPass) throws IOException, GeneralSecurityException
keyStream - input stream to the key store file (closed at the end of this method in a
finally block)storePass - password protecting the key store filealias - alias under which the private key is storedkeyPass - password protecting the private keyIOExceptionGeneralSecurityExceptionpublic static PrivateKey loadFromKeyStore(KeyStore keyStore, InputStream keyStream, String storePass, String alias, String keyPass) throws IOException, GeneralSecurityException
keyStore - key storekeyStream - input stream to the key store file (closed at the end of this method in a
finally block)storePass - password protecting the key store filealias - alias under which the private key is storedkeyPass - password protecting the private keyIOExceptionGeneralSecurityException@Deprecated public static PrivateKey loadFromPk8File(File file) throws IOException, GeneralSecurityException
loadFromPkcs8PemFile(java.io.File) instead. Note
that the file formatting requirements for loadFromPkcs8PemFile(java.io.File) are
stricter than this method's requirements.PKCS#8 format private key from a given file.IOExceptionGeneralSecurityExceptionpublic static byte[] readFromPemFormattedFile(File file) throws IOException, GeneralSecurityException
PEM formatted private key from a given file.
This supports any file if and only if it contains a DER and Base64 encoded key, and the contents are enclosed by the following:
-----BEGIN PRIVATE KEY----- -----END PRIVATE KEY-----
The file may contain additional content outside of the BEGIN and END tags, but it will be ignored. This method does not support additional content such as headers inside the BEGIN and END tags. If the file contains multiple BEGIN and END tags, only the content inside the first pair will be read.
IOExceptionGeneralSecurityExceptionpublic static PrivateKey loadFromPkcs8PemFile(File pemFile) throws IOException, GeneralSecurityException
PEM formatted PKCS8 encoded private key from a given file.
This method uses readFromPemFormattedFile(java.io.File), and the file formatting requirements from
that method apply.
IOExceptionGeneralSecurityExceptionpublic static PrivateKey loadFromP12File(File p12File, String storePass, String alias, String keyPass) throws GeneralSecurityException, IOException
PKCS#12 format private key from a given file.p12File - p12 filestorePass - password protecting the key store filealias - alias under which the private key is storedkeyPass - password protecting the private keyGeneralSecurityExceptionIOExceptionCopyright © 2011-2012 Google. All Rights Reserved.