Class StepUpChallengeMapper
java.lang.Object
com.irurueta.authserver.bff.infrastructure.resourceserver.StepUpChallengeMapper
Maps the
WWW-Authenticate challenge of a 401 answer of the resource server onto the domain: a bearer
challenge with error="insufficient_user_authentication" (RFC 9470) becomes a
DocumentsStepUpRequiredException carrying its acr_values and max_age. Any other challenge, or
none, is not a step-up request.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringName of the parameter carrying the authentication context classes asked for.private static final StringAuthentication scheme of the challenge.private static final StringName of the error parameter of the challenge.(package private) static final StringError code of a step-up challenge (RFC 9470, section 3).private static final StringName of the parameter carrying the maximum age of the authentication, in seconds.private static final intGroup ofPARAMETERholding the parameter name.private static final PatternOne auth-param of the challenge: a name and a quoted string (with escapes) or a bare token.private static final PatternEscape sequence of a quoted string: a backslash and the character it protects.private static final intGroup ofPARAMETERholding a quoted value, without its quotes.private static final intGroup ofPARAMETERholding a bare token value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanTells whether a challenge is of the bearer scheme.private static DurationReads themax_ageparameter.parameters(String challenge) Reads the auth-params of a bearer challenge.toException(org.springframework.http.HttpHeaders headers, Throwable cause) Reads the step-up request of a401answer, if it is one.
-
Field Details
-
INSUFFICIENT_USER_AUTHENTICATION
Error code of a step-up challenge (RFC 9470, section 3).- See Also:
-
BEARER
Authentication scheme of the challenge.- See Also:
-
ERROR
Name of the error parameter of the challenge.- See Also:
-
ACR_VALUES
Name of the parameter carrying the authentication context classes asked for.- See Also:
-
MAX_AGE
Name of the parameter carrying the maximum age of the authentication, in seconds.- See Also:
-
PARAMETER
One auth-param of the challenge: a name and a quoted string (with escapes) or a bare token. -
NAME_GROUP
private static final int NAME_GROUPGroup ofPARAMETERholding the parameter name.- See Also:
-
QUOTED_VALUE_GROUP
private static final int QUOTED_VALUE_GROUPGroup ofPARAMETERholding a quoted value, without its quotes.- See Also:
-
TOKEN_VALUE_GROUP
private static final int TOKEN_VALUE_GROUPGroup ofPARAMETERholding a bare token value.- See Also:
-
QUOTED_PAIR
Escape sequence of a quoted string: a backslash and the character it protects.
-
-
Constructor Details
-
StepUpChallengeMapper
public StepUpChallengeMapper()
-
-
Method Details
-
toException
public Optional<DocumentsStepUpRequiredException> toException(org.springframework.http.HttpHeaders headers, Throwable cause) Reads the step-up request of a401answer, if it is one.- Parameters:
headers- headers of the answer;nullwhen it had none.cause- the failure to keep as the cause of the domain exception.- Returns:
- the step-up request, or empty when the answer carries no step-up challenge.
-
isBearer
Tells whether a challenge is of the bearer scheme.- Parameters:
challenge- value of aWWW-Authenticateheader.- Returns:
truewhen its scheme isBearer, in any case.
-
parameters
Reads the auth-params of a bearer challenge.- Parameters:
challenge- value of aWWW-Authenticateheader of the bearer scheme.- Returns:
- the parameters by lower-case name; a repeated parameter keeps its first value.
-
maxAgeOf
Reads themax_ageparameter.- Parameters:
value- the parameter, in seconds;nullwhen absent.- Returns:
- the maximum age, or
nullwhen absent, not a number or negative.
-