Class PEMEncoder

java.lang.Object
io.fusionauth.pem.PEMEncoder

public class PEMEncoder extends Object
Encode a PrivateKey or PublicKey into a PEM formatted string.
Author:
Daniel DeGroff
  • Constructor Details

    • PEMEncoder

      public PEMEncoder()
  • Method Details

    • parseEncodedCertificate

      public String parseEncodedCertificate(String derEncoded)
      Attempt to covert a ASN.1 DER encoded X.509 certificate into a PEM encoded string.
      Parameters:
      derEncoded - base64 ASN.1 DER encoded bytes of an X.509 certificate
      Returns:
      a PEM encoded certificate
    • encode

      public String encode(PrivateKey privateKey, PublicKey publicKey)
      Encode the provided keys in a PEM format and return a string. If both private and public keys are provided a private key PEM will be returned with the public key embedded.

      If null is passed for one of the two parameters, a PEM will be returned that only includes the non-null value.

      Both values may no be null.

      Parameters:
      privateKey - the private key
      publicKey - the public key
      Returns:
      a PEM Encoded key
    • encode

      public String encode(Key key)
      Encode the provided key in a PEM format and return a string.

      Both values may no be null.

      Parameters:
      key - the key, this parameter may be of type PrivateKey PublicKey
      Returns:
      a PEM encoded key
    • encode

      public String encode(Certificate certificate)
      Encode the X.509 certificate in a PEM format and return a string.
      Parameters:
      certificate - The certificate
      Returns:
      a PEM encoded certificate