Class ApplePrivateKeyParser

java.lang.Object
com.irurueta.authserver.authorization.api.web.social.ApplePrivateKeyParser

@Component public class ApplePrivateKeyParser extends Object
Reads the private key Apple issues for Sign in with Apple (an EC P-256 key in PKCS#8 PEM form, the content of the .p8 file) from the text an environment variable holds, where line breaks are often written as a literal \n. The error never repeats the key.
  • Field Details

    • P256_ORDER_BITS

      static final int P256_ORDER_BITS
      Bits of the order of the P-256 curve Apple's ES256 keys use.
      See Also:
  • Constructor Details

    • ApplePrivateKeyParser

      public ApplePrivateKeyParser()
  • Method Details

    • parse

      public ECPrivateKey parse(String pem)
      Parses a key.
      Parameters:
      pem - PKCS#8 PEM text of the key, with or without the header and footer lines.
      Returns:
      the private key.
      Throws:
      IllegalArgumentException - if the text is not a PKCS#8 EC P-256 private key.
    • notAKey

      private static String notAKey()
      Builds the message of a refused key.
      Returns:
      the message.