Tabnine Logo
Session.stop
Code IndexAdd Tabnine to your IDE (free)

How to use
stop
method
in
org.apache.shiro.session.Session

Best Java code snippets using org.apache.shiro.session.Session.stop (Showing top 19 results out of 315)

origin: apache/shiro

/**
 * Immediately delegates to the underlying proxied session.
 */
public void stop() throws InvalidSessionException {
  delegate.stop();
}
origin: apache/shiro

public void invalidate() {
  try {
    getSession().stop();
  } catch (InvalidSessionException e) {
    throw new IllegalStateException(e);
  }
}
origin: apache/shiro

protected void stopSession(Subject subject) {
  Session s = subject.getSession(false);
  if (s != null) {
    s.stop();
  }
}
origin: apache/shiro

public void stop(SessionKey key) throws InvalidSessionException {
  Session session = lookupRequiredSession(key);
  try {
    if (log.isDebugEnabled()) {
      log.debug("Stopping session with id [" + session.getId() + "]");
    }
    session.stop();
    onStop(session, key);
    notifyStop(session);
  } finally {
    afterStopped(session);
  }
}
origin: wuyouzhuguli/FEBS-Shiro

@Override
public boolean forceLogout(String sessionId) {
  Session session = sessionDAO.readSession(sessionId);
  session.setTimeout(0);
  session.stop();
  sessionDAO.delete(session);
  return true;
}
origin: org.apache.shiro/shiro-core

/**
 * Immediately delegates to the underlying proxied session.
 */
public void stop() throws InvalidSessionException {
  delegate.stop();
}
origin: org.apache.shiro/shiro-core

protected void stopSession(Subject subject) {
  Session s = subject.getSession(false);
  if (s != null) {
    s.stop();
  }
}
origin: apache/shiro

@Test
public void testSessionStopThenStart() {
  String key = "testKey";
  String value = "testValue";
  DefaultSecurityManager sm = new DefaultSecurityManager();
  DelegatingSubject subject = new DelegatingSubject(sm);
  Session session = subject.getSession();
  session.setAttribute(key, value);
  assertTrue(session.getAttribute(key).equals(value));
  Serializable firstSessionId = session.getId();
  assertNotNull(firstSessionId);
  session.stop();
  session = subject.getSession();
  assertNotNull(session);
  assertNull(session.getAttribute(key));
  Serializable secondSessionId = session.getId();
  assertNotNull(secondSessionId);
  assertFalse(firstSessionId.equals(secondSessionId));
  subject.logout();
  sm.destroy();
}
origin: org.apache.shiro/shiro-core

public void stop(SessionKey key) throws InvalidSessionException {
  Session session = lookupRequiredSession(key);
  try {
    if (log.isDebugEnabled()) {
      log.debug("Stopping session with id [" + session.getId() + "]");
    }
    session.stop();
    onStop(session, key);
    notifyStop(session);
  } finally {
    afterStopped(session);
  }
}
origin: stackoverflow.com

 @Tested
Session s;

new Expectations(Session.class) {{ 
  s.stop(); times = 0; } //Session#stop must not be called
};
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 * Immediately delegates to the underlying proxied session.
 */
public void stop() throws InvalidSessionException {
  delegate.stop();
}
origin: bujiio/buji-pac4j

