Class DefaultJWTParser

java.lang.Object
io.smallrye.jwt.auth.principal.DefaultJWTParser
All Implemented Interfaces:
JWTParser

@ApplicationScoped public class DefaultJWTParser extends Object implements JWTParser
A default implementation of JWTParser.
  • Constructor Details

  • Method Details

    • parse

      public org.eclipse.microprofile.jwt.JsonWebToken parse(String bearerToken) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be verified or decrypted or decrypted and then verified and converted to JsonWebToken. This method depends on the injected JWTAuthContextInfo configuration context.
      Specified by:
      parse in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • parse

      public org.eclipse.microprofile.jwt.JsonWebToken parse(String bearerToken, JWTAuthContextInfo newAuthContextInfo) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be verified or decrypted or decrypted and then verified and converted to JsonWebToken.
      Specified by:
      parse in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      newAuthContextInfo - the configuration context which will override the injected JWTAuthContextInfo configuration context.
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • verify

      public org.eclipse.microprofile.jwt.JsonWebToken verify(String bearerToken, PublicKey key) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be verified and converted to JsonWebToken.
      Specified by:
      verify in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      key - the public verification key. The injected JWTAuthContextInfo configuration context will be reused, only its publicVerificationKey property will be replaced by this parameter.
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • verify

      public org.eclipse.microprofile.jwt.JsonWebToken verify(String bearerToken, SecretKey key) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be verified and converted to JsonWebToken.
      Specified by:
      verify in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      key - the secret verification key. The injected JWTAuthContextInfo configuration context will be reused, only its secretVerificationKey property will be replaced by this parameter.
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • verify

      public org.eclipse.microprofile.jwt.JsonWebToken verify(String bearerToken, String secret) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be verified and converted to JsonWebToken.
      Specified by:
      verify in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      secret - the secret. The injected JWTAuthContextInfo configuration context will be reused, only its secretVerificationKey property will be replaced after converting this parameter to SecretKey.
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • decrypt

      public org.eclipse.microprofile.jwt.JsonWebToken decrypt(String bearerToken, PrivateKey key) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be decrypted and converted to JsonWebToken.
      Specified by:
      decrypt in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      key - the private decryption key. The injected JWTAuthContextInfo configuration context will be reused, only its privateDecryptionkey property will be replaced by this parameter.
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • decrypt

      public org.eclipse.microprofile.jwt.JsonWebToken decrypt(String bearerToken, SecretKey key) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be decrypted and converted to JsonWebToken.
      Specified by:
      decrypt in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      key - the secret decryption key. The injected JWTAuthContextInfo configuration context will be reused, only its secretDecryptionkey property will be replaced by this parameter.
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • decrypt

      public org.eclipse.microprofile.jwt.JsonWebToken decrypt(String bearerToken, String secret) throws ParseException
      Description copied from interface: JWTParser
      Parse JWT token. The token will be decrypted and converted to JsonWebToken.
      Specified by:
      decrypt in interface JWTParser
      Parameters:
      bearerToken - the JWT token
      secret - the secret. The injected JWTAuthContextInfo configuration context will be reused, only its secretDecryptionkey property will be replaced will be replaced after converting this parameter to SecretKey.
      Returns:
      JsonWebToken
      Throws:
      ParseException - parse exception
    • parseOnly

      public org.eclipse.microprofile.jwt.JsonWebToken parseOnly(String token) throws ParseException
      Description copied from interface: JWTParser
      Parse an already verified signed JWT token. Use this method only if the token has been verified by the secure gateway or other systems.
      Specified by:
      parseOnly in interface JWTParser
      Throws:
      ParseException