Class BearerAuthCredentials
java.lang.Object
org.refcodes.web.BearerAuthCredentials
- All Implemented Interfaces:
org.refcodes.mixin.TokenAccessor,org.refcodes.mixin.Validatable<TokenCredentials>,AuthTypeAccessor,AuthTypeCredentials<BearerAuthCredentials,,TokenCredentials> TokenCredentials
public class BearerAuthCredentials
extends Object
implements TokenCredentials, AuthTypeCredentials<BearerAuthCredentials,TokenCredentials>
The
BearerAuthCredentials defines a type for representing a
Bearer-Authentication credentials Header-Field. Parse the Header-Field via
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
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 -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new bearer auth credentials impl.BearerAuthCredentials(String aToken) Instantiates a new bearer auth credentials impl. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidfromHttpAuthorization(String aHttpAuthorization) Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.Retrieves theAuthTypefrom the Authorization-Type property (or null if there are none such credentials).getToken()inthashCode()Creates aHeaderField.AUTHORIZATIONHTTP Header-Field value from theAuthTypeCredentialsinstance.toString()voidValidates the provided user-name and secret with thisBearerAuthCredentialsviaTokenCredentials.isValid(String).voidvalidate(TokenCredentials aCredentials) Validates the providedTokenCredentialswith thisBearerAuthCredentialsviaTokenCredentials.isValid(TokenCredentials).withHttpAuthorization(String aHttpAuthorization) Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.web.TokenCredentials
isValid, isValid
-
Field Details
-
DELIMITER_AUTH_TYPE
public static final char DELIMITER_AUTH_TYPE- See Also:
-
-
Constructor Details
-
BearerAuthCredentials
public BearerAuthCredentials()Instantiates a new bearer auth credentials impl. -
BearerAuthCredentials
Instantiates a new bearer auth credentials impl.- Parameters:
aToken- the secret
-
-
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
Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
withHttpAuthorizationin interfaceAuthTypeCredentials<BearerAuthCredentials,TokenCredentials> - Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader field's value- Returns:
- the t
-
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).
-
getToken
- Specified by:
getTokenin interfaceorg.refcodes.mixin.TokenAccessor
-
hashCode
-
equals
-
toString
-
fromHttpAuthorization
Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
fromHttpAuthorizationin interfaceAuthTypeCredentials<BearerAuthCredentials,TokenCredentials> - Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader field's value
-
toHttpAuthorization
Creates aHeaderField.AUTHORIZATIONHTTP Header-Field value from theAuthTypeCredentialsinstance.- Specified by:
toHttpAuthorizationin interfaceAuthTypeCredentials<BearerAuthCredentials,TokenCredentials> - Returns:
- The according HTTP Header-Field's value.
-