use of com.emc.storageos.db.client.model.Token in project coprhd-controller by CoprHD.
the class CassandraTokenManager method deleteToken.
/**
* Remove token from database if valid.
*/
@Override
public void deleteToken(String tokenIn) {
try {
if (tokenIn == null) {
_log.error("Null token passed for deletion");
return;
}
URI tkId = _tokenEncoder.decode(tokenIn).getTokenId();
Token verificationToken = _dbClient.queryObject(Token.class, tkId);
if (verificationToken == null) {
_log.error("Could not fetch token from the database: {}", tkId);
return;
}
deleteTokenInternal(verificationToken);
} catch (DatabaseException ex) {
throw SecurityException.fatals.databseExceptionDuringTokenDeletion(tokenIn, ex);
} catch (SecurityException e) {
_log.error("Token decoding exception during deleteToken.", e);
}
}
use of com.emc.storageos.db.client.model.Token in project coprhd-controller by CoprHD.
the class CassandraTokenManager method deleteAllTokensForUser.
/**
* Delete all tokens belonging to the user and mark all the user records for this user for deletion.
*/
@Override
public void deleteAllTokensForUser(String userName, boolean includeProxyTokens) {
try {
List<StorageOSUserDAO> userRecords = getUserRecords(userName.toLowerCase());
for (StorageOSUserDAO userRecord : userRecords) {
List<Token> tokensToDelete = getTokensForUserId(userRecord.getId());
for (Token token : tokensToDelete) {
_log.info("Removing token {} using userDAO {} for username {}", new String[] { token.getId().toString(), userRecord.getId().toString(), userName });
_dbClient.removeObject(token);
cleanUpRequestedTokenMap(token);
}
// making proxy token deletion optional
List<ProxyToken> pTokensToDelete = getProxyTokensForUserId(userRecord.getId());
if (includeProxyTokens) {
for (ProxyToken token : pTokensToDelete) {
_log.info("Removing proxy token {} using userDAO {} for username {}", new String[] { token.getId().toString(), userRecord.getId().toString(), userName });
_dbClient.removeObject(token);
}
_log.info("Marking for deletion: user record {} for username {}", userRecord.getId().toString(), userName);
_dbClient.markForDeletion(userRecord);
} else if (pTokensToDelete.isEmpty()) {
_log.info("No proxy tokens found. Marking for deletion: user record {} for username {}", userRecord.getId().toString(), userName);
_dbClient.markForDeletion(userRecord);
}
}
} catch (DatabaseException ex) {
throw SecurityException.fatals.exceptionDuringTokenDeletionForUser(userName, ex);
}
}
use of com.emc.storageos.db.client.model.Token in project coprhd-controller by CoprHD.
the class CassandraTokenManager method createNewToken.
/**
* create a new token with the user info
*
* @param user
* @return
*/
private Token createNewToken(StorageOSUserDAO user) {
Token token = new Token();
token.setId(URIUtil.createId(Token.class));
// relative index, Id of the userDAO record
token.setUserId(user.getId());
long timeNow = getCurrentTimeInMins();
token.setIssuedTime(timeNow);
token.setLastAccessTime(timeNow);
token.setExpirationTime(timeNow + (_maxLifeValuesHolder.getMaxTokenLifeTimeInMins()));
token.setIndexed(true);
_dbClient.persistObject(token);
return token;
}
Aggregations