コード例 #1
0
 @Override
 public long issueNewSessionCookie(
     HttpServletRequest req, HttpServletResponse resp, String userId) {
   User user = UserManager.getUser(Long.parseLong(userId));
   long expiresAt = System.currentTimeMillis() + SessionUtil.SESSION_LIFETIME * 1000L;
   SessionInfo sessionInfo = new SessionInfo(user.getUid(), expiresAt, random.nextLong());
   FilterUtil.setSessionCookie(req, resp, sessionInfo);
   FilterUtil.setSessionInfoInRequestAttributeAfterLogin(req, user, sessionInfo);
   return SessionUtil.SESSION_LIFETIME;
 }
コード例 #2
0
    @Override
    public boolean hasBigAccountChangeSince(String userId, long issueAt) {
      Preconditions.checkArgument(issueAt > 0);

      long id;
      try {
        id = Long.parseLong(userId);
      } catch (NumberFormatException e) {
        throw new IllegalArgumentException("Invalid user id.");
      }
      User user = UserManager.getUser(id);
      if (user == null) {
        throw new IllegalArgumentException("Invalid user id.");
      }

      return user.getLastBigChangeTime() > issueAt;
    }