Class PEMFileRSAPrivateKeySupplier
- java.lang.Object
-
- com.oracle.bmc.http.signing.internal.PEMFileRSAPrivateKeySupplier
-
- All Implemented Interfaces:
KeySupplier<RSAPrivateKey>
public class PEMFileRSAPrivateKeySupplier extends Object implements KeySupplier<RSAPrivateKey>
An implementation ofKeySupplier
that supplies a RSA private key from a PEM file.Supports PKCS#8 (starts with ‘—–BEGIN PRIVATE KEY—–’ tag), PKCS#8 encrypted key (starts with ‘—–BEGIN ENCRYPTED PRIVATE KEY—–’ tag) and PKCS#1 (i.e., starts with ‘—–BEGIN RSA PRIVATE KEY—–’ tag) format.
Example commands that can be used to generate a 2048 bits RSA private key:
$ openssl genrsa -out privateKey 2048
$ ssh-keygen -t rsa -b 2048
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PEMFileRSAPrivateKeySupplier.PEMFileRSAPrivateKeySupplierException
An exception in thePEMFileRSAPrivateKeySupplier
.
-
Constructor Summary
Constructors Constructor Description PEMFileRSAPrivateKeySupplier(InputStream inputStream, char[] passphraseCharacters)
Constructs a new file key supplier which reads the private key from the specified file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<RSAPrivateKey>
supplyKey()
Get the key from the file.Optional<RSAPrivateKey>
supplyKey(String ignored)
Get the key from the file.
-
-
-
Constructor Detail
-
PEMFileRSAPrivateKeySupplier
public PEMFileRSAPrivateKeySupplier(@Nonnull InputStream inputStream, @Nullable char[] passphraseCharacters)
Constructs a new file key supplier which reads the private key from the specified file.The provided stream will be closed by this supplier automatically.
- Parameters:
inputStream
- the path to the RSA private keypassphraseCharacters
- the passphrase of the private key, optional
-
-
Method Detail
-
supplyKey
public Optional<RSAPrivateKey> supplyKey(@Nonnull String ignored)
Get the key from the file.- Specified by:
supplyKey
in interfaceKeySupplier<RSAPrivateKey>
- Parameters:
ignored
- this parameter is ignored. The key returned is always the same, the one from the file.- Returns:
- an Optional for the key
-
supplyKey
@Nonnull public Optional<RSAPrivateKey> supplyKey()
Get the key from the file.- Returns:
- an Optional for the key
-
-