use of com.emc.storageos.db.client.model.BaseToken in project coprhd-controller by CoprHD.
the class CassandraTokenValidator method foreignTokenCacheLookup.
/**
* Looks in the cache for token/user record. Returns null if not found or found but cache expired
*
* @param tw
* @return user record
*/
private StorageOSUserDAO foreignTokenCacheLookup(TokenOnWire tw) {
BaseToken bToken = fetchTokenLocal(tw);
if (bToken == null || !Token.class.isInstance(bToken)) {
_log.info("Token: no hit from cache");
return null;
}
Token token = (Token) bToken;
Long expirationTime = token.getCacheExpirationTime();
if (expirationTime != null && expirationTime > getCurrentTimeInMins()) {
StorageOSUserDAO user = resolveUser(token);
_log.info("Got user from cached token: {}", user != null ? user.getUserName() : "no hit from cache");
return user;
}
_log.info("Cache expired for foreign token {}", token.getId());
return null;
}
use of com.emc.storageos.db.client.model.BaseToken in project coprhd-controller by CoprHD.
the class CassandraTokenValidator method fetchTokenLocal.
/**
* Retrieves a token and checks expiration
*
* @param tw
* @return
*/
private BaseToken fetchTokenLocal(TokenOnWire tw) {
BaseToken verificationToken = null;
URI tkId = tw.getTokenId();
if (!tw.isProxyToken()) {
verificationToken = _dbClient.queryObject(Token.class, tkId);
if (null != verificationToken && !checkExpiration(((Token) verificationToken), true)) {
_log.warn("Token found in database but is expired: {}", verificationToken.getId());
return null;
}
} else {
verificationToken = _dbClient.queryObject(ProxyToken.class, tkId);
if (null != verificationToken && !checkExpiration((ProxyToken) verificationToken)) {
_log.warn("ProxyToken found in database but is expired: {}", verificationToken.getId());
return null;
}
}
if (verificationToken == null) {
_log.error("Could not find token with id {} for validation", tkId);
}
return verificationToken;
}
Aggregations