Package org.refcodes.net
Interface BearerAuthCredentials
-
- 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 viaAuthTypeCredentials.fromHttpAuthorization(String)
and feed it with the header'sHeaderField.AUTHORIZATION
field's value. To create the according Header-Field's value from theBearerAuthCredentials
type, callAuthTypeCredentials.toHttpAuthorization()
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.net.AuthTypeAccessor
AuthTypeAccessor.AuthTypeBuilder<B extends AuthTypeAccessor.AuthTypeBuilder<B>>, AuthTypeAccessor.AuthTypeMutator, AuthTypeAccessor.AuthTypeProperty
-
-
Field Summary
Fields Modifier and Type Field Description static char
DELIMITER_AUTH_TYPE
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default AuthType
getAuthType()
Retrieves theAuthType
from the Authorization-Type property (or null if there are none such credentials).default void
validate(java.lang.String aToken)
Validates the provided user-name and secret with thisBearerAuthCredentials
viaTokenCredentials.isValid(String)
.default void
validate(TokenCredentials aCredentials)
Validates the providedTokenCredentials
with thisBearerAuthCredentials
viaTokenCredentials.isValid(TokenCredentials)
.default BearerAuthCredentials
withHttpAuthorization(java.lang.String aHttpAuthorization)
Initializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.-
Methods inherited from interface org.refcodes.net.AuthTypeCredentials
fromHttpAuthorization, toHttpAuthorization
-
Methods inherited from interface org.refcodes.net.TokenCredentials
isValid, isValid
-
-
-
-
Field Detail
-
DELIMITER_AUTH_TYPE
static final char DELIMITER_AUTH_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
validate
default void validate(TokenCredentials aCredentials) throws ForbiddenException
Validates the providedTokenCredentials
with thisBearerAuthCredentials
viaTokenCredentials.isValid(TokenCredentials)
. In case the providedTokenCredentials
are not valid, then aForbiddenException
is thrown.- Specified by:
validate
in interfaceAuthTypeCredentials<BearerAuthCredentials,TokenCredentials>
- Parameters:
aCredentials
- TheTokenCredentials
to be verified.- Throws:
ForbiddenException
- thrown in case the providedTokenCredentials
do not match.
-
validate
default void validate(java.lang.String aToken) throws ForbiddenException
Validates the provided user-name and secret with thisBearerAuthCredentials
viaTokenCredentials.isValid(String)
. In case the provided credentials are not valid, then aForbiddenException
is thrown.- Parameters:
aToken
- The secret part to be tested if it fits with the thisTokenCredentials
instance.- Throws:
ForbiddenException
- thrown in case the providedTokenCredentials
do not match.
-
withHttpAuthorization
default BearerAuthCredentials withHttpAuthorization(java.lang.String aHttpAuthorization) throws java.lang.IllegalArgumentException
Initializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.- Specified by:
withHttpAuthorization
in interfaceAuthTypeCredentials<BearerAuthCredentials,TokenCredentials>
- Parameters:
aHttpAuthorization
- TheHeaderField.AUTHORIZATION
header field's value- Returns:
- the t
- Throws:
java.lang.IllegalArgumentException
- The value does not conform the the HTTP Authorization Header-Field's Basic-Authentication format.
-
getAuthType
default AuthType getAuthType()
Retrieves theAuthType
from the Authorization-Type property (or null if there are none such credentials).- Specified by:
getAuthType
in interfaceAuthTypeAccessor
- Returns:
- The
AuthType
stored by the Basic-Authentication credentials property (or null if there are none such credentials).
-
-