@Override
public boolean destroySession(final J2EContext context) {
  getSession(true).stop();
  return true;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

protected void stopSession(Subject subject) {
  Session s = subject.getSession(false);
  if (s != null) {
    s.stop();
  }
}
origin: stackoverflow.com

DefaultSecurityManager securityManager = (DefaultSecurityManager) SecurityUtils.getSecurityManager();
 DefaultSessionManager sessionManager = (DefaultSessionManager) securityManager.getSessionManager();
 Collection<Session> activeSessions = sessionManager.getSessionDAO().getActiveSessions();
 for (Session session: activeSessions){
    session.stop();
 }
origin: stackoverflow.com

 @Test
public void testWhatever (@Mocked final Session s)
{
  final Whatever w = new Whatever();
  w.method();

  new Verifications() {{ s.stop(); times = 0; }};
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

public void stop(SessionKey key) throws InvalidSessionException {
  Session session = lookupRequiredSession(key);
  if (log.isDebugEnabled()) {
    log.debug("Stopping session with id [" + session.getId() + "]");
  }
  session.stop();
  onStop(session, key);
  notifyStop(session);
  afterStopped(session);
}
origin: org.seedstack.seed/seed-web-security

  /**
   * Regenerate the session if any. This prevents a potential session fixation issue by forcing a new session id on
   * login success. See https://issues.apache.org/jira/browse/SHIRO-170.
   *
   * @param subject the successfully logged in subject
   */
  default void regenerateSession(Subject subject) {
    Session session = subject.getSession(false);
    if (session != null) {
      // Retain session attributes
      Map<Object, Object> attributes = new LinkedHashMap<>();
      for (Object key : session.getAttributeKeys()) {
        Object value = session.getAttribute(key);
        if (value != null) {
          attributes.put(key, value);
        }
      }

      // Destroy the current sessions and recreate a new one
      session.stop();
      session = subject.getSession(true);

      // Restore attributes in the new session
      for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
        session.setAttribute(entry.getKey(), entry.getValue());
      }
    }
  }
}
origin: theonedev/onedev

public void login(String userName, String password, boolean rememberMe) {
  Subject subject = SecurityUtils.getSubject();
  // Force a new session to prevent session fixation attack.
  // We have to invalidate via both Shiro and Wicket; otherwise it doesn't
  // work.
  subject.getSession().stop();
  WebSession.get().replaceSession(); 
  UsernamePasswordToken token;
  token = new UsernamePasswordToken(userName, password, rememberMe);
  
  subject.login(token);
}

origin: 417511458/jbone

  /**
   * 销毁Session
   * @param context
   * @param ticket
   */
  public void destroySession(C context, final String ticket) {
    ProfileManager manager = new ProfileManager(context);
    manager.logout();

    Serializable sessionId = sessionTicketStore.getSessionId(ticket);
    if (sessionId != null) {
      try {
        Session session = sessionManager.getSession(new DefaultSessionKey(sessionId));
        session.stop();
      } catch (Exception e) {
        logger.warn(e.getMessage());
      }
    }
    sessionTicketStore.deleteByTicket(ticket);
  }
}
org.apache.shiro.sessionSessionstop

Javadoc

Explicitly stops (invalidates) this session and releases all associated resources.

If this session has already been authenticated (i.e. the Subject that owns this session has logged-in), calling this method explicitly might have undesired side effects:

It is common for a Subject implementation to retain authentication state in the Session. If the session is explicitly stopped by application code by calling this method directly, it could clear out any authentication state that might exist, thereby effectively "unauthenticating" the Subject.

As such, you might consider org.apache.shiro.subject.Subject#logout the 'owning' Subject instead of manually calling this method, as a log out is expected to stop the corresponding session automatically, and also allows framework code to execute additional cleanup logic.

Popular methods of Session

  • getAttribute
    Returns the object bound to this session identified by the specified key. If there is no object boun
  • setAttribute
    Binds the specified value to this session, uniquely identified by the specifed key name. If there is
  • getId
    Returns the unique identifier assigned by the system upon session creation. All return values from t
  • removeAttribute
    Removes (unbinds) the object bound to this session under the specified key name.
  • getHost
    Returns the host name or IP string of the host that originated this session, or nullif the host is u
  • getTimeout
    Returns the time in milliseconds that the session session may remain idle before expiring. * A negat
  • getLastAccessTime
    Returns the last time the application received a request or method invocation from the user associat
  • getStartTimestamp
    Returns the time the session was started; that is, the time the system created the instance.
  • setTimeout
    Sets the time in milliseconds that the session may remain idle before expiring. * A negative val
  • getAttributeKeys
    Returns the keys of all the attributes stored under this session. If there are no attributes, this r
  • touch
    Explicitly updates the #getLastAccessTime() of this session to the current time when this method is
  • touch

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSharedPreferences (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now