Ejemplo n.º 1
0
  /** Loads the session from the backing. */
  public SessionArrayValue loadSession(Env env, String sessionId) {
    long now = env.getCurrentTime();

    SessionArrayValue session = _sessionManager.getSession(env, sessionId, now);

    if (session == null) session = _sessionManager.createSession(env, sessionId, now);

    return session;
  }
Ejemplo n.º 2
0
  /**
   * Creates a pseudo-random session id. If there's an old id and the group matches, then use it
   * because different applications on the same matchine should use the same cookie.
   */
  public String createSessionId(Env env) {
    String id;

    do {
      CharBuffer sb = new CharBuffer();

      Base64.encode(sb, RandomUtil.getRandomLong());
      Base64.encode(sb, env.getCurrentTime());

      id = sb.toString();
    } while (getSession(env, id, 0) != null);

    if (id == null || id.equals("")) throw new RuntimeException();

    return id;
  }