Search in sources :

Example 6 with Expiration

use of com.zimbra.cs.ephemeral.EphemeralInput.Expiration in project zm-mailbox by Zimbra.

the class CsrfUtil method storeTokenData.

/**
 * @param tokenSalt
 * @param accountId
 * @param authTokenExpiration
 * @param crumb
 * @throws ServiceException
 */
private static void storeTokenData(String data, AuthToken authToken, long authTokenExpiration, String crumb) throws ServiceException {
    Account account = getAccount(authToken, Boolean.TRUE);
    if (account != null) {
        Expiration expiration = new AbsoluteExpiration(authTokenExpiration);
        boolean needToAdd = true;
        String curData = account.getCsrfTokenData(crumb);
        if (curData != null) {
            if (!data.equals(curData)) {
                account.removeCsrfTokenData(crumb, curData);
            } else {
                ZimbraLog.ephemeral.debug("CSRF token already stored in ephemeral storage");
                needToAdd = false;
            }
        }
        if (needToAdd) {
            account.addCsrfTokenData(crumb, data, expiration);
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) AbsoluteExpiration(com.zimbra.cs.ephemeral.EphemeralInput.AbsoluteExpiration) Expiration(com.zimbra.cs.ephemeral.EphemeralInput.Expiration) AbsoluteExpiration(com.zimbra.cs.ephemeral.EphemeralInput.AbsoluteExpiration)

Aggregations

AbsoluteExpiration (com.zimbra.cs.ephemeral.EphemeralInput.AbsoluteExpiration)6 Expiration (com.zimbra.cs.ephemeral.EphemeralInput.Expiration)6 EphemeralInput (com.zimbra.cs.ephemeral.EphemeralInput)3 EphemeralKey (com.zimbra.cs.ephemeral.EphemeralKey)3 ServiceException (com.zimbra.common.service.ServiceException)2 Account (com.zimbra.cs.account.Account)1 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)1 EphemeralLocation (com.zimbra.cs.ephemeral.EphemeralLocation)1 LdapEntryLocation (com.zimbra.cs.ephemeral.LdapEntryLocation)1