Tabnine Logo
SessionDAO
Code IndexAdd Tabnine to your IDE (free)

How to use
SessionDAO
in
org.apache.shiro.session.mgt.eis

Best Java code snippets using org.apache.shiro.session.mgt.eis.SessionDAO (Showing top 20 results out of 315)

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: apache/shiro

protected void onChange(Session session) {
  sessionDAO.update(session);
}
origin: apache/shiro

/**
 * Persists the given session instance to an underlying EIS (Enterprise Information System).  This implementation
 * delegates and calls
 * <code>this.{@link SessionDAO sessionDAO}.{@link SessionDAO#create(org.apache.shiro.session.Session) create}(session);<code>
 *
 * @param session the Session instance to persist to the underlying EIS.
 */
protected void create(Session session) {
  if (log.isDebugEnabled()) {
    log.debug("Creating new EIS record for new session instance [" + session + "]");
  }
  sessionDAO.create(session);
}
origin: apache/shiro

expect(sessionDAO.create(eq(session1))).andReturn(sessionId1);
sessionDAO.update(eq(session1));
expectLastCall().anyTimes();
replay(sessionDAO);
reset(sessionDAO);
expect(sessionDAO.readSession(sessionId1)).andReturn(session1).anyTimes();
sessionDAO.update(eq(session1));
replay(sessionDAO);
sm.setTimeout(new DefaultSessionKey(sessionId1), 1);
expect(sessionDAO.readSession(sessionId1)).andReturn(session1);
sessionDAO.update(eq(session1)); //update's the stop timestamp
sessionDAO.delete(session1);
replay(sessionDAO);
origin: apache/shiro

protected Session retrieveSessionFromDataSource(Serializable sessionId) throws UnknownSessionException {
  return sessionDAO.readSession(sessionId);
}
origin: apache/shiro

protected void delete(Session session) {
  sessionDAO.delete(session);
}
origin: com.intoverflow.booster/booster-core

