/** * Get an immutable list of Subjects extracted from every AuthenticationResult * associated with the context. * * @return immutable list of Subjects */ @Nonnull @NonnullElements @Unmodifiable @NotLive public List<Subject> getSubjects() { final List<Subject> composite = new ArrayList<>(); for (final AuthenticationResult e : getAuthenticationResults().values()) { composite.add(e.getSubject()); } return ImmutableList.copyOf(composite); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final AuthenticationContext authenticationContext) { if (canonicalPrincipalName != null) { final SubjectContext sc = profileRequestContext.getSubcontext(SubjectContext.class, true); // Check for an existing value. if (sc.getPrincipalName() != null && !canonicalPrincipalName.equals(sc.getPrincipalName())) { log.warn("{} Result of authentication ({}) does not match existing subject in context ({})", getLogPrefix(), canonicalPrincipalName, sc.getPrincipalName()); ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_SUBJECT_CTX); return; } sc.setPrincipalName(canonicalPrincipalName); final Map scResults = sc.getAuthenticationResults(); scResults.putAll(authenticationContext.getActiveResults()); final AuthenticationResult latest = authenticationContext.getAuthenticationResult(); if (latest != null && !scResults.containsKey(latest.getAuthenticationFlowId())) { scResults.put(latest.getAuthenticationFlowId(), latest); } } authenticationContext.setCompletionInstant(); }