@Override public boolean isSatisfiedBy(final Authentication authn) { boolean credsOk = true; if (this.tryAll) { credsOk = authn.getCredentials().size() == authn.getSuccesses().size() + authn.getFailures().size(); } return credsOk && StringUtils.isNotBlank(this.requiredHandlerName) && authn.getSuccesses().containsKey(this.requiredHandlerName); } }
@Override public boolean isSatisfiedBy(final Authentication authn) { if (this.tryAll) { return authn.getCredentials().size() == authn.getSuccesses().size() + authn.getFailures().size(); } return !authn.getSuccesses().isEmpty(); } }
/** * Creates a new instance from an authentication event that was successful prior to principal resolution. * * @param authentication Authentication event. */ public UnresolvedPrincipalException(final Authentication authentication) { super(UNRESOLVED_PRINCIPAL, authentication.getFailures(), authentication.getSuccesses()); }
/** * Creates a new instance from an authentication event that was successful prior to principal resolution. * This form should be used when a resolver exception prevented principal resolution. * * @param authentication Authentication event. * @param cause Exception that prevented principal resolution. */ public UnresolvedPrincipalException(final Authentication authentication, final Exception cause) { super(cause.getMessage(), authentication.getFailures(), authentication.getSuccesses()); } }
@Override public boolean isSatisfiedBy(final Authentication authn) { return authn.getSuccesses().size() == authn.getCredentials().size(); } }
/** * Creates a new instance from what would otherwise have been a successful authentication event and the two * disparate principals resolved. * * @param authentication Authentication event. * @param a First resolved principal. * @param b Second resolved principal. */ public MixedPrincipalException(final Authentication authentication, final Principal a, final Principal b) { super(a + " != " + b, authentication.getFailures(), authentication.getSuccesses()); this.first = a; this.second = b; }
@Override public boolean isSatisfiedBy(final Authentication authentication) { for (final String required : context.getRegisteredService().getRequiredHandlers()) { if (!authentication.getSuccesses().containsKey(required)) { return false; } } return true; } };
/** * Add authentication method attribute. * * @param builder the builder * @param authentication the authentication */ private void addAuthenticationMethodAttribute(final AuthenticationBuilder builder, final Authentication authentication) { for (final HandlerResult result : authentication.getSuccesses().values()) { builder.addAttribute(AUTHENTICATION_METHOD_ATTRIBUTE, result.getHandlerName()); } }
@Override public boolean equals(final Object obj) { if (!(obj instanceof Authentication)) { return false; } if (obj == this) { return true; } final Authentication other = (Authentication) obj; final EqualsBuilder builder = new EqualsBuilder(); builder.append(this.principal, other.getPrincipal()); builder.append(this.credentials, other.getCredentials()); builder.append(this.successes, other.getSuccesses()); builder.append(this.authenticationDate, other.getAuthenticationDate()); builder.append(wrap(this.attributes), other.getAttributes()); builder.append(wrap(this.failures), other.getFailures()); return builder.isEquals(); }
authenticationAttributes); authenticationBuilder.addSuccesses(authn.getSuccesses()) .addFailures(authn.getFailures()) .addCredentials(authn.getCredentials());
successes.putAll(authn.getSuccesses()); failures.putAll(authn.getFailures());
/** * Creates a new builder initialized with data from the given authentication source. * * @param source Authentication source. * * @return New builder instance initialized with all fields in the given authentication source. */ public static AuthenticationBuilder newInstance(final Authentication source) { final DefaultAuthenticationBuilder builder = new DefaultAuthenticationBuilder(source.getPrincipal()); builder.setAuthenticationDate(source.getAuthenticationDate()); builder.setCredentials(source.getCredentials()); builder.setSuccesses(source.getSuccesses()); builder.setFailures(source.getFailures()); builder.setAttributes(source.getAttributes()); return builder; }