Github user michaelarusso commented on a diff in the pull request:
https://github.com/apache/usergrid/pull/573#discussion_r122738547
--- Diff:
stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
---
@@ -469,60 +393,60 @@ public void revokeToken( String token ) {
return;
}
- UUID tokenId = info.getUuid();
-
- Mutator<ByteBuffer> batch = createMutator(
cassandra.getUsergridApplicationKeyspace(), be );
+ final UUID tokenId = info.getUuid();
// clean up the link in the principal -> token index if the
principal is
// on the token
if ( info.getPrincipal() != null ) {
- batch.addDeletion( principalKey( info.getPrincipal() ),
PRINCIPAL_TOKEN_CF, bytebuffer( tokenId ),
- be );
+ tokenSerialization.revokeToken(tokenId, principalKey(
info.getPrincipal()));
+ }else{
+ tokenSerialization.revokeToken(tokenId, null);
}
- // remove the token from the tokens cf
- batch.addDeletion( bytebuffer( tokenId ), TOKENS_CF );
-
- batch.execute();
}
private TokenInfo getTokenInfo( UUID uuid ) throws Exception {
if ( uuid == null ) {
throw new InvalidTokenException( "No token specified" );
}
- Map<String, ByteBuffer> columns = getColumnMap( cassandra
- .getColumns( cassandra.getUsergridApplicationKeyspace(),
TOKENS_CF, uuid, TOKEN_PROPERTIES, se,
- be ) );
- if ( !hasKeys( columns, REQUIRED_TOKEN_PROPERTIES ) ) {
+
+ Map<String, Object> tokenDetails =
tokenSerialization.getTokenInfo(uuid);
+
+ if ( !hasKeys( tokenDetails, REQUIRED_TOKEN_PROPERTIES ) ) {
throw new InvalidTokenException( "Token not found in database"
);
}
- String type = string( columns.get( TOKEN_TYPE ) );
- long created = getLong( columns.get( TOKEN_CREATED ) );
- long accessed = getLong( columns.get( TOKEN_ACCESSED ) );
- long inactive = getLong( columns.get( TOKEN_INACTIVE ) );
- long duration = getLong( columns.get( TOKEN_DURATION ) );
- String principalTypeStr = string( columns.get(
TOKEN_PRINCIPAL_TYPE ) );
+
+ String type = (String) tokenDetails.get(TOKEN_TYPE);
--- End diff --
Sure, but we are the ones putting the data in the columns so that's what it
always is. The same code basically exists today in the old Hector impl:
https://github.com/apache/usergrid/blob/master/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java#L500
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---