Class SimpleTokenUtils

java.lang.Object
org.eclipse.microprofile.jwt.tck.config.SimpleTokenUtils

public class SimpleTokenUtils extends Object
Scaled down version of tck TokenUtils that has no JWT library dependencies so that it can be embedded in the tck wars without needing a JWT library on the server side.
  • Method Details

    • decodePrivateKey

      public static PrivateKey decodePrivateKey(String pemEncoded) throws Exception
      Decode a PEM encoded private key string to an RSA PrivateKey
      Parameters:
      pemEncoded - - PEM string for private key
      Returns:
      PrivateKey
      Throws:
      Exception - on decode failure
    • decodePublicKey

      public static RSAPublicKey decodePublicKey(String pemEncoded) throws Exception
      Decode a PEM encoded public key string to an RSA PublicKey
      Parameters:
      pemEncoded - - PEM string for public key
      Returns:
      RSAPublicKey
      Throws:
      Exception - on decode failure
    • decodeECPublicKey

      public static ECPublicKey decodeECPublicKey(String pemEncoded) throws Exception
      Decode a PEM encoded public key string to an EC PublicKey
      Parameters:
      pemEncoded - - PEM string for public key
      Returns:
      ECPublicKey
      Throws:
      Exception - on decode failure
    • decodeJWKSPublicKey

      public static RSAPublicKey decodeJWKSPublicKey(String jwksValue) throws Exception
      Decode a JWK(S) encoded public key string to an RSA PublicKey
      Parameters:
      jwksValue - - JWKS string value
      Returns:
      RSAPublicKey from RSAPublicKeySpec
      Throws:
      Exception
    • decodeJWKSPrivateKey

      public static PrivateKey decodeJWKSPrivateKey(String jwksValue) throws Exception
      Decode a JWK(S) encoded private key string to an RSA PrivateKey
      Parameters:
      jwksValue - - JWKS string value
      Returns:
      PrivateKey from RSAPrivateKeySpec
      Throws:
      Exception
    • readResource

      public static String readResource(String resName) throws IOException
      Read a classpath resource into a string and return it.
      Parameters:
      resName - - classpath resource name
      Returns:
      the resource content as a string
      Throws:
      IOException - - on failure