Class DefaultAuthenticationBuilder

  • All Implemented Interfaces:
    java.io.Serializable, org.apereo.cas.authentication.AuthenticationBuilder

    public class DefaultAuthenticationBuilder
    extends java.lang.Object
    implements org.apereo.cas.authentication.AuthenticationBuilder
    Constructs immutable Authentication objects 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.AuthenticationBuilder addAttribute​(java.lang.String key, java.lang.Object value)  
      org.apereo.cas.authentication.AuthenticationBuilder addAttribute​(java.lang.String key, java.util.List<java.lang.Object> value)  
      org.apereo.cas.authentication.AuthenticationBuilder addAttributes​(java.util.Map<java.lang.String,​java.lang.Object> attributes)  
      org.apereo.cas.authentication.AuthenticationBuilder addCredential​(org.apereo.cas.authentication.CredentialMetaData credential)  
      org.apereo.cas.authentication.AuthenticationBuilder addCredentials​(java.util.List<org.apereo.cas.authentication.CredentialMetaData> credentials)  
      org.apereo.cas.authentication.AuthenticationBuilder addFailure​(java.lang.String key, java.lang.Throwable value)  
      org.apereo.cas.authentication.AuthenticationBuilder addFailures​(@NonNull java.util.Map<java.lang.String,​java.lang.Throwable> failures)  
      org.apereo.cas.authentication.AuthenticationBuilder addSuccess​(java.lang.String key, org.apereo.cas.authentication.AuthenticationHandlerExecutionResult value)  
      org.apereo.cas.authentication.AuthenticationBuilder addSuccesses​(@NonNull java.util.Map<java.lang.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​(java.util.List<org.apereo.cas.authentication.MessageDescriptor> warning)  
      org.apereo.cas.authentication.Authentication build()  
      boolean hasAttribute​(java.lang.String name, java.util.function.Predicate<java.lang.Object> predicate)  
      org.apereo.cas.authentication.AuthenticationBuilder mergeAttribute​(java.lang.String key, java.lang.Object value)  
      org.apereo.cas.authentication.AuthenticationBuilder mergeAttribute​(java.lang.String key, java.util.List<java.lang.Object> value)  
      static org.apereo.cas.authentication.AuthenticationBuilder newInstance()
      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 of​(org.apereo.cas.authentication.principal.Principal principal, org.apereo.cas.authentication.principal.PrincipalFactory principalFactory, java.util.Map<java.lang.String,​java.util.List<java.lang.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 setAttributes​(java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> attributes)  
      org.apereo.cas.authentication.AuthenticationBuilder setAuthenticationDate​(java.time.ZonedDateTime d)  
      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.
      org.apereo.cas.authentication.AuthenticationBuilder setFailures​(@NonNull java.util.Map<java.lang.String,​java.lang.Throwable> failures)  
      org.apereo.cas.authentication.AuthenticationBuilder setPrincipal​(org.apereo.cas.authentication.principal.Principal p)  
      org.apereo.cas.authentication.AuthenticationBuilder setSuccesses​(@NonNull java.util.Map<java.lang.String,​org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)  
      org.apereo.cas.authentication.AuthenticationBuilder setWarnings​(java.util.List<org.apereo.cas.authentication.MessageDescriptor> warning)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apereo.cas.authentication.AuthenticationBuilder

        getAuthenticationDate, getFailures, getPrincipal, getSuccesses, hasAttribute
    • 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
      • of

        public static org.apereo.cas.authentication.AuthenticationBuilder of​(org.apereo.cas.authentication.principal.Principal principal,
                                                                             org.apereo.cas.authentication.principal.PrincipalFactory principalFactory,
                                                                             java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> principalAttributes,
                                                                             org.apereo.cas.authentication.principal.Service service,
                                                                             org.apereo.cas.services.RegisteredService registeredService,
                                                                             org.apereo.cas.authentication.Authentication authentication)
        Factory method.
        Parameters:
        principal - principal.
        principalFactory - principalFactory.
        principalAttributes - principalAttributes.
        service - service.
        registeredService - registeredService.
        authentication - authentication.
        Returns:
        AuthenticationBuilder new AuthenticationBuilder instance.
      • setPrincipal

        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

        public org.apereo.cas.authentication.AuthenticationBuilder addCredentials​(java.util.List<org.apereo.cas.authentication.CredentialMetaData> credentials)
        Specified by:
        addCredentials in interface org.apereo.cas.authentication.AuthenticationBuilder
      • addCredential

        public org.apereo.cas.authentication.AuthenticationBuilder addCredential​(org.apereo.cas.authentication.CredentialMetaData credential)
        Specified by:
        addCredential in interface org.apereo.cas.authentication.AuthenticationBuilder
      • addWarnings

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

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

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

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

        public org.apereo.cas.authentication.AuthenticationBuilder addAttribute​(java.lang.String key,
                                                                                java.lang.Object value)
        Specified by:
        addAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
      • setSuccesses

        public org.apereo.cas.authentication.AuthenticationBuilder setSuccesses​(@NonNull
                                                                                @NonNull java.util.Map<java.lang.String,​org.apereo.cas.authentication.AuthenticationHandlerExecutionResult> successes)
        Specified by:
        setSuccesses in interface org.apereo.cas.authentication.AuthenticationBuilder
      • addAttributes

        public org.apereo.cas.authentication.AuthenticationBuilder addAttributes​(java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        addAttributes in interface org.apereo.cas.authentication.AuthenticationBuilder
      • addSuccesses

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

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

        public org.apereo.cas.authentication.AuthenticationBuilder addSuccess​(java.lang.String key,
                                                                              org.apereo.cas.authentication.AuthenticationHandlerExecutionResult value)
        Specified by:
        addSuccess in interface org.apereo.cas.authentication.AuthenticationBuilder
      • setAuthenticationDate

        public org.apereo.cas.authentication.AuthenticationBuilder setAuthenticationDate​(java.time.ZonedDateTime d)
        Specified by:
        setAuthenticationDate in interface org.apereo.cas.authentication.AuthenticationBuilder
      • build

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

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

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

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

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

        public org.apereo.cas.authentication.AuthenticationBuilder mergeAttribute​(java.lang.String key,
                                                                                  java.util.List<java.lang.Object> value)
        Specified by:
        mergeAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
      • hasAttribute

        public boolean hasAttribute​(java.lang.String name,
                                    java.util.function.Predicate<java.lang.Object> predicate)
        Specified by:
        hasAttribute in interface org.apereo.cas.authentication.AuthenticationBuilder
      • setCredentials

        public org.apereo.cas.authentication.AuthenticationBuilder setCredentials​(@NonNull
                                                                                  @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.