Package org.wildfly.security.http.oidc
Class TokenValidator
- java.lang.Object
-
- org.wildfly.security.http.oidc.TokenValidator
-
public class TokenValidator extends Object
Validator for an ID token or bearer token, as per OpenID Connect Core 1.0 and RFC 7523.- Author:
- Farah Juma
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classTokenValidator.AtHashValidatorprivate static classTokenValidator.AzpValidatorstatic classTokenValidator.Builderprivate static classTokenValidator.TypeValidatorstatic classTokenValidator.VerifiedTokens
-
Field Summary
Fields Modifier and Type Field Description private OidcClientConfigurationclientConfigurationprivate static intHEADER_INDEXprivate org.jose4j.jwt.consumer.JwtConsumerBuilderjwtConsumerBuilder
-
Constructor Summary
Constructors Modifier Constructor Description privateTokenValidator(TokenValidator.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TokenValidator.Builderbuilder(OidcClientConfiguration clientConfiguration)Construct a new builder instance.private static StringgetAccessTokenHash(String accessTokenString, String jwsAlgorithm)AccessTokenparseAndVerifyToken(String bearerToken)Parse and verify the given bearer token.TokenValidator.VerifiedTokensparseAndVerifyToken(String idToken, String accessToken)Parse and verify the given ID token.private org.jose4j.jwt.consumer.JwtContextsetVerificationKey(String token, org.jose4j.jwt.consumer.JwtConsumerBuilder jwtConsumerBuilder)
-
-
-
Field Detail
-
HEADER_INDEX
private static final int HEADER_INDEX
- See Also:
- Constant Field Values
-
jwtConsumerBuilder
private org.jose4j.jwt.consumer.JwtConsumerBuilder jwtConsumerBuilder
-
clientConfiguration
private OidcClientConfiguration clientConfiguration
-
-
Constructor Detail
-
TokenValidator
private TokenValidator(TokenValidator.Builder builder)
-
-
Method Detail
-
parseAndVerifyToken
public TokenValidator.VerifiedTokens parseAndVerifyToken(String idToken, String accessToken) throws OidcException
Parse and verify the given ID token.- Parameters:
idToken- the ID token- Returns:
- the
VerifiedTokensif the ID token was valid - Throws:
OidcException- if the ID token is invalid
-
parseAndVerifyToken
public AccessToken parseAndVerifyToken(String bearerToken) throws OidcException
Parse and verify the given bearer token.- Parameters:
bearerToken- the bearer token- Returns:
- the
AccessTokenif the bearer token was valid - Throws:
OidcException- if the bearer token is invalid
-
setVerificationKey
private org.jose4j.jwt.consumer.JwtContext setVerificationKey(String token, org.jose4j.jwt.consumer.JwtConsumerBuilder jwtConsumerBuilder) throws org.jose4j.jwt.consumer.InvalidJwtException
- Throws:
org.jose4j.jwt.consumer.InvalidJwtException
-
builder
public static TokenValidator.Builder builder(OidcClientConfiguration clientConfiguration)
Construct a new builder instance.- Parameters:
clientConfiguration- the OIDC client configuration- Returns:
- the new builder instance
-
getAccessTokenHash
private static String getAccessTokenHash(String accessTokenString, String jwsAlgorithm) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
-