/** * Helper method that evaluates a {@link Principal} object against this context * to determine if the input is compatible with it. * * @param <T> type of principal * @param principal principal to evaluate * * @return true iff the input is compatible with the requested authentication requirements */ public <T extends Principal> boolean isAcceptable(@Nonnull final T principal) { return isAcceptable(new PrincipalSupportingComponent() { public <TT extends Principal> Set<TT> getSupportedPrincipals(final Class<TT> c) { if (c.isAssignableFrom(principal.getClass())) { return Collections.singleton((TT) principal); } else { return Collections.emptySet(); } } }); }
/** * Helper method that evaluates a {@link Principal} object against a {@link RequestedPrincipalContext} child * of this context, if present, to determine if the input is compatible with it. * * @param <T> type of principal * @param principal principal to evaluate * * @return true iff the input is compatible with the requested authentication requirements or if * no such requirements have been imposed */ public <T extends Principal> boolean isAcceptable(@Nonnull final T principal) { final RequestedPrincipalContext rpCtx = getSubcontext(RequestedPrincipalContext.class); if (rpCtx != null) { return rpCtx.isAcceptable(principal); } else { // No requirements so anything is acceptable. return true; } }
/** * Helper method that evaluates a {@link PrincipalSupportingComponent} against a * {@link RequestedPrincipalContext} child of this context, if present, to determine * if the input is compatible with it. * * @param component component to evaluate * * @return true iff the input is compatible with the requested authentication requirements or if * no such requirements have been imposed */ public boolean isAcceptable(@Nonnull final PrincipalSupportingComponent component) { final RequestedPrincipalContext rpCtx = getSubcontext(RequestedPrincipalContext.class); if (rpCtx != null) { return rpCtx.isAcceptable(component); } else { // No requirements so anything is acceptable. return true; } }
/** * Helper method that evaluates {@link Principal} objects against this context * to determine if the input is compatible with it. * * @param principals principal(s) to evaluate * * @return true iff the input is compatible with the requested authentication requirements * * @since 3.3.0 */ public boolean isAcceptable(@Nonnull @NonnullElements final Collection<Principal> principals) { return isAcceptable(new PrincipalSupportingComponent() { public <T extends Principal> Set<T> getSupportedPrincipals(final Class<T> c) { final HashSet set = new HashSet<>(); for (final Principal p : principals) { if (c.isAssignableFrom(p.getClass())) { set.add(p); } } return set; } }); }
/** * Helper method that evaluates {@link Principal} objects against a {@link RequestedPrincipalContext} child * of this context, if present, to determine if the input is compatible with them. * * @param principals principal(s) to evaluate * * @return true iff the input is compatible with the requested authentication requirements or if * no such requirements have been imposed */ public boolean isAcceptable(@Nonnull @NonnullElements final Collection<Principal> principals) { final RequestedPrincipalContext rpCtx = getSubcontext(RequestedPrincipalContext.class); if (rpCtx != null) { return rpCtx.isAcceptable(principals); } else { // No requirements so anything is acceptable. return true; } }