예제 #1
0
  /**
   * Validate the token expiration date.
   *
   * @param expirationDate - Token expiration date.
   * @return - Token status.
   */
  public static boolean isValid(Date expirationDate) {
    Date currentDate = new Date();
    String formattedDate = dateFormat.format(currentDate);
    currentDate = convertDate(formattedDate);

    boolean isExpired = currentDate.after(expirationDate);
    boolean isEqual = currentDate.equals(expirationDate);
    return isExpired || isEqual;
  }
 /**
  * Generate the challenge string.
  *
  * @return a generated nonce.
  */
 public String generateNonce() {
   // Get the time of day and run MD5 over it.
   Date date = new Date();
   long time = date.getTime();
   Random rand = new Random();
   long pad = rand.nextLong();
   String nonceString = (new Long(time)).toString() + (new Long(pad)).toString();
   byte mdbytes[] = messageDigest.digest(nonceString.getBytes());
   // Convert the mdbytes array into a hex string.
   return ProxyUtilities.toHexString(mdbytes);
 }