org.keycloak.util

## Class PemUtils

- java.lang.Object
- - org.keycloak.util.PemUtils

-     public final class PemUtils
      extends Object

  Utility classes to extract PublicKey, PrivateKey, and X509Certificate from openssl generated PEM files
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static X509Certificate` | `decodeCertificate(InputStream is)`
    `static X509Certificate` | `decodeCertificate(String cert)`
    `static PrivateKey` | `decodePrivateKey(InputStream is)`
    `static PrivateKey` | `decodePrivateKey(String pem)` Extract a private key that is a PKCS8 pem string (base64 encoded PKCS8)
    `static PublicKey` | `decodePublicKey(String pem)` Extract a public key from a PEM string
    `static String` | `pemFromStream(InputStream is)`
    `static byte[]` | `pemToDer(InputStream is)` Decode a PEM file to DER format
    `static byte[]` | `pemToDer(String pem)` Decode a PEM string to DER format
    `static String` | `removeBeginEnd(String pem)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### decodeCertificate

          public static X509Certificate decodeCertificate(InputStream is)
                                                   throws Exception

      Throws:
        `Exception`

    - #### decodeCertificate

          public static X509Certificate decodeCertificate(String cert)
                                                   throws Exception

      Throws:
        `Exception`

    - #### decodePublicKey

          public static PublicKey decodePublicKey(String pem)
                                           throws Exception

      Extract a public key from a PEM string
      Parameters:
        `pem` -
      Returns:
      Throws:
        `Exception`

    - #### decodePrivateKey

          public static PrivateKey decodePrivateKey(String pem)
                                             throws Exception

      Extract a private key that is a PKCS8 pem string (base64 encoded PKCS8)
      Parameters:
        `pem` -
      Returns:
      Throws:
        `Exception`

    - #### decodePrivateKey

          public static PrivateKey decodePrivateKey(InputStream is)
                                             throws Exception

      Throws:
        `Exception`

    - #### pemToDer

          public static byte[] pemToDer(InputStream is)
                                 throws IOException

      Decode a PEM file to DER format
      Parameters:
        `is` -
      Returns:
      Throws:
        `IOException`

    - #### pemToDer

          public static byte[] pemToDer(String pem)
                                 throws IOException

      Decode a PEM string to DER format
      Parameters:
        `pem` -
      Returns:
      Throws:
        `IOException`

    - #### removeBeginEnd

          public static String removeBeginEnd(String pem)

    - #### pemFromStream

          public static String pemFromStream(InputStream is)
                                      throws IOException

      Throws:
        `IOException`

Copyright © 2015. All Rights Reserved.