use of org.gluu.oxauth.model.common.SessionTokens in project oxAuth by GluuFederation.
the class GrantService method persist.
public void persist(TokenLdap token) {
if (shouldPutInCache(token.getTokenTypeEnum(), token.isImplicitFlow())) {
ClientTokens clientTokens = getCacheClientTokens(token.getClientId());
clientTokens.getTokenHashes().add(token.getTokenCode());
// fallback to client's lifetime
int expiration = appConfiguration.getDynamicRegistrationExpirationTime();
switch(token.getTokenTypeEnum()) {
case ID_TOKEN:
expiration = appConfiguration.getIdTokenLifetime();
break;
case REFRESH_TOKEN:
expiration = appConfiguration.getRefreshTokenLifetime();
break;
case ACCESS_TOKEN:
case LONG_LIVED_ACCESS_TOKEN:
int lifetime = appConfiguration.getAccessTokenLifetime();
Client client = clientService.getClient(token.getClientId());
// oxAuth #830 Client-specific access token expiration
if (client != null && client.getAccessTokenLifetime() != null && client.getAccessTokenLifetime() > 0) {
lifetime = client.getAccessTokenLifetime();
}
expiration = lifetime;
break;
case AUTHORIZATION_CODE:
expiration = appConfiguration.getAuthorizationCodeLifetime();
break;
}
token.setIsFromCache(true);
cacheService.put(expiration, token.getTokenCode(), token);
cacheService.put(expiration, clientTokens.cacheKey(), clientTokens);
if (StringUtils.isNotBlank(token.getSessionDn())) {
SessionTokens sessionTokens = getCacheSessionTokens(token.getSessionDn());
sessionTokens.getTokenHashes().add(token.getTokenCode());
cacheService.put(expiration, sessionTokens.cacheKey(), sessionTokens);
}
return;
}
ldapEntryManager.persist(token);
}
use of org.gluu.oxauth.model.common.SessionTokens in project oxAuth by GluuFederation.
the class GrantService method getCacheSessionTokens.
public SessionTokens getCacheSessionTokens(String sessionDn) {
SessionTokens sessionTokens = new SessionTokens(sessionDn);
Object o = cacheService.get(sessionTokens.cacheKey());
if (o instanceof SessionTokens) {
return (SessionTokens) o;
} else {
return sessionTokens;
}
}
Aggregations