Package io.undertow.server.session

Examples of io.undertow.server.session.SessionManager


        if (httpSession != null && httpSession.isInvalid()) {
            exchange.removeAttachment(sessionAttachmentKey);
            httpSession = null;
        }
        if (httpSession == null) {
            final SessionManager sessionManager = deployment.getSessionManager();
            Session session = sessionManager.getSession(exchange, c);
            if (session != null) {
                httpSession = SecurityActions.forSession(session, this, false);
                exchange.putAttachment(sessionAttachmentKey, httpSession);
            } else if (create) {
                final Session newSession = sessionManager.createSession(exchange, c);
                httpSession = SecurityActions.forSession(newSession, this, true);
                exchange.putAttachment(sessionAttachmentKey, httpSession);
            }
        }
        return httpSession;
View Full Code Here


        if (httpSession != null && httpSession.isInvalid()) {
            exchange.removeAttachment(sessionAttachmentKey);
            httpSession = null;
        }
        if (httpSession == null) {
            final SessionManager sessionManager = deploymentInfo.getSessionManager();
            Session session = sessionManager.getSession(exchange, c);
            if (session != null) {
                httpSession = new HttpSessionImpl(session, this, getDeployment().getApplicationListeners(), exchange, false);
                exchange.putAttachment(sessionAttachmentKey, httpSession);
            } else if (create) {
                final Session newSession = sessionManager.createSession(exchange, c);
                httpSession = new HttpSessionImpl(newSession, this, getDeployment().getApplicationListeners(), exchange, true);
                exchange.putAttachment(sessionAttachmentKey, httpSession);
                getDeployment().getApplicationListeners().sessionCreated(httpSession);
            }
        }
View Full Code Here

            final String server = SERVER.resolveModelAttribute(context, subModel).asString();

            final ServiceController<?> controller = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path));
            final UndertowDeploymentService deploymentService = (UndertowDeploymentService) controller.getService();
            Deployment deployment = deploymentService.getDeployment();
            SessionManager sessionManager = deployment.getSessionManager();

            SessionStat stat = SessionStat.getStat(operation.require(ModelDescriptionConstants.NAME).asString());
            SessionManagerStatistics sms = sessionManager instanceof SessionManagerStatistics ? (SessionManagerStatistics) sessionManager : null;

            if (stat == null) {
                context.getFailureDescription().set(UndertowLogger.ROOT_LOGGER.unknownMetric(operation.require(ModelDescriptionConstants.NAME).asString()));
            } else {
                ModelNode result = new ModelNode();
                switch (stat) {
                    case ACTIVE_SESSIONS:
                        result.set(sessionManager.getActiveSessions().size());
                        break;
                    case EXPIRED_SESSIONS:
                        if(sms == null) {
                            result.set(0);
                        } else {
View Full Code Here

    public Iterator<Session> iterator() {
        Sessions<String> sessions = this.sso.getSessions();
        Set<String> deployments = sessions.getDeployments();
        List<Session> result = new ArrayList<>(deployments.size());
        for (String deployment: deployments) {
            SessionManager manager = this.registry.getSessionManager(deployment);
            if (manager != null) {
                String sessionId = sessions.getSession(deployment);
                if (sessionId != null) {
                    Session session = manager.getSession(sessions.getSession(deployment));
                    if (session != null) {
                        result.add(new InvalidatableSession(session));
                    }
                }
            }
View Full Code Here

    }

    @Test
    public void iterator() {
        Sessions<String> sessions = mock(Sessions.class);
        SessionManager manager = mock(SessionManager.class);
        Session session = mock(Session.class);
        String deployment = "deployment";
        String sessionId = "session";

        when(this.sso.getSessions()).thenReturn(sessions);
        when(sessions.getDeployments()).thenReturn(Collections.singleton(deployment));
        when(sessions.getSession(deployment)).thenReturn(sessionId);
        when(this.registry.getSessionManager(deployment)).thenReturn(manager);
        when(manager.getSession(sessionId)).thenReturn(session);
        when(session.getId()).thenReturn(sessionId);

        Iterator<Session> results = this.subject.iterator();

        assertTrue(results.hasNext());
        Session result = results.next();
        assertEquals(session.getId(), result.getId());
        assertFalse(results.hasNext());

        verifyZeroInteractions(this.batch);

        // Validate that returned sessions can be invalidated
        HttpServerExchange exchange = new HttpServerExchange(null);
        Session mutableSession = mock(Session.class);

        when(session.getSessionManager()).thenReturn(manager);
        when(manager.getSession(same(exchange), Matchers.<SessionConfig>any())).thenReturn(mutableSession);

        result.invalidate(exchange);

        verify(mutableSession).invalidate(same(exchange));
    }
View Full Code Here

    @Test
    public void contains() {
        String deployment = "deployment";
        Session session = mock(Session.class);
        SessionManager manager = mock(SessionManager.class);
        Sessions<String> sessions = mock(Sessions.class);

        when(session.getSessionManager()).thenReturn(manager);
        when(manager.getDeploymentName()).thenReturn(deployment);
        when(this.sso.getSessions()).thenReturn(sessions);
        when(sessions.getDeployments()).thenReturn(Collections.<String>emptySet());

        boolean result = this.subject.contains(session);
View Full Code Here

    @Test
    public void add() {
        String deployment = "deployment";
        String sessionId = "session";
        Session session = mock(Session.class);
        SessionManager manager = mock(SessionManager.class);
        Sessions<String> sessions = mock(Sessions.class);

        when(session.getId()).thenReturn(sessionId);
        when(session.getSessionManager()).thenReturn(manager);
        when(manager.getDeploymentName()).thenReturn(deployment);
        when(this.sso.getSessions()).thenReturn(sessions);

        this.subject.add(session);

        verify(sessions).addSession(deployment, sessionId);
View Full Code Here

    @Test
    public void remove() {
        String deployment = "deployment";
        Session session = mock(Session.class);
        SessionManager manager = mock(SessionManager.class);
        Sessions<String> sessions = mock(Sessions.class);

        when(session.getSessionManager()).thenReturn(manager);
        when(manager.getDeploymentName()).thenReturn(deployment);
        when(this.sso.getSessions()).thenReturn(sessions);

        this.subject.remove(session);

        verify(sessions).removeSession(deployment);
View Full Code Here

    @Test
    public void getSession() {
        String deployment = "deployment";
        String sessionId = "session";
        Session session = mock(Session.class);
        SessionManager manager = mock(SessionManager.class);
        Sessions<String> sessions = mock(Sessions.class);

        when(session.getSessionManager()).thenReturn(manager);
        when(manager.getDeploymentName()).thenReturn(deployment);
        when(this.sso.getSessions()).thenReturn(sessions);
        when(sessions.getSession(deployment)).thenReturn(sessionId);
        when(manager.getSession(sessionId)).thenReturn(session);

        Session result = this.subject.getSession(manager);

        assertSame(session, result);
View Full Code Here

     *
     * @param sessionId The session ID
     * @return The session
     */
    public HttpSessionImpl getSession(final String sessionId) {
        final SessionManager sessionManager = deployment.getSessionManager();
        Session session = sessionManager.getSession(sessionId);
        if (session != null) {
            return SecurityActions.forSession(session, this, false);
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of io.undertow.server.session.SessionManager

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.