Class OAuth2Utils

java.lang.Object
com.google.auth.oauth2.OAuth2Utils

@InternalApi public class OAuth2Utils extends Object
Internal utilities for the com.google.auth.oauth2 namespace.
  • Field Details

  • Method Details

    • privateKeyFromPkcs8

      public static PrivateKey privateKeyFromPkcs8(String privateKeyPkcs8) throws IOException
      Converts a PKCS#8 string to an RSA private key.
      Parameters:
      privateKeyPkcs8 - the PKCS#8 string.
      Returns:
      the RSA private key.
      Throws:
      IOException - if the PKCS#8 data is invalid or if an unexpected exception occurs during key creation.
    • privateKeyFromPkcs8

      public static PrivateKey privateKeyFromPkcs8(String privateKeyPkcs8, com.google.auth.oauth2.OAuth2Utils.Pkcs8Algorithm algorithm) throws IOException
      Reads a private key from a PKCS#8 encoded string.

      If the key is labeled with "-----BEGIN PRIVATE KEY-----", it is parsed as PKCS#8 as per RFC 7468 Section 10.

      Parameters:
      privateKeyPkcs8 - base64 encoded private key string
      algorithm - expected algorithm of the private key
      Returns:
      the private key.
      Throws:
      IOException - if the private key data is invalid or if an unexpected exception occurs during key creation.
      See Also: