- All Superinterfaces:
AuthTypeAccessor
,AuthTypeCredentials<BasicAuthCredentials,BasicCredentials>
,BasicCredentials
,org.refcodes.mixin.CredentialsAccessor
,org.refcodes.mixin.IdentityAccessor
,org.refcodes.mixin.SecretAccessor
,org.refcodes.mixin.Validatable<BasicCredentials>
- All Known Subinterfaces:
BasicAuthCredentials.BasicAuthCredentialsBuilder
- All Known Implementing Classes:
BasicAuthCredentialsBuilderImpl
,BasicAuthCredentialsImpl
public interface BasicAuthCredentials extends BasicCredentials, AuthTypeCredentials<BasicAuthCredentials,BasicCredentials>
This interface defines a type for representing a Basic-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 BasicAuthCredentials
type, call
AuthTypeCredentials.toHttpAuthorization()
.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
BasicAuthCredentials.BasicAuthCredentialsBuilder
Builder type for theBasicAuthCredentials
type.Nested classes/interfaces inherited from interface org.refcodes.web.AuthTypeAccessor
AuthTypeAccessor.AuthTypeBuilder<B extends AuthTypeAccessor.AuthTypeBuilder<B>>, AuthTypeAccessor.AuthTypeMutator, AuthTypeAccessor.AuthTypeProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.CredentialsAccessor
org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<B extends org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<B>>, org.refcodes.mixin.CredentialsAccessor.CredentialsMutator, org.refcodes.mixin.CredentialsAccessor.CredentialsProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.IdentityAccessor
org.refcodes.mixin.IdentityAccessor.IdentityBuilder<B extends org.refcodes.mixin.IdentityAccessor.IdentityBuilder<B>>, org.refcodes.mixin.IdentityAccessor.IdentityMutator, org.refcodes.mixin.IdentityAccessor.IdentityProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.SecretAccessor
org.refcodes.mixin.SecretAccessor.SecretBuilder<B extends org.refcodes.mixin.SecretAccessor.SecretBuilder<B>>, org.refcodes.mixin.SecretAccessor.SecretMutator, org.refcodes.mixin.SecretAccessor.SecretProperty
-
Field Summary
Fields Modifier and Type Field Description static char
DELIMITER_BASIC_AUTH
static char
DELIMITER_CREDENTIALS
-
Method Summary
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(String aUserName, String aSecret)
Validates the provided user-name and secret with thisBasicAuthCredentials
viaBasicCredentials.isValid(String, String)
.default void
validate(BasicCredentials aCredentials)
Validates the providedBasicCredentials
with thisBasicAuthCredentials
viaBasicCredentials.isValid(BasicCredentials)
.default BasicAuthCredentials
withHttpAuthorization(String aHttpAuthorization)
Initializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.Methods inherited from interface org.refcodes.web.AuthTypeCredentials
fromHttpAuthorization, toHttpAuthorization
Methods inherited from interface org.refcodes.web.BasicCredentials
isValid, isValid
Methods inherited from interface org.refcodes.mixin.IdentityAccessor
getIdentity
Methods inherited from interface org.refcodes.mixin.SecretAccessor
getSecret
-
Field Details
-
DELIMITER_BASIC_AUTH
static final char DELIMITER_BASIC_AUTH- See Also:
- Constant Field Values
-
DELIMITER_CREDENTIALS
static final char DELIMITER_CREDENTIALS- See Also:
- Constant Field Values
-
-
Method Details
-
validate
Validates the providedBasicCredentials
with thisBasicAuthCredentials
viaBasicCredentials.isValid(BasicCredentials)
. In case the providedBasicCredentials
are not valid, then aForbiddenException
is thrown.- Specified by:
validate
in interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials>
- Parameters:
aCredentials
- TheBasicCredentials
to be verified.- Throws:
ForbiddenException
- thrown in case the providedBasicCredentials
do not match.
-
validate
Validates the provided user-name and secret with thisBasicAuthCredentials
viaBasicCredentials.isValid(String, String)
. In case the provided credentials are not valid, then aForbiddenException
is thrown.- Parameters:
aUserName
- The user-name part to be tested if it fits with the thisBasicCredentials
instance.aSecret
- The secret part to be tested if it fits with the thisBasicCredentials
instance.- Throws:
ForbiddenException
- thrown in case the providedBasicCredentials
do not match.
-
withHttpAuthorization
default BasicAuthCredentials withHttpAuthorization(String aHttpAuthorization) throws IllegalArgumentExceptionInitializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.- Specified by:
withHttpAuthorization
in interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials>
- Parameters:
aHttpAuthorization
- TheHeaderField.AUTHORIZATION
header 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 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).
-