Пример #1
0
  public String createSession(int userId) {
    String sessionKey = generateSessionId();

    synchronized (activeSessions) {
      activeSessions.put(sessionKey, new Session(userId, sessionKey, timeProvider.now()));
    }

    System.out.println("Created session " + sessionKey + " for user " + userId);

    return sessionKey;
  }
Пример #2
0
 private boolean hasExpired(Session session) {
   return timeProvider.now() >= session.getCreateTime() + Settings.SESSION_EXPIRATION_TIME;
 }