java.lang.Object
org.refcodes.web.BasicCredentials
org.refcodes.web.BasicAuthCredentials
- All Implemented Interfaces:
org.refcodes.mixin.CredentialsAccessor,org.refcodes.mixin.IdentityAccessor,org.refcodes.mixin.SecretAccessor,org.refcodes.mixin.Validatable<BasicCredentials>,AuthTypeAccessor,AuthTypeCredentials<BasicAuthCredentials,BasicCredentials>
- Direct Known Subclasses:
BasicAuthCredentialsBuilder
public class BasicAuthCredentials
extends BasicCredentials
implements AuthTypeCredentials<BasicAuthCredentials,BasicCredentials>
The
BasicAuthCredentials defines a type for representing a
Basic-Authentication credentials Header-Field. Parse the Header-Field via
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
toHttpAuthorization().-
Nested Class Summary
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
FieldsModifier and TypeFieldDescriptionstatic final charstatic final charFields inherited from class org.refcodes.web.BasicCredentials
_identity, _secret -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a newBasicAuthCredentialsinstance.BasicAuthCredentials(String aIdentity, String aSecret) Instantiates a newBasicAuthCredentialsinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidfromHttpAuthorization(String aHttpAuthorization) Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.Retrieves theAuthTypefrom the Authorization-Type property (or null if there are none such credentials).inthashCode()Creates aHeaderField.AUTHORIZATIONHTTP Header-Field value from theAuthTypeCredentialsinstance.toString()voidValidates the provided user-name and secret with thisBasicAuthCredentialsviaBasicCredentials.isValid(String, String).voidvalidate(BasicCredentials aCredentials) Validates the providedBasicCredentialswith thisBasicAuthCredentialsviaBasicCredentials.isValid(BasicCredentials).withHttpAuthorization(String aHttpAuthorization) Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.Methods inherited from class org.refcodes.web.BasicCredentials
isValid, isValidMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.mixin.Validatable
isValid
-
Field Details
-
DELIMITER_BASIC_AUTH
public static final char DELIMITER_BASIC_AUTH- See Also:
-
DELIMITER_CREDENTIALS
public static final char DELIMITER_CREDENTIALS- See Also:
-
-
Constructor Details
-
BasicAuthCredentials
public BasicAuthCredentials()Instantiates a newBasicAuthCredentialsinstance. -
BasicAuthCredentials
Instantiates a newBasicAuthCredentialsinstance.- Parameters:
aIdentity- the user nameaSecret- the secret
-
-
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
Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
withHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials> - Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader field's value- Returns:
- the t
-
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).
-
getIdentity
- Specified by:
getIdentityin interfaceorg.refcodes.mixin.IdentityAccessor- Overrides:
getIdentityin classBasicCredentials
-
getSecret
- Specified by:
getSecretin interfaceorg.refcodes.mixin.SecretAccessor- Overrides:
getSecretin classBasicCredentials
-
hashCode
public int hashCode() -
equals
-
toString
-
fromHttpAuthorization
Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
fromHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials> - Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader field's value
-
toHttpAuthorization
Creates aHeaderField.AUTHORIZATIONHTTP Header-Field value from theAuthTypeCredentialsinstance.- Specified by:
toHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials,BasicCredentials> - Returns:
- The according HTTP Header-Field's value.
-