Class DefaultIntrospectionProcessor<T>
java.lang.Object
io.micronaut.security.endpoints.introspection.DefaultIntrospectionProcessor<T>
- Type Parameters:
T- Request
- All Implemented Interfaces:
IntrospectionProcessor<T>
@Singleton
public class DefaultIntrospectionProcessor<T>
extends Object
implements IntrospectionProcessor<T>
Validates the
IntrospectionRequest.getToken() with the available TokenValidator.
Then it creates a IntrospectionResponse with the first Authentication object.
If no TokenValidator is able to validate the token, it tries with RefreshTokenValidator.
If it cannot authenticate it returns {active: false}- Since:
- 2.1.0
- Author:
- Sergio del Amo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final org.slf4j.Loggerstatic final Stringprotected final RefreshTokenValidatorstatic final Stringstatic final Stringstatic final Stringprotected final TokenConfigurationprotected final Collection<TokenValidator<T>> static final String -
Constructor Summary
ConstructorsConstructorDescriptionDefaultIntrospectionProcessor(Collection<TokenValidator<T>> tokenValidators, TokenConfiguration tokenConfiguration, @Nullable RefreshTokenValidator refreshTokenValidator) -
Method Summary
Modifier and TypeMethodDescription@NonNull IntrospectionResponsecreateIntrospectionResponse(@NonNull Authentication authentication, @NonNull T requestContext) Creates anIntrospectionResponsefor anAuthentication.protected @NonNull IntrospectionResponseemptyIntrospectionResponse(@NonNull String token) Empty response for introspection response.@NonNull org.reactivestreams.Publisher<IntrospectionResponse> introspect(@NonNull Authentication authentication, @NonNull T requestContext) @NonNull org.reactivestreams.Publisher<IntrospectionResponse> introspect(@NonNull IntrospectionRequest introspectionRequest, @NonNull T requestContext) resolveAud(@NonNull Authentication authentication) Populates the introspection response with aud claim.resolveClientId(@NonNull Authentication authentication) Populates the introspection response client_id.resolveExpiration(@NonNull Authentication authentication) Populates the introspection response with the exp claim of authentication.resolveExtensions(@NonNull Authentication authentication) resolveIssuedAt(@NonNull Authentication authentication) Populates the introspection response with the iat claim of authentication.resolveIssuer(@NonNull Authentication authentication) Populates the introspection response with iss claim.resolveJwtId(@NonNull Authentication authentication) Populates the introspection response with jti username.resolveNotBefore(@NonNull Authentication authentication) Populates the introspection response with the nbf claim of authentication.resolveScope(@NonNull Authentication authentication) Populates the introspection response scope.protected @NonNull StringresolveSub(@NonNull Authentication authentication) Populates the introspection response with sub claim.resolveTokenType(@NonNull Authentication authentication) Populates the introspection response token type.resolveUsername(@NonNull Authentication authentication) Populates the introspection response with the username.secondsSinceEpochOfAttribute(@NonNull String attributeName, @NonNull Authentication authentication) static longtoSecondsSinceEpoch(Date date)
-
Field Details
-
CLIENT_ID
- See Also:
-
USERNAME
- See Also:
-
TOKEN_TYPE
- See Also:
-
ISSUER
- See Also:
-
SUBJECT
- See Also:
-
EXP
- See Also:
-
NOT_BEFORE
- See Also:
-
ISSUED_AT
- See Also:
-
JWT_ID
- See Also:
-
AUDIENCE
- See Also:
-
SCOPE
- See Also:
-
FIELDS_ATTRIBUTE_NAMES
-
LOG
protected static final org.slf4j.Logger LOG -
tokenValidators
-
tokenConfiguration
-
refreshTokenValidator
-
-
Constructor Details
-
DefaultIntrospectionProcessor
public DefaultIntrospectionProcessor(Collection<TokenValidator<T>> tokenValidators, TokenConfiguration tokenConfiguration, @Nullable RefreshTokenValidator refreshTokenValidator)
-
-
Method Details
-
introspect
public @NonNull org.reactivestreams.Publisher<IntrospectionResponse> introspect(@NonNull IntrospectionRequest introspectionRequest, @NonNull T requestContext) - Specified by:
introspectin interfaceIntrospectionProcessor<T>- Parameters:
introspectionRequest- A parameter representing the token along with optional parameters representing additional contextrequestContext- HTTP Request- Returns:
- Introspection Response
-
emptyIntrospectionResponse
Empty response for introspection response.- Parameters:
token- Token- Returns:
- Introspection Response
-
introspect
public @NonNull org.reactivestreams.Publisher<IntrospectionResponse> introspect(@NonNull Authentication authentication, @NonNull T requestContext) - Specified by:
introspectin interfaceIntrospectionProcessor<T>- Parameters:
authentication- The authenticationrequestContext- HTTP Request- Returns:
- Introspection Response
-
createIntrospectionResponse
public @NonNull IntrospectionResponse createIntrospectionResponse(@NonNull Authentication authentication, @NonNull T requestContext) Creates anIntrospectionResponsefor anAuthentication.- Parameters:
authentication- AuthenticationrequestContext- HTTP Request- Returns:
- an
IntrospectionResponse
-
resolveExtensions
- Parameters:
authentication- Authentication- Returns:
- Introspection response extensions
-
resolveScope
Populates the introspection response scope.- Parameters:
authentication- Authentication- Returns:
- the scope
-
resolveTokenType
Populates the introspection response token type.- Parameters:
authentication- Authentication- Returns:
- the Token type
-
resolveClientId
Populates the introspection response client_id.- Parameters:
authentication- Authentication- Returns:
- client_id value
-
resolveAud
Populates the introspection response with aud claim.- Parameters:
authentication- Authentication- Returns:
- value of aud claim
-
resolveSub
Populates the introspection response with sub claim.- Parameters:
authentication- Authentication- Returns:
- value of sub claim
-
resolveIssuer
Populates the introspection response with iss claim.- Parameters:
authentication- Authentication- Returns:
- value of iss claim
-
resolveJwtId
Populates the introspection response with jti username.- Parameters:
authentication- Authentication- Returns:
- the jti claim value
-
resolveUsername
Populates the introspection response with the username.- Parameters:
authentication- Authentication- Returns:
- the username
-
resolveExpiration
Populates the introspection response with the exp claim of authentication.- Parameters:
authentication- Authentication- Returns:
- the exp claim
-
secondsSinceEpochOfAttribute
protected Optional<Long> secondsSinceEpochOfAttribute(@NonNull String attributeName, @NonNull Authentication authentication) - Parameters:
attributeName- The attribute name e.g. exp nbf iatauthentication- Authentication- Returns:
- An empty optional if the authentication attribute is not found or it cannot be transformed to epoch seconds
-
resolveNotBefore
Populates the introspection response with the nbf claim of authentication.- Parameters:
authentication- Authentication- Returns:
- value for nbf claim
-
resolveIssuedAt
Populates the introspection response with the iat claim of authentication.- Parameters:
authentication- Authentication- Returns:
- value for iat claim
-
toSecondsSinceEpoch
- Parameters:
date- Date- Returns:
- seconds since epoch
-