usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject usergrid git commit: Fix precondition checks and add another try/catch around the token workflow org id.
Date Mon, 19 Jun 2017 15:50:32 GMT
Repository: usergrid
Updated Branches:
  refs/heads/token-service-to-dstax 996344900 -> c0ba71039


Fix precondition checks and add another try/catch around the token workflow org id.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c0ba7103
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c0ba7103
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c0ba7103

Branch: refs/heads/token-service-to-dstax
Commit: c0ba7103949564dd9cebc3631fe8e5002a7e73d2
Parents: 9963449
Author: Michael Russo <russomichael@google.com>
Authored: Mon Jun 19 08:49:57 2017 -0700
Committer: Michael Russo <russomichael@google.com>
Committed: Mon Jun 19 08:49:57 2017 -0700

----------------------------------------------------------------------
 .../persistence/token/impl/TokenSerializationImpl.java       | 8 ++++----
 .../usergrid/security/tokens/impl/TokenServiceImpl.java      | 6 +++++-
 2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/c0ba7103/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
b/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
index 240da00..7825da0 100644
--- a/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
+++ b/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
@@ -192,9 +192,9 @@ public class TokenSerializationImpl implements TokenSerialization {
     public void updateTokenAccessTime(UUID tokenUUID, long accessedTime, long inactiveTime,
int ttl ){
 
         Preconditions.checkNotNull(tokenUUID, "token UUID is required");
-        Preconditions.checkNotNull(accessedTime, "accessedTime is required");
-        Preconditions.checkNotNull(inactiveTime, "inactiveTime is required");
-        Preconditions.checkNotNull(ttl, "ttl is required");
+        Preconditions.checkArgument(accessedTime > -1 , "accessedTime is required to be
positive");
+        Preconditions.checkArgument(inactiveTime > -1 , "inactiveTime is required to be
positive");
+        Preconditions.checkArgument(ttl > -1 , "ttl is required to be positive");
 
         logger.trace("updateTokenAccessTime, token UUID: {}, accessedTime: {}, inactiveTime:
{}, ttl: {}",
             tokenUUID, accessedTime, inactiveTime, ttl);
@@ -287,7 +287,7 @@ public class TokenSerializationImpl implements TokenSerialization {
 
         Preconditions.checkNotNull(tokenUUID, "tokenUUID is required");
         Preconditions.checkNotNull(tokenUUID, "tokenInfo is required");
-        Preconditions.checkNotNull(ttl, "ttl is required");
+        Preconditions.checkArgument(ttl > -1 , "ttl is required to be positive");
 
         logger.trace("putTokenInfo, token UUID: {}, tokenInfo: {}, ttl: {}", tokenUUID, tokenInfo,
ttl);
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c0ba7103/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
index f149a1f..05859ad 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
@@ -456,7 +456,11 @@ public class TokenServiceImpl implements TokenService {
 
         UUID workflowOrgId = null;
         if (tokenDetails.containsKey(TOKEN_WORKFLOW_ORG_ID)) {
-            workflowOrgId = (UUID) tokenDetails.get(TOKEN_WORKFLOW_ORG_ID);
+            try {
+                workflowOrgId = (UUID) tokenDetails.get(TOKEN_WORKFLOW_ORG_ID);
+            } catch (ClassCastException cce){
+                logger.error("Unable to cast {} to primitive UUID type", TOKEN_WORKFLOW_ORG_ID);
+            }
         }
 
         return new TokenInfo( uuid, type, created, accessed, inactive, duration, principal,
state, workflowOrgId );


Mime
View raw message