Session session = subject.getSession(false);
if (session != null) {
  session = sessionDAO.readSession(session.getId());
    onlineSession.stop();
    onlineSession.setStatus(OnlineStatus.OFFLINE);
    sessionDAO.update(onlineSession);
    request.setAttribute(RESPONSE_REPLY_CODE, ReplyCode.TxnSessionKickedOut);
    request.setAttribute(RESPONSE_REDIRECT_URL, shiroEnv.getUserForceLogoutUrl());
      onlineSession.setUserId(principal.getUserId());
    sessionDAO.update(onlineSession);
origin: apache/shiro

protected Collection<Session> getActiveSessions() {
  Collection<Session> active = sessionDAO.getActiveSessions();
  return active != null ? active : Collections.<Session>emptySet();
}
origin: org.apache.shiro/shiro-core

protected Session retrieveSessionFromDataSource(Serializable sessionId) throws UnknownSessionException {
  return sessionDAO.readSession(sessionId);
}
origin: org.apache.shiro/shiro-core

protected void delete(Session session) {
  sessionDAO.delete(session);
}
origin: org.apache.shiro/shiro-core

protected Collection<Session> getActiveSessions() {
  Collection<Session> active = sessionDAO.getActiveSessions();
  return active != null ? active : Collections.<Session>emptySet();
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

protected Session retrieveSessionFromDataSource(Serializable sessionId) throws UnknownSessionException {
  return sessionDAO.readSession(sessionId);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

protected void delete(Session session) {
  sessionDAO.delete(session);
}
origin: org.apache.shiro/shiro-core

protected void onChange(Session session) {
  sessionDAO.update(session);
}
origin: wuyouzhuguli/FEBS-Shiro

@Override
public List<UserOnline> list() {
  List<UserOnline> list = new ArrayList<>();
  Collection<Session> sessions = sessionDAO.getActiveSessions();
  for (Session session : sessions) {
    UserOnline userOnline = new UserOnline();
    User user;
    SimplePrincipalCollection principalCollection;
    if (session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY) == null) {
      continue;
    } else {
      principalCollection = (SimplePrincipalCollection) session
          .getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
      user = (User) principalCollection.getPrimaryPrincipal();
      userOnline.setUsername(user.getUsername());
      userOnline.setUserId(user.getUserId().toString());
    }
    userOnline.setId((String) session.getId());
    userOnline.setHost(session.getHost());
    userOnline.setStartTimestamp(session.getStartTimestamp());
    userOnline.setLastAccessTime(session.getLastAccessTime());
    long timeout = session.getTimeout();
    userOnline.setStatus(timeout == 0L ? "0" : "1");
    String address = AddressUtils.getCityInfo(userOnline.getHost());
    userOnline.setLocation(address);
    userOnline.setTimeout(timeout);
    list.add(userOnline);
  }
  return list;
}
origin: org.apache.shiro/shiro-core

/**
 * Persists the given session instance to an underlying EIS (Enterprise Information System).  This implementation
 * delegates and calls
 * <code>this.{@link SessionDAO sessionDAO}.{@link SessionDAO#create(org.apache.shiro.session.Session) create}(session);<code>
 *
 * @param session the Session instance to persist to the underlying EIS.
 */
protected void create(Session session) {
  if (log.isDebugEnabled()) {
    log.debug("Creating new EIS record for new session instance [" + session + "]");
  }
  sessionDAO.create(session);
}
origin: huangjian888/jeeweb-mybatis-springboot

@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
    throws Exception {
  Subject subject = getSubject(request, response);
  if (subject == null || subject.getSession() == null) {
    return true;
  }
  Session session = sessionDAO.readSession(subject.getSession().getId());
  if (session != null && session instanceof OnlineSession) {
    OnlineSession onlineSession = (OnlineSession) session;
    request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession);
    // 把user id设置进去
    //boolean isGuest = onlineSession.getUserId() == null  ;
    if (StringUtils.isEmpty(onlineSession.getUserId())) {
      User user = UserUtils.getUser();
      if (user != null) {
        onlineSession.setUserId(user.getId());
        onlineSession.setUsername(user.getUsername());
        onlineSession.markAttributeChanged();
      }
    }
    if (onlineSession.getStatus() == OnlineSession.OnlineStatus.force_logout) {
      return false;
    }
  }
  return true;
}
origin: com.github.fartherp/shiro-redisson

public void onStop(Session session) {
  LOGGER.debug("session onStop ID: " + session.getId());
  this.sessionDAO.delete(session);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

protected void onChange(Session session) {
  sessionDAO.update(session);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

protected Collection<Session> getActiveSessions() {
  Collection<Session> active = sessionDAO.getActiveSessions();
  return active != null ? active : Collections.<Session>emptySet();
}
org.apache.shiro.session.mgt.eisSessionDAO

Javadoc

Data Access Object design pattern specification to enable Session access to an EIS (Enterprise Information System). It provides your four typical CRUD methods: #create, #readSession(java.io.Serializable), #update(org.apache.shiro.session.Session), and #delete(org.apache.shiro.session.Session).

The remaining #getActiveSessions() method exists as a support mechanism to pre-emptively orphaned sessions, typically by org.apache.shiro.session.mgt.ValidatingSessionManagers), and should be as efficient as possible, especially if there are thousands of active sessions. Large scale/high performance implementations will often return a subset of the total active sessions and perform validation a little more frequently, rather than return a massive set and infrequently validate.

Most used methods

  • readSession
    Retrieves the session from the EIS uniquely identified by the specified sessionId.
  • delete
    Deletes the associated EIS record of the specified session. If there never existed a session EIS rec
  • update
    Updates (persists) data from a previously created Session instance in the EIS identified by {@link S
  • create
    Inserts a new Session record into the underling EIS (e.g. Relational database, file system, persiste
  • getActiveSessions
    Returns all sessions in the EIS that are considered active, meaning all sessions that haven't been s

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JComboBox (javax.swing)
  • JFrame (javax.swing)
  • 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