Class PrivateKeyReader
java.lang.Object
com.amazonaws.services.iot.client.sample.sampleUtil.PrivateKeyReader
Class for reading RSA or ECC private key from PEM file.
It can read PEM files with PKCS#8 or PKCS#1 encodings. It doesn't support
encrypted PEM files.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PrivateKeygetPrivateKey(InputStream stream, String algorithm) Get a Private Key for the file.static PrivateKeygetPrivateKey(String fileName) Get a RSA Private Key from InputStream.static PrivateKeygetPrivateKey(String fileName, String algorithm) Get a Private Key from InputStream.
-
Field Details
-
P1_BEGIN_MARKER
- See Also:
-
P1_END_MARKER
- See Also:
-
P8_BEGIN_MARKER
- See Also:
-
P8_END_MARKER
- See Also:
-
-
Constructor Details
-
PrivateKeyReader
public PrivateKeyReader()
-
-
Method Details
-
getPrivateKey
public static PrivateKey getPrivateKey(String fileName) throws IOException, GeneralSecurityException Get a RSA Private Key from InputStream.- Parameters:
fileName- file name- Returns:
- Private key
- Throws:
IOException- IOException resulted from invalid file IOGeneralSecurityException- GeneralSecurityException resulted from invalid key format
-
getPrivateKey
public static PrivateKey getPrivateKey(String fileName, String algorithm) throws IOException, GeneralSecurityException Get a Private Key from InputStream.- Parameters:
fileName- file namealgorithm- the name of the key algorithm, for example "RSA" or "EC"- Returns:
- Private key
- Throws:
IOException- IOException resulted from invalid file IOGeneralSecurityException- GeneralSecurityException resulted from invalid key data
-
getPrivateKey
public static PrivateKey getPrivateKey(InputStream stream, String algorithm) throws IOException, GeneralSecurityException Get a Private Key for the file.- Parameters:
stream- InputStream objectalgorithm- the name of the key algorithm, for example "RSA" or "EC"- Returns:
- Private key
- Throws:
IOException- IOException resulted from invalid file IOGeneralSecurityException- GeneralSecurityException resulted from invalid key data
-