예제 #1
0
 /**
  * Reconstruct the object from the supplied token.
  *
  * @param token
  */
 public PleaseWaitStateBean(String token) {
   ManagementContainer mc = ManagementContainer.getInstance();
   final SessionValidationManager svm = mc.getSessionValidationManager();
   String payload = svm.validateToken(TOKEN_PURPOSE, token);
   String[] items = payload.split(",", 5);
   // ignore the 1st item, it's just a nonce.
   m_userId = Integer.parseInt(items[1]);
   m_timeZoneOffsetMin = Integer.parseInt(items[2]);
 }
예제 #2
0
  /**
   * Build a token from the given state.
   *
   * @return
   */
  public String encodeToken() {
    ManagementContainer mc = ManagementContainer.getInstance();
    SessionValidationManager svm = mc.getSessionValidationManager();

    int rnd = 0;
    if (s_sr != null) {
      // Add some randomness to the payload.
      // Without this, tokens generated w/ the same userId and tz
      // match around the first 90 bytes.  With the rnd the 1st
      // 20 bytes match.
      rnd = s_sr.nextInt();
    }
    String payload = rnd + "," + getUserId() + "," + getTimeZoneOffsetMin();
    String token = svm.createLocalToken(TOKEN_PURPOSE, payload);
    return token;
  }
예제 #3
0
 private String createTicket(String purpose, String email) {
   SessionValidationManager svm = ManagementContainer.getInstance().getSessionValidationManager();
   return svm.createLocalToken(purpose, email);
 }