Class PemObject

java.lang.Object
org.springframework.vault.support.PemObject

public class PemObject extends Object
Represents a PEM object that is internally decoded to a DER object. Typically, used to obtain a RSAPrivateCrtKeySpec.

Mainly for use within the framework.

Since:
2.2
Author:
Mark Paluch
  • Method Details

    • isPemEncoded

      public static boolean isPemEncoded(String content)
      Check whether the content is PEM-encoded.
      Parameters:
      content - the content to inspect
      Returns:
      true if PEM-encoded.
    • fromKey

      public static PemObject fromKey(String content)
      Create a PemObject from PEM content that is enclosed with -BEGIN PRIVATE KEY- and -END PRIVATE KEY-. This method returns either the first PEM object ot throws IllegalArgumentException of no object could be found.
      Parameters:
      content - the PEM content.
      Returns:
      the PemObject from PEM content.
      Throws:
      IllegalArgumentException - if no PEM object could be found.
    • parseFirst

      public static PemObject parseFirst(String content)
      Create a PemObject from PEM content that is enclosed with -BEGIN PRIVATE KEY- or -BEGIN PUBLIC KEY-. This method returns either the first PEM object ot throws IllegalArgumentException of no object could be found.
      Parameters:
      content - the PEM content.
      Returns:
      the PemObject from PEM content.
      Throws:
      IllegalArgumentException - if no PEM object could be found.
      Since:
      2.3
    • parse

      public static List<PemObject> parse(String content)
      Create one or more PemObjects from PEM content. Accepts concatenated PEM objects.
      Parameters:
      content - the PEM content.
      Returns:
      the list of PemObject from PEM content.
      Since:
      2.3
    • isCertificate

      public boolean isCertificate()
      Returns:
      true if the object was identified to contain a private key.
      Since:
      2.3
    • isPrivateKey

      public boolean isPrivateKey()
      Returns:
      true if the object was identified to contain a private key.
      Since:
      2.3
    • isPublicKey

      public boolean isPublicKey()
      Returns:
      true if the object was identified to contain a public key.
      Since:
      2.3
    • getCertificate

      public X509Certificate getCertificate()
      Retrieve a X509Certificate.
      Returns:
      the X509Certificate.
      Since:
      2.3
    • getCertificates

      public List<X509Certificate> getCertificates()
      Retrieve one or more X509Certificates.
      Returns:
      the X509Certificates.
      Since:
      2.4
    • getRSAPrivateKeySpec

      public RSAPrivateCrtKeySpec getRSAPrivateKeySpec()
      Returns:
      the RSAPrivateCrtKeySpec.
      Since:
      2.3
    • getRSAPublicKeySpec

      public RSAPublicKeySpec getRSAPublicKeySpec()
      Returns:
      the RSAPrivateCrtKeySpec.