Class Pem.Encoder

java.lang.Object
oracle.nosql.driver.iam.pki.Pem.Encoder
Enclosing class:
Pem

public static class Pem.Encoder extends Object
Encode certificates, public keys and private keys into PEM encoded format
  • Method Details

    • 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 stream
      privateKey - 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 stream
      publicKey - 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 stream
      certificate - The certificate
      Returns:
      the channel
      Throws:
      IOException - if an error occurs writing to the stream