Class DefaultAuthenticationBuilder

java.lang.Object
org.apereo.cas.authentication.DefaultAuthenticationBuilder
All Implemented Interfaces:
Serializable, org.apereo.cas.authentication.AuthenticationBuilder

public class DefaultAuthenticationBuilder extends Object implements org.apereo.cas.authentication.AuthenticationBuilder
Constructs immutable Authentication objects using the builder pattern.
Since:
4.0.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    DefaultAuthenticationBuilder(org.apereo.cas.authentication.principal.Principal principal)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apereo.cas.authentication.AuthenticationBuilder
    addAttribute(String key, Object value)
     
    org.apereo.cas.authentication.AuthenticationBuilder
     
    org.apereo.cas.authentication.AuthenticationBuilder
     
    org.apereo.cas.authentication.AuthenticationBuilder
    addCredential(org.apereo.cas.authentication.Credential credential)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    addCredentials(List<org.apereo.cas.authentication.Credential> credentials)
     
    org.apereo.cas.authentication.AuthenticationBuilder
     
    org.apereo.cas.authentication.AuthenticationBuilder
    addFailures(@NonNull Map<String,Throwable> failures)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    addSuccess(String key, org.apereo.cas.authentication.AuthenticationHandlerExecutionResult value)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    addSuccesses(@NonNull Map<String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    addWarning(org.apereo.cas.authentication.MessageDescriptor warning)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    addWarnings(List<org.apereo.cas.authentication.MessageDescriptor> warning)
     
    org.apereo.cas.authentication.Authentication
     
    Authentication metadata attributes.
    Authentication date.
    List<org.apereo.cas.authentication.Credential>
     
    Map of handler names to authentication failures.
    org.apereo.cas.authentication.principal.Principal
    Authenticated principal.
    Map<String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult>
    Map of handler names to authentication successes.
    List<org.apereo.cas.authentication.MessageDescriptor>
    Warnings here are considered global and apply to the authentication event vs individual attempts and results.
    boolean
    hasAttribute(String name, Predicate<Object> predicate)
     
    org.apereo.cas.authentication.AuthenticationBuilder
     
    org.apereo.cas.authentication.AuthenticationBuilder
     
    static org.apereo.cas.authentication.AuthenticationBuilder
    Creates a new builder.
    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.
    static org.apereo.cas.authentication.AuthenticationBuilder
    newInstance(org.apereo.cas.authentication.principal.Principal principal)
    New instance authentication builder with a principal.
    static org.apereo.cas.authentication.AuthenticationBuilder
    of(org.springframework.context.ApplicationContext applicationContext, org.apereo.cas.authentication.principal.Principal principal, org.apereo.cas.authentication.principal.PrincipalFactory principalFactory, Map<String,List<Object>> principalAttributes, org.apereo.cas.authentication.principal.Service service, org.apereo.cas.services.RegisteredService registeredService, org.apereo.cas.authentication.Authentication authentication)
    Factory method.
    org.apereo.cas.authentication.AuthenticationBuilder
     
    org.apereo.cas.authentication.AuthenticationBuilder
     
    org.apereo.cas.authentication.AuthenticationBuilder
    setCredentials(@NonNull List<org.apereo.cas.authentication.Credential> credentials)
    Sets the list of metadata about credentials presented for authentication.
    org.apereo.cas.authentication.AuthenticationBuilder
    setFailures(@NonNull Map<String,Throwable> failures)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    setPrincipal(org.apereo.cas.authentication.principal.Principal p)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    setSuccesses(@NonNull Map<String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)
     
    org.apereo.cas.authentication.AuthenticationBuilder
    setWarnings(List<org.apereo.cas.authentication.MessageDescriptor> warning)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apereo.cas.authentication.AuthenticationBuilder

    hasAttribute, mergeAttributes
  • Constructor Details

    • DefaultAuthenticationBuilder

      public DefaultAuthenticationBuilder()
    • DefaultAuthenticationBuilder

      public DefaultAuthenticationBuilder(org.apereo.cas.authentication.principal.Principal principal)
  • Method Details

    • 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
    • newInstance

      public static org.apereo.cas.authentication.AuthenticationBuilder newInstance(org.apereo.cas.authentication.principal.Principal principal)
      New instance authentication builder with a principal.
      Parameters:
      principal - the principal
      Returns:
      the authentication builder
    • of

      public static org.apereo.cas.authentication.AuthenticationBuilder of(org.springframework.context.ApplicationContext applicationContext, org.apereo.cas.authentication.principal.Principal principal, org.apereo.cas.authentication.principal.PrincipalFactory principalFactory, Map<String,List<Object>> principalAttributes, org.apereo.cas.authentication.principal.Service service, org.apereo.cas.services.RegisteredService registeredService, org.apereo.cas.authentication.Authentication authentication) throws Throwable
      Factory method.
      Parameters:
      applicationContext - the application context
      principal - principal.
      principalFactory - principalFactory.
      principalAttributes - principalAttributes.
      service - service.
      registeredService - registeredService.
      authentication - authentication.
      Returns:
      AuthenticationBuilder new AuthenticationBuilder instance.
      Throws:
      Throwable - the throwable
    • setPrincipal

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder setPrincipal(org.apereo.cas.authentication.principal.Principal p)
      Specified by:
      setPrincipal in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addCredentials

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addCredentials(List<org.apereo.cas.authentication.Credential> credentials)
      Specified by:
      addCredentials in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addCredential

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addCredential(org.apereo.cas.authentication.Credential credential)
      Specified by:
      addCredential in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addWarnings

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addWarnings(List<org.apereo.cas.authentication.MessageDescriptor> warning)
      Specified by:
      addWarnings in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addWarning

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addWarning(org.apereo.cas.authentication.MessageDescriptor warning)
      Specified by:
      addWarning in interface org.apereo.cas.authentication.AuthenticationBuilder
    • setWarnings

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder setWarnings(List<org.apereo.cas.authentication.MessageDescriptor> warning)
      Specified by:
      setWarnings in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addAttribute

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addAttribute(String key, List<Object> value)
      Specified by:
      addAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addAttribute

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addAttribute(String key, Object value)
      Specified by:
      addAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addAttributes

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addAttributes(Map<String,Object> attributes)
      Specified by:
      addAttributes in interface org.apereo.cas.authentication.AuthenticationBuilder
    • setSuccesses

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder setSuccesses(@NonNull @NonNull Map<String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)
      Specified by:
      setSuccesses in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addSuccesses

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addSuccesses(@NonNull @NonNull Map<String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)
      Specified by:
      addSuccesses in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addFailures

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addFailures(@NonNull @NonNull Map<String,Throwable> failures)
      Specified by:
      addFailures in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addSuccess

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addSuccess(String key, org.apereo.cas.authentication.AuthenticationHandlerExecutionResult value)
      Specified by:
      addSuccess in interface org.apereo.cas.authentication.AuthenticationBuilder
    • build

      @CanIgnoreReturnValue public org.apereo.cas.authentication.Authentication build()
      Specified by:
      build in interface org.apereo.cas.authentication.AuthenticationBuilder
    • setFailures

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder setFailures(@NonNull @NonNull Map<String,Throwable> failures)
      Specified by:
      setFailures in interface org.apereo.cas.authentication.AuthenticationBuilder
    • addFailure

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder addFailure(String key, Throwable value)
      Specified by:
      addFailure in interface org.apereo.cas.authentication.AuthenticationBuilder
    • setAttributes

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder setAttributes(Map<String,List<Object>> attributes)
      Specified by:
      setAttributes in interface org.apereo.cas.authentication.AuthenticationBuilder
    • mergeAttribute

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder mergeAttribute(String key, Object value)
      Specified by:
      mergeAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
    • mergeAttribute

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder mergeAttribute(String key, List<Object> value)
      Specified by:
      mergeAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
    • setAuthenticationDate

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder setAuthenticationDate(ZonedDateTime dateTime)
      Specified by:
      setAuthenticationDate in interface org.apereo.cas.authentication.AuthenticationBuilder
    • hasAttribute

      @CanIgnoreReturnValue public boolean hasAttribute(String name, Predicate<Object> predicate)
      Specified by:
      hasAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
    • setCredentials

      @CanIgnoreReturnValue public org.apereo.cas.authentication.AuthenticationBuilder setCredentials(@NonNull @NonNull List<org.apereo.cas.authentication.Credential> credentials)
      Sets the list of metadata about credentials presented for authentication.
      Parameters:
      credentials - Non-null list of credential metadata.
      Returns:
      This builder instance.
    • getCredentials

      public List<org.apereo.cas.authentication.Credential> getCredentials()
    • getWarnings

      public List<org.apereo.cas.authentication.MessageDescriptor> getWarnings()
      Warnings here are considered global and apply to the authentication event vs individual attempts and results.
    • getAttributes

      public Map<String,List<Object>> getAttributes()
      Authentication metadata attributes.
    • getSuccesses

      public Map<String,org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> getSuccesses()
      Map of handler names to authentication successes.
      Specified by:
      getSuccesses in interface org.apereo.cas.authentication.AuthenticationBuilder
    • getFailures

      public Map<String,Throwable> getFailures()
      Map of handler names to authentication failures.
      Specified by:
      getFailures in interface org.apereo.cas.authentication.AuthenticationBuilder
    • getPrincipal

      public org.apereo.cas.authentication.principal.Principal getPrincipal()
      Authenticated principal.
      Specified by:
      getPrincipal in interface org.apereo.cas.authentication.AuthenticationBuilder
    • getAuthenticationDate

      public ZonedDateTime getAuthenticationDate()
      Authentication date.
      Specified by:
      getAuthenticationDate in interface org.apereo.cas.authentication.AuthenticationBuilder