Github user mdunker commented on a diff in the pull request:

    https://github.com/apache/usergrid/pull/573#discussion_r122738110
  
    --- 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);
    +        long created = (long) tokenDetails.get(TOKEN_CREATED);
    +        long accessed = (long) tokenDetails.get(TOKEN_ACCESSED);
    +        long inactive = (long) tokenDetails.get(TOKEN_INACTIVE);
    +        long duration = (long) tokenDetails.get(TOKEN_DURATION);
    +
    +        String principalTypeStr = (String) 
tokenDetails.get(TOKEN_PRINCIPAL_TYPE);
    +
             AuthPrincipalType principalType = null;
             if ( principalTypeStr != null ) {
                 try {
                     principalType = AuthPrincipalType.valueOf( 
principalTypeStr.toUpperCase() );
                 }
                 catch ( IllegalArgumentException e ) {
    +                logger.warn("Unable to convert authPrincipal Type from 
string to enum");
                 }
             }
             AuthPrincipalInfo principal = null;
             if ( principalType != null ) {
    -            UUID entityId = uuid( columns.get( TOKEN_ENTITY ) );
    -            UUID appId = uuid( columns.get( TOKEN_APPLICATION ) );
    +            UUID entityId = (UUID) tokenDetails.get(TOKEN_ENTITY);
    +            UUID appId = (UUID) tokenDetails.get(TOKEN_APPLICATION);
                 principal = new AuthPrincipalInfo( principalType, entityId, 
appId );
             }
    -        @SuppressWarnings("unchecked") Map<String, Object> state =
    -                ( Map<String, Object> ) JsonUtils.fromByteBuffer( 
columns.get( TOKEN_STATE ) );
    +
    +        @SuppressWarnings("unchecked")
    +        Map<String, Object> state = ( Map<String, Object> ) 
tokenDetails.get( TOKEN_STATE );
     
             UUID workflowOrgId = null;
    -        if (columns.containsKey(TOKEN_WORKFLOW_ORG_ID)) {
    -            workflowOrgId = 
ConversionUtils.uuid(columns.get(TOKEN_WORKFLOW_ORG_ID));
    +        if (tokenDetails.containsKey(TOKEN_WORKFLOW_ORG_ID)) {
    +            workflowOrgId = (UUID) tokenDetails.get(TOKEN_WORKFLOW_ORG_ID);
    --- End diff --
    
    try/catch?


---
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.
---

Reply via email to