Package org.apache.shiro.session

Examples of org.apache.shiro.session.Session.removeAttribute()



        //会话属性操作
        session.setAttribute("key", "123");
        Assert.assertEquals("123", session.getAttribute("key"));
        session.removeAttribute("key");
    }

}
View Full Code Here


    }

    private void clearRunAsIdentities() {
        Session session = getSession(false);
        if (session != null) {
            session.removeAttribute(RUN_AS_PRINCIPALS_SESSION_KEY);
        }
    }

    private void pushIdentity(PrincipalCollection principals) throws NullPointerException {
        if (isEmpty(principals)) {
View Full Code Here

    if (value != null) {
      Session session = currentUser.getSession();
      session.setAttribute(name, value);
    } else {
      Session session = currentUser.getSession(false);
      session.removeAttribute(name);
    }
  }
}
View Full Code Here

   */
  @Override
  protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response) throws Exception {
   
    Session session = SystemVariableUtils.getSession();
    session.removeAttribute(getLoginIncorrectNumberKeyAttribute());
    session.setAttribute("sv", subject.getPrincipal());
   
    return super.onLoginSuccess(token, subject, request, response);
  }

View Full Code Here

            PrincipalCollection existingPrincipals =
                    (PrincipalCollection) session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);

            if (isEmpty(currentPrincipals)) {
                if (!isEmpty(existingPrincipals)) {
                    session.removeAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
                }
                // otherwise both are null or empty - no need to update the session
            } else {
                if (!currentPrincipals.equals(existingPrincipals)) {
                    session.setAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY, currentPrincipals);
View Full Code Here

                }
                //otherwise authc state matches - no need to update the session
            } else {
                if (existingAuthc != null) {
                    //existing doesn't match the current state - remove it:
                    session.removeAttribute(DefaultSubjectContext.AUTHENTICATED_SESSION_KEY);
                }
                //otherwise not in the session and not authenticated - no need to update the session
            }
        }
    }
View Full Code Here

     * @param subject the subject for which any existing subject state will be removed from its session.
     */
    protected void removeFromSession(Subject subject) {
        Session session = subject.getSession(false);
        if (session != null) {
            session.removeAttribute(DefaultSubjectContext.AUTHENTICATED_SESSION_KEY);
            session.removeAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
        }
    }

    /**
 
View Full Code Here

     */
    protected void removeFromSession(Subject subject) {
        Session session = subject.getSession(false);
        if (session != null) {
            session.removeAttribute(DefaultSubjectContext.AUTHENTICATED_SESSION_KEY);
            session.removeAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
        }
    }

    /**
     * Removes any existing subject state from the subject's session (if the session exists).
View Full Code Here

    }

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

    private void pushIdentity(PrincipalCollection principals) throws NullPointerException {
View Full Code Here

                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

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.