/** {@inheritDoc} */ @Nullable public AuthenticationResult apply(@Nullable final ProfileRequestContext input) { if (input != null) { final AuthenticationContext authnContext = input.getSubcontext(AuthenticationContext.class); if (authnContext != null) { final MultiFactorAuthenticationContext mfaContext = authnContext.getSubcontext(MultiFactorAuthenticationContext.class); if (mfaContext != null) { final Collection<AuthenticationResult> results = mfaContext.getActiveResults().values(); if (!results.isEmpty()) { final Subject subject = new Subject(); for (final AuthenticationResult result : results) { subject.getPrincipals().add(new AuthenticationResultPrincipal(result)); subject.getPrincipals().addAll(result.getSubject().getPrincipals()); subject.getPublicCredentials().addAll(result.getSubject().getPublicCredentials()); subject.getPrivateCredentials().addAll(result.getSubject().getPrivateCredentials()); } final AuthenticationResult merged = new AuthenticationResult( mfaContext.getAuthenticationFlowDescriptor().getId(), subject); return merged; } } } } return null; }
authenticationContext.setAttemptedFlow(mfaContext.getAuthenticationFlowDescriptor());