Package org.apereo.cas.authentication
Class DefaultAuthenticationBuilder
- java.lang.Object
-
- org.apereo.cas.authentication.DefaultAuthenticationBuilder
-
- All Implemented Interfaces:
java.io.Serializable,org.apereo.cas.authentication.AuthenticationBuilder
public class DefaultAuthenticationBuilder extends java.lang.Object implements org.apereo.cas.authentication.AuthenticationBuilderConstructs immutableAuthenticationobjects using the builder pattern.- Since:
- 4.0.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthenticationBuilder()Creates a new instance using the current date for the authentication date.DefaultAuthenticationBuilder(org.apereo.cas.authentication.principal.Principal p)Creates a new instance using the current date for the authentication date and the given principal for the authenticated principal.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apereo.cas.authentication.AuthenticationBuilderaddAttribute(java.lang.String key, java.lang.Object value)Adds an authentication metadata attribute key-value pair.org.apereo.cas.authentication.AuthenticationBuilderaddCredential(org.apereo.cas.authentication.CredentialMetaData credential)Adds metadata about a credential presented for authentication.org.apereo.cas.authentication.AuthenticationBuilderaddCredentials(java.util.List<org.apereo.cas.authentication.CredentialMetaData> credentials)org.apereo.cas.authentication.AuthenticationBuilderaddFailure(java.lang.String key, java.lang.Throwable value)Adds an authentication failure to the map of handler names to the authentication handler failures.org.apereo.cas.authentication.AuthenticationBuilderaddFailures(java.util.Map<java.lang.String,java.lang.Throwable> failures)org.apereo.cas.authentication.AuthenticationBuilderaddSuccess(java.lang.String key, org.apereo.cas.authentication.AuthenticationHandlerExecutionResult value)Adds an authentication success to the map of handler names to successful authentication handler results.org.apereo.cas.authentication.AuthenticationBuilderaddSuccesses(java.util.Map<java.lang.String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)org.apereo.cas.authentication.Authenticationbuild()Creates an immutable authentication instance from builder data.booleanhasAttribute(java.lang.String name, java.util.function.Predicate<java.lang.Object> predicate)org.apereo.cas.authentication.AuthenticationBuildermergeAttribute(java.lang.String key, java.lang.Object value)static org.apereo.cas.authentication.AuthenticationBuildernewInstance()Creates a new builder.static org.apereo.cas.authentication.AuthenticationBuildernewInstance(org.apereo.cas.authentication.Authentication source)Creates a new builder initialized with data from the given authentication source.org.apereo.cas.authentication.AuthenticationBuildersetAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)Sets the authentication metadata attributes.org.apereo.cas.authentication.AuthenticationBuildersetAuthenticationDate(java.time.ZonedDateTime d)Sets the authentication date and returns this instance.org.apereo.cas.authentication.AuthenticationBuildersetCredentials(java.util.List<org.apereo.cas.authentication.CredentialMetaData> credentials)Sets the list of metadata about credentials presented for authentication.org.apereo.cas.authentication.AuthenticationBuildersetFailures(java.util.Map<java.lang.String,java.lang.Throwable> failures)Sets the authentication handler failure map.org.apereo.cas.authentication.AuthenticationBuildersetPrincipal(org.apereo.cas.authentication.principal.Principal p)Sets the principal returns this instance.org.apereo.cas.authentication.AuthenticationBuildersetSuccesses(java.util.Map<java.lang.String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)Sets the authentication handler success map.
-
-
-
Constructor Detail
-
DefaultAuthenticationBuilder
public DefaultAuthenticationBuilder()
Creates a new instance using the current date for the authentication date.
-
DefaultAuthenticationBuilder
public DefaultAuthenticationBuilder(org.apereo.cas.authentication.principal.Principal p)
Creates a new instance using the current date for the authentication date and the given principal for the authenticated principal.- Parameters:
p- Authenticated principal.
-
-
Method Detail
-
newInstance
public static org.apereo.cas.authentication.AuthenticationBuilder newInstance(org.apereo.cas.authentication.Authentication source)
Creates a new builder initialized with data from the given authentication source.- Parameters:
source- Authentication source.- Returns:
- New builder instance initialized with all fields in the given authentication source.
-
newInstance
public static org.apereo.cas.authentication.AuthenticationBuilder newInstance()
Creates a new builder.- Returns:
- New builder instance
-
setAuthenticationDate
public org.apereo.cas.authentication.AuthenticationBuilder setAuthenticationDate(java.time.ZonedDateTime d)
Sets the authentication date and returns this instance.- Specified by:
setAuthenticationDatein interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
d- Authentication date.- Returns:
- This builder instance.
-
addCredentials
public org.apereo.cas.authentication.AuthenticationBuilder addCredentials(java.util.List<org.apereo.cas.authentication.CredentialMetaData> credentials)
- Specified by:
addCredentialsin interfaceorg.apereo.cas.authentication.AuthenticationBuilder
-
setPrincipal
public org.apereo.cas.authentication.AuthenticationBuilder setPrincipal(org.apereo.cas.authentication.principal.Principal p)
Sets the principal returns this instance.- Specified by:
setPrincipalin interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
p- Authenticated principal.- Returns:
- This builder instance.
-
setCredentials
public org.apereo.cas.authentication.AuthenticationBuilder setCredentials(@NonNull java.util.List<org.apereo.cas.authentication.CredentialMetaData> credentials)Sets the list of metadata about credentials presented for authentication.- Parameters:
credentials- Non-null list of credential metadata.- Returns:
- This builder instance.
-
addCredential
public org.apereo.cas.authentication.AuthenticationBuilder addCredential(org.apereo.cas.authentication.CredentialMetaData credential)
Adds metadata about a credential presented for authentication.- Specified by:
addCredentialin interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
credential- Credential metadata.- Returns:
- This builder instance.
-
setAttributes
public org.apereo.cas.authentication.AuthenticationBuilder setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Sets the authentication metadata attributes.- Specified by:
setAttributesin interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
attributes- Non-null map of authentication metadata attributes.- Returns:
- This builder instance.
-
mergeAttribute
public org.apereo.cas.authentication.AuthenticationBuilder mergeAttribute(java.lang.String key, java.lang.Object value)- Specified by:
mergeAttributein interfaceorg.apereo.cas.authentication.AuthenticationBuilder
-
hasAttribute
public boolean hasAttribute(java.lang.String name, java.util.function.Predicate<java.lang.Object> predicate)- Specified by:
hasAttributein interfaceorg.apereo.cas.authentication.AuthenticationBuilder
-
addAttribute
public org.apereo.cas.authentication.AuthenticationBuilder addAttribute(java.lang.String key, java.lang.Object value)Adds an authentication metadata attribute key-value pair.- Specified by:
addAttributein interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
key- Authentication attribute key.value- Authentication attribute value.- Returns:
- This builder instance.
-
setSuccesses
public org.apereo.cas.authentication.AuthenticationBuilder setSuccesses(@NonNull java.util.Map<java.lang.String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)Sets the authentication handler success map.- Specified by:
setSuccessesin interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
successes- Non-null map of handler names to successful handler authentication results.- Returns:
- This builder instance.
-
addSuccesses
public org.apereo.cas.authentication.AuthenticationBuilder addSuccesses(java.util.Map<java.lang.String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)
- Specified by:
addSuccessesin interfaceorg.apereo.cas.authentication.AuthenticationBuilder
-
addSuccess
public org.apereo.cas.authentication.AuthenticationBuilder addSuccess(java.lang.String key, org.apereo.cas.authentication.AuthenticationHandlerExecutionResult value)Adds an authentication success to the map of handler names to successful authentication handler results.- Specified by:
addSuccessin interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
key- Authentication handler name.value- Successful authentication handler result produced by handler of given name.- Returns:
- This builder instance.
-
setFailures
public org.apereo.cas.authentication.AuthenticationBuilder setFailures(@NonNull java.util.Map<java.lang.String,java.lang.Throwable> failures)Sets the authentication handler failure map.- Specified by:
setFailuresin interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
failures- Non-null map of handler name to authentication failures.- Returns:
- This builder instance.
-
addFailures
public org.apereo.cas.authentication.AuthenticationBuilder addFailures(java.util.Map<java.lang.String,java.lang.Throwable> failures)
- Specified by:
addFailuresin interfaceorg.apereo.cas.authentication.AuthenticationBuilder
-
addFailure
public org.apereo.cas.authentication.AuthenticationBuilder addFailure(java.lang.String key, java.lang.Throwable value)Adds an authentication failure to the map of handler names to the authentication handler failures.- Specified by:
addFailurein interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Parameters:
key- Authentication handler name.value- Exception raised on handler failure to authenticate credential.- Returns:
- This builder instance.
-
build
public org.apereo.cas.authentication.Authentication build()
Creates an immutable authentication instance from builder data.- Specified by:
buildin interfaceorg.apereo.cas.authentication.AuthenticationBuilder- Returns:
- Immutable authentication.
-
-