Package org.apache.shiro.session

Examples of org.apache.shiro.session.Session


        }
        return null;
    }

    private void clearRunAsIdentities() {
        Session session = getSession(false);
        if (session != null) {
            session.removeAttribute(RUN_AS_PRINCIPALS_SESSION_KEY);
        }
        this.runAsPrincipals = null;
    }
View Full Code Here


        }
        if (this.runAsPrincipals == null) {
            this.runAsPrincipals = new ArrayList<PrincipalCollection>();
        }
        this.runAsPrincipals.add(0, principals);
        Session session = getSession();
        session.setAttribute(RUN_AS_PRINCIPALS_SESSION_KEY, this.runAsPrincipals);
    }
View Full Code Here

    private PrincipalCollection popIdentity() {
        PrincipalCollection popped = null;
        if (!CollectionUtils.isEmpty(this.runAsPrincipals)) {
            popped = this.runAsPrincipals.remove(0);
            Session session;
            if (!CollectionUtils.isEmpty(this.runAsPrincipals)) {
                //persist the changed deque to the session
                session = getSession();
                session.setAttribute(RUN_AS_PRINCIPALS_SESSION_KEY, this.runAsPrincipals);
            } else {
                //deque is empty, remove it from the session:
                session = getSession(false);
                if (session != null) {
                    session.removeAttribute(RUN_AS_PRINCIPALS_SESSION_KEY);
                }
            }
        }

        return popped;
View Full Code Here

    protected void bind(Subject subject) {
        // TODO consider refactoring to use Subject.Binder.
        // This implementation was copied from SessionSubjectBinder that was removed
        PrincipalCollection principals = subject.getPrincipals();
        if (principals != null && !principals.isEmpty()) {
            Session session = subject.getSession();
            bindPrincipalsToSession(principals, session);
        } else {
            Session session = subject.getSession(false);
            if (session != null) {
                session.removeAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
            }
        }

        if (subject.isAuthenticated()) {
            Session session = subject.getSession();
            session.setAttribute(DefaultSubjectContext.AUTHENTICATED_SESSION_KEY, subject.isAuthenticated());
        } else {
            Session session = subject.getSession(false);
            if (session != null) {
                session.removeAttribute(DefaultSubjectContext.AUTHENTICATED_SESSION_KEY);
            }
        }
    }
View Full Code Here

            return context;
        }
        try {
            //Context couldn't resolve it directly, let's see if we can since we have direct access to
            //the session manager:
            Session session = resolveContextSession(context);
            if (session != null) {
                context.setSession(session);
            }
        } catch (InvalidSessionException e) {
            log.debug("Resolved SubjectContext context session is invalid.  Ignoring and creating an anonymous " +
View Full Code Here

        SecurityManager securityManager = context.resolveSecurityManager();
        if (securityManager == null) {
            throw new IllegalStateException("SecurityManager instance should already be present in the " +
                    "SubjectContext argument.");
        }
        Session session = context.resolveSession();
        if (session == null) {
            log.trace("No session in the current subject context.  One will be created to persist principals [{}] " +
                    "Doing this prevents unnecessary repeated RememberMe operations since an identity has been " +
                    "discovered.", principals);
            //no session - start one:
            SessionContext sessionContext = createSessionContext(context);
            session = start(sessionContext);
            context.setSession(session);
            log.debug("Created session with id {} to retain discovered principals {}", session.getId(), principals);
        }
        bindPrincipalsToSession(principals, session);
    }
View Full Code Here

            }
        }
    }

    protected void stopSession(Subject subject) {
        Session s = subject.getSession(false);
        if (s != null) {
            s.stop();
        }
    }
View Full Code Here

     * does not do anything.
     *
     * @param subject the subject to unbind from the application as it will no longer be used.
     */
    protected void unbind(Subject subject) {
        Session session = subject.getSession(false);
        if (session != null) {
            session.removeAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
            session.removeAttribute(DefaultSubjectContext.AUTHENTICATED_SESSION_KEY);
        }
    }
View Full Code Here

    public DefaultSubjectFactory() {
    }

    public Subject createSubject(SubjectContext context) {
        SecurityManager securityManager = context.resolveSecurityManager();
        Session session = context.resolveSession();
        PrincipalCollection principals = context.resolvePrincipals();
        boolean authenticated = context.resolveAuthenticated();
        String host = context.resolveHost();
        return newSubjectInstance(principals, authenticated, host, session, securityManager);
    }
View Full Code Here

            ((CacheManagerAware) this.sessionDAO).setCacheManager(this.cacheManager);
        }
    }

    protected Session doCreateSession(SessionContext context) {
        Session s = newSessionInstance(context);
        if (log.isTraceEnabled()) {
            log.trace("Creating session for host {}", s.getHost());
        }
        create(s);
        return s;
    }
View Full Code Here

TOP

Related Classes of org.apache.shiro.session.Session

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.