/** {@inheritDoc} */ @Override @Nullable public T apply(@Nullable final ProfileRequestContext input) { final AuthenticationContext ac = authnContextLookupStrategy.apply(input); if (ac == null || ac.getAuthenticationResult() == null) { return defaultPrincipal; } final Set<T> principals = ac.getAuthenticationResult().getSupportedPrincipals(principalType); if (principals.isEmpty()) { return defaultPrincipal; } else if (principals.size() == 1 || weightMap.isEmpty()) { return principals.iterator().next(); } final Object[] principalArray = principals.toArray(); Arrays.sort(principalArray, new WeightedComparator()); return (T) principalArray[principalArray.length - 1]; }
/** * Compare the result's custom principal names to the string values of the attribute. * * @param result result to examine * * @return a match between the result's principal names and the attribute's string values, or null */ @Nullable private String getMatch(@Nonnull final AuthenticationResult result) { log.debug("{} Looking for match for active result of flow {} against values for attribute {}", getLogPrefix(), result.getAuthenticationFlowId(), attribute.getId()); for (final Principal p : result.getSupportedPrincipals(Principal.class)) { log.debug("{} Comparing principal {} against attribute values {}", getLogPrefix(), p.getName(), attribute.getValues()); for (final IdPAttributeValue val : attribute.getValues()) { if (val instanceof StringAttributeValue && Objects.equals(val.getValue(), p.getName())) { return p.getName(); } } } return null; }
: authenticationContext.getAuthenticationResult().getSupportedPrincipals(p.getClass())) { if (predicate.apply(new PrincipalSupportingComponent() { public <T extends Principal> Set<T> getSupportedPrincipals(final Class<T> c) {
if (!latest.getSupportedPrincipals(match.getClass()).contains(match)) { log.debug("{} Authentication result lacks originally projected matching principal '{}'," + " reevaluating", getLogPrefix(), match.getName());