Package com.oracle.bmc.http.client.pki
Class Pem.Encoder
- java.lang.Object
-
- com.oracle.bmc.http.client.pki.Pem.Encoder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringencode(Iterable<? extends Certificate> certificates)Render a certificate chain in PEM formatStringencode(Certificate certificate)Render a certificate in PEM formatbyte[]encode(PrivateKey privateKey)Render a private key in PEM format.Stringencode(PublicKey publicKey)Render a public key in PEM format using PKCS1Pem.Encoderwith(Pem.Encryption encryption)Configure an encoder to produce encrypted private keys.Pem.Encoderwith(Pem.Format format)Configure a new instance with the specified PKCS format.Pem.Encoderwith(Pem.Passphrase passphrase)Configure an encoder to produce encrypted private keys.WritableByteChannelwrite(WritableByteChannel output, Certificate certificate)Write a certificate to a byte streamWritableByteChannelwrite(WritableByteChannel output, PrivateKey privateKey)Write a private key to a byte streamWritableByteChannelwrite(WritableByteChannel output, PublicKey publicKey)Write a public key to a byte stream
-
-
-
Method Detail
-
with
public Pem.Encoder with(Pem.Format format)
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
public Pem.Encoder with(Pem.Encryption encryption)
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
public Pem.Encoder with(Pem.Passphrase passphrase)
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
public String encode(PublicKey publicKey)
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
public String encode(Certificate certificate)
Render a certificate in PEM format- Parameters:
certificate- The certificate- Returns:
- PEM encoding of the certificate
-
encode
public String encode(Iterable<? extends Certificate> certificates)
Render a certificate chain in PEM format- Parameters:
certificates- The certificates- Returns:
- PEM encoding of the certificate chain
-
encode
public byte[] encode(PrivateKey privateKey)
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- 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- 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- Throws:
IOException- if an error occurs writing to the stream
-
-