Package org.refcodes.net
Interface BearerAuthCredentials
-
- All Superinterfaces:
AuthCredentials<BearerAuthCredentials,BearerCredentials>
,AuthTypeAccessor
,BearerCredentials
,org.refcodes.mixin.TokenAccessor
,org.refcodes.mixin.Validatable<BearerCredentials>
- All Known Implementing Classes:
BearerAuthCredentialsImpl
public interface BearerAuthCredentials extends BearerCredentials, AuthCredentials<BearerAuthCredentials,BearerCredentials>
This interface defines a type for representing a Bearer-Authentication credentials Header-Field. Parse the Header-Field viaAuthCredentials.fromHttpAuthorization(String)
and feed it with the header'sHeaderField.AUTHORIZATION
field's value. To create the according Header-Field's value from theBearerAuthCredentials
type, callAuthCredentials.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_BEARER_AUTH
-
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
viaBearerCredentials.isValid(String)
.default void
validate(BearerCredentials aCredentials)
Validates the providedBearerCredentials
with thisBearerAuthCredentials
viaBearerCredentials.isValid(BearerCredentials)
.default BearerAuthCredentials
withHttpAuthorization(java.lang.String aHttpAuthorization)
Initializes thisAuthCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.-
Methods inherited from interface org.refcodes.net.AuthCredentials
fromHttpAuthorization, toHttpAuthorization
-
Methods inherited from interface org.refcodes.net.BearerCredentials
isValid, isValid
-
-
-
-
Field Detail
-
DELIMITER_BEARER_AUTH
static final char DELIMITER_BEARER_AUTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
validate
default void validate(BearerCredentials aCredentials) throws ForbiddenException
Validates the providedBearerCredentials
with thisBearerAuthCredentials
viaBearerCredentials.isValid(BearerCredentials)
. In case the providedBearerCredentials
are not valid, then aForbiddenException
is thrown.- Specified by:
validate
in interfaceAuthCredentials<BearerAuthCredentials,BearerCredentials>
- Parameters:
aCredentials
- TheBearerCredentials
to be verified.- Throws:
ForbiddenException
- thrown in case the providedBearerCredentials
do not match.
-
validate
default void validate(java.lang.String aToken) throws ForbiddenException
Validates the provided user-name and secret with thisBearerAuthCredentials
viaBearerCredentials.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 thisBearerCredentials
instance.- Throws:
ForbiddenException
- thrown in case the providedBearerCredentials
do not match.
-
withHttpAuthorization
default BearerAuthCredentials withHttpAuthorization(java.lang.String aHttpAuthorization) throws java.lang.IllegalArgumentException
Initializes thisAuthCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.- Specified by:
withHttpAuthorization
in interfaceAuthCredentials<BearerAuthCredentials,BearerCredentials>
- 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).
-
-