Examples of SecurityContextImpl


Examples of org.springframework.security.core.context.SecurityContextImpl

        assertSame(session.getAttribute("context"), securityContexts.get(0));
    }

    @Test
    public void getSecurityContextsMulti() {
        session.setAttribute("another", new SecurityContextImpl());
        List<SecurityContext> securityContexts = destroyedEvent.getSecurityContexts();
        assertEquals(2,securityContexts.size());
    }
View Full Code Here

Examples of org.springframework.security.core.context.SecurityContextImpl

    public void loadedContextContextIsCopiedToSecurityContextHolderAndUpdatedContextIsStored() throws Exception {
        final MockHttpServletRequest request = new MockHttpServletRequest();
        final MockHttpServletResponse response = new MockHttpServletResponse();
        SecurityContextPersistenceFilter filter = new SecurityContextPersistenceFilter();
        final TestingAuthenticationToken beforeAuth = new TestingAuthenticationToken("someoneelse", "passwd", "ROLE_B");
        final SecurityContext scBefore = new SecurityContextImpl();
        final SecurityContext scExpectedAfter = new SecurityContextImpl();
        scExpectedAfter.setAuthentication(testToken);
        scBefore.setAuthentication(beforeAuth);
        final SecurityContextRepository repo = mock(SecurityContextRepository.class);
        filter.setSecurityContextRepository(repo);

        when(repo.loadContext(any(HttpRequestResponseHolder.class))).thenReturn(scBefore);
View Full Code Here

Examples of org.springframework.security.core.context.SecurityContextImpl

        WASUsernameAndGroupsExtractor helper = mock(WASUsernameAndGroupsExtractor.class);
        when(helper.getCurrentUserName()).thenReturn("joe");
        WebSphere2SpringSecurityPropagationInterceptor interceptor =
            new WebSphere2SpringSecurityPropagationInterceptor(helper);

        final SecurityContext context = new SecurityContextImpl();

        interceptor.setAuthenticationManager(new AuthenticationManager() {
            public Authentication authenticate(Authentication authentication) {
                // Store the auth object
                context.setAuthentication(authentication);
                return null;
            }
        });
        interceptor.setAuthenticationDetailsSource(mock(AuthenticationDetailsSource.class));
        interceptor.invoke(mock(MethodInvocation.class));

        PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();
        AuthenticationUserDetailsService uds = mock(AuthenticationUserDetailsService.class);
        UserDetails user = mock(UserDetails.class);
        List authorities = AuthorityUtils.createAuthorityList("SOME_ROLE");
        when(user.getAuthorities()).thenReturn(authorities);
        when(uds.loadUserDetails(any(Authentication.class))).thenReturn(user);
        provider.setPreAuthenticatedUserDetailsService(uds);
        provider.setUserDetailsChecker(mock(UserDetailsChecker.class));

        assertNotNull(provider.authenticate(context.getAuthentication()));
    }
View Full Code Here

Examples of org.springframework.security.core.context.SecurityContextImpl

    @Before
    public void setUp() throws Exception {
        // store initial security context for later restoration
        initialSecurityContext = SecurityContextHolder.getContext();

        SecurityContext context = new SecurityContextImpl();
        User user = new User("user");
        user.setId(1L);
        user.setPassword("password");
        user.addRole(new Role(Constants.USER_ROLE));

        UsernamePasswordAuthenticationToken token =
                new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword(), user.getAuthorities());
        token.setDetails(user);
        context.setAuthentication(token);
        SecurityContextHolder.setContext(context);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.