Package org.refcodes.net
Interface BasicAuthCredentials
-
- 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 viaAuthTypeCredentials.fromHttpAuthorization(String)and feed it with the header'sHeaderField.AUTHORIZATIONfield's value. To create the according Header-Field's value from theBasicAuthCredentialstype, callAuthTypeCredentials.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.net.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
-
-
Field Summary
Fields Modifier and Type Field Description static charDELIMITER_BASIC_AUTHstatic charDELIMITER_CREDENTIALS
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default AuthTypegetAuthType()Retrieves theAuthTypefrom the Authorization-Type property (or null if there are none such credentials).default voidvalidate(java.lang.String aUserName, java.lang.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(java.lang.String aHttpAuthorization)Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.-
Methods inherited from interface org.refcodes.net.AuthTypeCredentials
fromHttpAuthorization, toHttpAuthorization
-
Methods inherited from interface org.refcodes.net.BasicCredentials
isValid, isValid
-
-
-
-
Field Detail
-
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 Detail
-
validate
default void validate(BasicCredentials aCredentials) throws ForbiddenException
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
default void validate(java.lang.String aUserName, java.lang.String aSecret) throws ForbiddenExceptionValidates 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(java.lang.String aHttpAuthorization) throws java.lang.IllegalArgumentException
Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
withHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials>- Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader 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 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).
-
-