Examples of SessionDestroyedEvent


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

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

        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

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

        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

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

        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

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

        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

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

        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

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

        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

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

        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

Examples of org.springframework.session.events.SessionDestroyedEvent

    private final ConcurrentHashMap<String,Map<String,WebSocketSession>> httpSessionIdToWsSessions = new ConcurrentHashMap<String,Map<String,WebSocketSession>>();

    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        if(event instanceof SessionDestroyedEvent) {
            SessionDestroyedEvent e = (SessionDestroyedEvent) event;
            closeWsSessions(e.getSessionId());
        } else if(event instanceof SessionConnectEvent) {
            SessionConnectEvent e = (SessionConnectEvent) event;
            afterConnectionEstablished(e.getWebSocketSession());
        } else if(event instanceof SessionDisconnectEvent) {
            SessionDisconnectEvent e = (SessionDisconnectEvent) event;
            Map<String, Object> sessionAttributes = SimpMessageHeaderAccessor.getSessionAttributes(e.getMessage().getHeaders());
            String httpSessionId =  sessionAttributes == null ? null : SessionRepositoryMessageInterceptor.getSessionId(sessionAttributes);
            afterConnectionClosed(httpSessionId, e.getSessionId());
        }
    }
View Full Code Here

Examples of org.springframework.session.events.SessionDestroyedEvent

        String channel = new String(message.getChannel());
        int beginIndex = channel.lastIndexOf(":") + 1;
        int endIndex = channel.length();
        String sessionId = channel.substring(beginIndex, endIndex);

        publishEvent(new SessionDestroyedEvent(this, sessionId));
    }
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.