@Test public void testOnSuccessfulAuthentication() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain filterChain = new MockFilterChain(); request.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + getEncoder().encodeToString(new String("user:password").getBytes())); request.addHeader(X_IDP_ENTITY_ID, PolicyLoader.authenticatingAuthority); request.addHeader(X_UNSPECIFIED_NAME_ID, "uid"); request.addHeader(X_DISPLAY_NAME, "John Doe"); subject.doFilter(request, response, filterChain); RunAsFederatedUser user = (RunAsFederatedUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); assertEquals("uid", user.getIdentifier()); assertEquals("John Doe", user.getDisplayName()); assertEquals(1, user.getIdpEntities().size()); assertEquals(1, user.getSpEntities().size()); assertEquals(PolicyLoader.authenticatingAuthority, user.getAuthenticatingAuthority()); assertEquals("[ROLE_PEP, ROLE_USER]", user.getAuthorities().toString()); }
@Override protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException { Optional<FederatedUser> runAsFederatedUserOptional = federatedUserBuilder.basicAuthUser(request, authResult.getAuthorities()); if (runAsFederatedUserOptional.isPresent()) { SecurityContextHolder.getContext().setAuthentication(new PolicyIdpAccessAwareToken((RunAsFederatedUser) runAsFederatedUserOptional.get())); } }
PolicyIdpAccessEnforcerFilter extends BasicAuthenticationFilter { @Override protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException { Optional<FederatedUser> runAsFederatedUserOptional = federatedUserBuilder.basicAuthUser(request, authResult.getAuthorities()); if (runAsFederatedUserOptional.isPresent()) { SecurityContextHolder.getContext().setAuthentication(new PolicyIdpAccessAwareToken((RunAsFederatedUser) runAsFederatedUserOptional.get())); } } }
PolicyIdpAccessEnforcerFilter extends BasicAuthenticationFilter { @Override protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException { Optional<FederatedUser> runAsFederatedUserOptional = federatedUserBuilder.basicAuthUser(request, authResult.getAuthorities()); if (runAsFederatedUserOptional.isPresent()) { SecurityContextHolder.getContext().setAuthentication(new PolicyIdpAccessAwareToken((RunAsFederatedUser) runAsFederatedUserOptional.get())); } } PolicyIdpAccessEnforcerFilter(AuthenticationManager authenticationManager, Manage manage); }
PolicyIdpAccessEnforcerFilter extends BasicAuthenticationFilter { @Override protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException { Optional<FederatedUser> runAsFederatedUserOptional = federatedUserBuilder.basicAuthUser(request, authResult.getAuthorities()); if (runAsFederatedUserOptional.isPresent()) { SecurityContextHolder.getContext().setAuthentication(new PolicyIdpAccessAwareToken((RunAsFederatedUser) runAsFederatedUserOptional.get())); } } PolicyIdpAccessEnforcerFilter(AuthenticationManager authenticationManager, Manage manage);  }
PolicyIdpAccessEnforcerFilter extends BasicAuthenticationFilter { @Override protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException { Optional<FederatedUser> runAsFederatedUserOptional = federatedUserBuilder.basicAuthUser(request, authResult.getAuthorities()); if (runAsFederatedUserOptional.isPresent()) { SecurityContextHolder.getContext().setAuthentication(new PolicyIdpAccessAwareToken((RunAsFederatedUser) runAsFederatedUserOptional.get())); } } PolicyIdpAccessEnforcerFilter(AuthenticationManager authenticationManager, Manage manage);   }