本文整理匯總了Java中org.apache.commons.lang3.time.DateUtils.MILLIS_PER_MINUTE屬性的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.MILLIS_PER_MINUTE屬性的具體用法?Java DateUtils.MILLIS_PER_MINUTE怎麽用?Java DateUtils.MILLIS_PER_MINUTE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.commons.lang3.time.DateUtils
的用法示例。
在下文中一共展示了DateUtils.MILLIS_PER_MINUTE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSsoToken
/**
* Return SSO token to use in cross site parameters valid for few minutes.
*
* @param login
* The login of the user.
* @param userKey
* The key of the user.
* @return SSO token to use as cross site parameter.
*/
private String getSsoToken(final String login, final String userKey) throws Exception {
// Uses a secure Random not a simple Random
final SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
// Salt generation 64 bits long
final byte[] bSalt = new byte[8];
random.nextBytes(bSalt);
// Digest computation
final long expire = System.currentTimeMillis()
+ DateUtils.MILLIS_PER_MINUTE * get("sso.duration", DEFAULT_TIMEOUT);
final byte[] bDigest = getHash(get("sso.iteration", 1000), login + userKey + expire, bSalt);
final String sDigest = byteToBase64(bDigest);
final String sSalt = byteToBase64(bSalt);
// Secret key of DES algorithm used to generated the SSO token.
final String ssoKey = configuration.get("sso.secret");
// Generated an encrypted key, valid for 30 minutes
return encrypt(
login + "|"
+ sDigest + "|" + sSalt + "|" + new String(
Base64.encodeInteger(new BigInteger(String.valueOf(expire))), StandardCharsets.UTF_8),
ssoKey);
}
示例2: getOldSsoToken
/**
* Return SSO token to use in cross site parameters valid for 30 minutes.
*
* @param login
* The login of the user
* @param userKey
* The key of the user
* @return SSO token to use as cross site parameter.
*/
private String getOldSsoToken(final String login, final String userKey) throws Exception {
// Uses a secure Random not a simple Random
final SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
// Salt generation 64 bits long
final byte[] bSalt = new byte[8];
random.nextBytes(bSalt);
// Digest computation
final byte[] bDigest = resource.getHash(1000, login + userKey, bSalt);
final String sDigest = resource.byteToBase64(bDigest);
final String sSalt = resource.byteToBase64(bSalt);
final long expire = System.currentTimeMillis() - DateUtils.MILLIS_PER_MINUTE * 31;
// Generated an encrypted key, valid for 30 minutes
return resource.encrypt(login + "|" + sDigest + "|" + sSalt + "|"
+ new String(Base64.encodeInteger(new BigInteger(String.valueOf(expire)))), "secret");
}
示例3: getTime
/**
* Return the milliseconds of given date. Year, month and day fields are ignored.
*/
private long getTime(final Date date) {
final Calendar calendar = DateUtils.toCalendar(date);
return calendar.get(Calendar.HOUR_OF_DAY) * DateUtils.MILLIS_PER_HOUR + calendar.get(Calendar.MINUTE) * DateUtils.MILLIS_PER_MINUTE
+ calendar.get(Calendar.SECOND) * DateUtils.MILLIS_PER_SECOND + calendar.get(Calendar.MILLISECOND);
}