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.

These classes are marked public but should be treated effectively as internal classes only. They are not subject to any backwards compatibility guarantees and might change or be removed at any time. They are provided only as a convenience for other libraries within the com.google.auth family. Application developers should avoid using these classes directly; they are not part of the public API.

  • 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: