@Override
    @CanIgnoreReturnValue
    public AuthenticationBuilder addAttribute(final String key, final Object value) {
        if (value instanceof final Map mappedValue) {
            val list = new ArrayList<>();
            list.add(mappedValue);
            this.attributes.put(key, list);
            return this;
        }
        return addAttribute(key, CollectionUtils.toCollection(value, ArrayList.class));
    }
Factory method.

@param applicationContext  the application context
@param principal           principal.
@param principalFactory    principalFactory.
@param principalAttributes principalAttributes.
@param service             service.
@param registeredService   registeredService.
@param authentication      authentication.
@return AuthenticationBuilder new AuthenticationBuilder instance.
@throws Throwable the throwable
core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/DefaultAuthenticationBuilder.java