Package org.springframework.security.core.session

Examples of org.springframework.security.core.session.SessionDestroyedEvent


        // Register new Session
        sessionRegistry.registerNewSession(sessionId, principal);

        // De-register session via an ApplicationEvent
        sessionRegistry.onApplicationEvent(new SessionDestroyedEvent("") {
            @Override
            public String getId() {
                return sessionId;
            }
View Full Code Here


        JaasAuthenticationToken token = new JaasAuthenticationToken(null, null, loginContext);

        SecurityContext context = SecurityContextHolder.createEmptyContext();
        context.setAuthentication(token);

        SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);
        when(event.getSecurityContexts()).thenReturn(Arrays.asList(context));

        jaasProvider.handleLogout(event);

        assertTrue(loginContext.loggedOut);
    }
View Full Code Here

        verifyFailedLogin();
    }

    @Test
    public void logout() throws Exception {
        SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);
        SecurityContext securityContext = mock(SecurityContext.class);
        JaasAuthenticationToken token = mock(JaasAuthenticationToken.class);
        LoginContext context = mock(LoginContext.class);

        when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext));
        when(securityContext.getAuthentication()).thenReturn(token);
        when(token.getLoginContext()).thenReturn(context);

        provider.onApplicationEvent(event);
View Full Code Here

        verifyNoMoreInteractions(event, securityContext, token, context);
    }

    @Test
    public void logoutNullSession() {
        SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);

        provider.handleLogout(event);

        verify(event).getSecurityContexts();
        verify(log).debug(anyString());
View Full Code Here

        verifyNoMoreInteractions(event);
    }

    @Test
    public void logoutNullAuthentication() {
        SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);
        SecurityContext securityContext = mock(SecurityContext.class);

        when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext));

        provider.handleLogout(event);

        verify(event).getSecurityContexts();
        verify(event).getSecurityContexts();
View Full Code Here

        verifyNoMoreInteractions(event, securityContext);
    }

    @Test
    public void logoutNonJaasAuthentication() {
        SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);
        SecurityContext securityContext = mock(SecurityContext.class);

        when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext));
        when(securityContext.getAuthentication()).thenReturn(token);

        provider.handleLogout(event);

        verify(event).getSecurityContexts();
View Full Code Here

        verifyNoMoreInteractions(event, securityContext);
    }

    @Test
    public void logoutNullLoginContext() throws Exception {
        SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);
        SecurityContext securityContext = mock(SecurityContext.class);
        JaasAuthenticationToken token = mock(JaasAuthenticationToken.class);

        when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext));
        when(securityContext.getAuthentication()).thenReturn(token);

        provider.onApplicationEvent(event);
        verify(event).getSecurityContexts();
        verify(securityContext).getAuthentication();
View Full Code Here

        verifyNoMoreInteractions(event, securityContext, token);
    }

    @Test
    public void logoutLoginException() throws Exception {
        SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);
        SecurityContext securityContext = mock(SecurityContext.class);
        JaasAuthenticationToken token = mock(JaasAuthenticationToken.class);
        LoginContext context = mock(LoginContext.class);
        LoginException loginException = new LoginException("Failed Login");

        when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext));
        when(securityContext.getAuthentication()).thenReturn(token);
        when(token.getLoginContext()).thenReturn(context);
        doThrow(loginException).when(context).logout();

        provider.onApplicationEvent(event);
View Full Code Here

TOP

Related Classes of org.springframework.security.core.session.SessionDestroyedEvent

Copyright © 2018 www.massapicom. 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.