Package oracle.nosql.driver.iam.pki
Class Pem.Encoder
java.lang.Object
oracle.nosql.driver.iam.pki.Pem.Encoder
- Enclosing class:
- Pem
Encode certificates, public keys and private keys into PEM encoded format
-
Method Summary
Modifier and TypeMethodDescriptionencode
(Iterable<? extends Certificate> certificates) Render a certificate chain in PEM formatencode
(Certificate certificate) Render a certificate in PEM formatbyte[]
encode
(PrivateKey privateKey) Render a private key in PEM format.Render a public key in PEM format using PKCS1with
(Pem.Encryption encryption) Configure an encoder to produce encrypted private keys.with
(Pem.Format format) Configure a new instance with the specified PKCS format.with
(Pem.Passphrase passphrase) Configure an encoder to produce encrypted private keys.write
(WritableByteChannel output, Certificate certificate) Write a certificate to a byte streamwrite
(WritableByteChannel output, PrivateKey privateKey) Write a private key to a byte streamwrite
(WritableByteChannel output, PublicKey publicKey) Write a public key to a byte stream
-
Method Details
-
with
Configure a new instance with the specified PKCS format. Note that the format applies to private and public keys only. Certificates always use X509 PEM encoding.- Parameters:
format
- The encoding format for public and private keys- Returns:
- Encoder instance
-
with
Configure an encoder to produce encrypted private keys.Encryption does not apply to public keys or certificates
- Parameters:
encryption
- The encryption configuration, or null if no encryption is required- Returns:
- Encoder instance
-
with
Configure an encoder to produce encrypted private keys.Encryption does not apply to public keys or certificates
- Parameters:
passphrase
- The encryption passphrase, or null if no encryption is required- Returns:
- Encoder instance
-
encode
Render a public key in PEM format using PKCS1- Parameters:
publicKey
- The public key- Returns:
- PEM encoding of the public key in PKCS1 format
-
encode
Render a certificate in PEM format- Parameters:
certificate
- The certificate- Returns:
- PEM encoding of the certificate
-
encode
Render a certificate chain in PEM format- Parameters:
certificates
- The certificates- Returns:
- PEM encoding of the certificate chain
-
encode
Render a private key in PEM format. The private key is sensitive data and is returned as a byte array. The caller is responsible for erasing the byte array after use.- Parameters:
privateKey
- The private key- Returns:
- The PEM encoded private key as UTF-8 encoded bytes
-
write
public WritableByteChannel write(WritableByteChannel output, PrivateKey privateKey) throws IOException Write a private key to a byte stream- Parameters:
output
- The byte streamprivateKey
- The private key- Returns:
- the channel
- Throws:
IOException
- if an error occurs writing to the stream
-
write
public WritableByteChannel write(WritableByteChannel output, PublicKey publicKey) throws IOException Write a public key to a byte stream- Parameters:
output
- The byte streampublicKey
- The public key- Returns:
- the channel
- Throws:
IOException
- if an error occurs writing to the stream
-
write
public WritableByteChannel write(WritableByteChannel output, Certificate certificate) throws IOException Write a certificate to a byte stream- Parameters:
output
- The byte streamcertificate
- The certificate- Returns:
- the channel
- Throws:
IOException
- if an error occurs writing to the stream
-