- 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 interfaceBasicAuthCredentials.BasicAuthCredentialsBuilderBuilder type for theBasicAuthCredentialstype.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.CredentialsAccessor
org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<B extends org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<B>>, org.refcodes.mixin.CredentialsAccessor.CredentialsMutator, org.refcodes.mixin.CredentialsAccessor.CredentialsPropertyNested 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.IdentityPropertyNested 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 charDELIMITER_BASIC_AUTHstatic charDELIMITER_CREDENTIALS -
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 aUserName, String aSecret)Validates the provided user-name and secret with thisBasicAuthCredentialsviaBasicCredentials.isValid(String, String).default voidvalidate(BasicCredentials aCredentials)Validates the providedBasicCredentialswith thisBasicAuthCredentialsviaBasicCredentials.isValid(BasicCredentials).default BasicAuthCredentialswithHttpAuthorization(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.web.BasicCredentials
isValid, isValidMethods inherited from interface org.refcodes.mixin.IdentityAccessor
getIdentityMethods 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 providedBasicCredentialswith thisBasicAuthCredentialsviaBasicCredentials.isValid(BasicCredentials). In case the providedBasicCredentialsare not valid, then aForbiddenExceptionis thrown.- Specified by:
validatein interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials>- Parameters:
aCredentials- TheBasicCredentialsto be verified.- Throws:
ForbiddenException- thrown in case the providedBasicCredentialsdo not match.
-
validate
Validates the provided user-name and secret with thisBasicAuthCredentialsviaBasicCredentials.isValid(String, String). In case the provided credentials are not valid, then aForbiddenExceptionis thrown.- Parameters:
aUserName- The user-name part to be tested if it fits with the thisBasicCredentialsinstance.aSecret- The secret part to be tested if it fits with the thisBasicCredentialsinstance.- Throws:
ForbiddenException- thrown in case the providedBasicCredentialsdo not match.
-
withHttpAuthorization
default BasicAuthCredentials withHttpAuthorization(String aHttpAuthorization) throws IllegalArgumentExceptionInitializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
withHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials>- 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).
-