Class PEMParsers


  • public class PEMParsers
    extends Object

    Static factory methods used to create instances of PEMParser.

    Thread Safety:

    Instances obtained through a factory method of this class are immutable and thread-safe.

    Author:
    Tomoki Sato
    • Method Detail

      • ofStandard

        public static PEMParser ofStandard​(String label)

        Creates a new PEMParser with the given type label.

        In order to extract the content between '-----BEGIN PRIVATE KEY-----' and '-----END PRIVATE KEY-----' for example, pass 'PRIVATE KEY' to the label argument.

        This parser ignores characters outside the encapsulation boundaries (i.e. all the characters before '-----BEGIN .... -----' or after '-----END ..... -----').

        Examples:
          // Creates a parser for PEM-encoded texts
          // in which the private key data starts with '-----BEGIN PRIVATE KEY-----'
          // and ends with '-----END PRIVATE KEY-----'.
          PEMParser.ofStandard("PRIVATE KEY");
        
          // Creates a parser for PEM-encoded texts
          // in which the public key data starts with '-----BEGIN PUBLIC KEY-----'
          // and ends with '-----END PUBLIC KEY-----'.
          PEMParser.ofStandard("PUBLIC KEY");
         

        The returned PEMParser is intended to parse texts encoded in the 'Standard' format described in RFC7468.

        Parameters:
        label - a type label.
        Returns:
        a new PEMParser.
        Throws:
        IllegalArgumentException - if the format of the given label is invalid.