- All Superinterfaces:
AuthTypeAccessor,AuthTypeCredentials<BearerAuthCredentials,TokenCredentials>,org.refcodes.mixin.TokenAccessor,TokenCredentials,org.refcodes.mixin.Validatable<TokenCredentials>
- All Known Implementing Classes:
BeararAuthCredentialsImpl
public interface BearerAuthCredentials extends TokenCredentials, AuthTypeCredentials<BearerAuthCredentials,TokenCredentials>
This interface defines a type for representing a Bearer-Authentication
credentials Header-Field. Parse the Header-Field via
AuthTypeCredentials.fromHttpAuthorization(String) and feed it with the header's
HeaderField.AUTHORIZATION field's value. To create the according
Header-Field's value from the BearerAuthCredentials type, call
AuthTypeCredentials.toHttpAuthorization().-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.web.AuthTypeAccessor
AuthTypeAccessor.AuthTypeBuilder<B extends AuthTypeAccessor.AuthTypeBuilder<B>>, AuthTypeAccessor.AuthTypeMutator, AuthTypeAccessor.AuthTypePropertyNested classes/interfaces inherited from interface org.refcodes.mixin.TokenAccessor
org.refcodes.mixin.TokenAccessor.TokenBuilder<B extends org.refcodes.mixin.TokenAccessor.TokenBuilder<B>>, org.refcodes.mixin.TokenAccessor.TokenMutator, org.refcodes.mixin.TokenAccessor.TokenProperty -
Field Summary
Fields Modifier and Type Field Description static charDELIMITER_AUTH_TYPE -
Method Summary
Modifier and Type Method Description default AuthTypegetAuthType()Retrieves theAuthTypefrom the Authorization-Type property (or null if there are none such credentials).default voidvalidate(String aToken)Validates the provided user-name and secret with thisBearerAuthCredentialsviaTokenCredentials.isValid(String).default voidvalidate(TokenCredentials aCredentials)Validates the providedTokenCredentialswith thisBearerAuthCredentialsviaTokenCredentials.isValid(TokenCredentials).default BearerAuthCredentialswithHttpAuthorization(String aHttpAuthorization)Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.Methods inherited from interface org.refcodes.web.AuthTypeCredentials
fromHttpAuthorization, toHttpAuthorizationMethods inherited from interface org.refcodes.mixin.TokenAccessor
getTokenMethods inherited from interface org.refcodes.web.TokenCredentials
isValid, isValid
-
Field Details
-
DELIMITER_AUTH_TYPE
static final char DELIMITER_AUTH_TYPE- See Also:
- Constant Field Values
-
-
Method Details
-
validate
Validates the providedTokenCredentialswith thisBearerAuthCredentialsviaTokenCredentials.isValid(TokenCredentials). In case the providedTokenCredentialsare not valid, then aForbiddenExceptionis thrown.- Specified by:
validatein interfaceAuthTypeCredentials<BearerAuthCredentials,TokenCredentials>- Parameters:
aCredentials- TheTokenCredentialsto be verified.- Throws:
ForbiddenException- thrown in case the providedTokenCredentialsdo not match.
-
validate
Validates the provided user-name and secret with thisBearerAuthCredentialsviaTokenCredentials.isValid(String). In case the provided credentials are not valid, then aForbiddenExceptionis thrown.- Parameters:
aToken- The secret part to be tested if it fits with the thisTokenCredentialsinstance.- Throws:
ForbiddenException- thrown in case the providedTokenCredentialsdo not match.
-
withHttpAuthorization
default BearerAuthCredentials withHttpAuthorization(String aHttpAuthorization) throws IllegalArgumentExceptionInitializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
withHttpAuthorizationin interfaceAuthTypeCredentials<BearerAuthCredentials,TokenCredentials>- Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader field's value- Returns:
- the t
- Throws:
IllegalArgumentException- The value does not conform the the HTTP Authorization Header-Field's Basic-Authentication format.
-
getAuthType
Retrieves theAuthTypefrom the Authorization-Type property (or null if there are none such credentials).- Specified by:
getAuthTypein interfaceAuthTypeAccessor- Returns:
- The
AuthTypestored by the Basic-Authentication credentials property (or null if there are none such credentials).
-