You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/31 00:01:27 UTC

svn commit: r1781006 - /axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java

Author: veithen
Date: Tue Jan 31 00:01:27 2017
New Revision: 1781006

URL: http://svn.apache.org/viewvc?rev=1781006&view=rev
Log:
Clean up the patch.

Modified:
    axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java

Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java?rev=1781006&r1=1781005&r2=1781006&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java Tue Jan 31 00:01:27 2017
@@ -16,6 +16,12 @@
 
 package org.apache.rahas;
 
+import org.apache.axiom.om.OMElement;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.message.token.Reference;
+
+import javax.xml.namespace.QName;
+
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Hashtable;
@@ -27,12 +33,6 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.message.token.Reference;
-
 /**
  * In-memory implementation of the token storage
  */
@@ -91,17 +91,13 @@ public class SimpleTokenStore implements
     }
 
     public String[] getTokenIdentifiers() throws TrustException {       
-        
-        String [] tokenIdentifiers = null;
-        
         readLock.lock();
-        
-        Set identifiers = tokens.keySet();
-        tokenIdentifiers = (String[]) identifiers.toArray(new String[identifiers.size()]); 
-        
-        readLock.unlock();
-        
-        return tokenIdentifiers;
+        try {
+            Set identifiers = tokens.keySet();
+            return (String[]) identifiers.toArray(new String[identifiers.size()]);
+        } finally {
+            readLock.unlock();
+        }
     }
 
     public Token[] getValidTokens() throws TrustException {
@@ -121,7 +117,7 @@ public class SimpleTokenStore implements
         return getTokens(Token.EXPIRED);
     }
 
-    private Token[] getTokens(int[] states) throws TrustException {
+    private Token[] getTokens(int... states) throws TrustException {
         List tokens = new ArrayList();
         
         readLock.lock();
@@ -143,22 +139,16 @@ public class SimpleTokenStore implements
         return (Token[]) tokens.toArray(new Token[tokens.size()]);
     }
 
-    private Token[] getTokens(int state) throws TrustException {
-        int[] states = new int[]{state};        
-        return getTokens(states);
-    }
-
     public Token getToken(String id) throws TrustException {
         readLock.lock();
         
         Token token;
         
         try {
-
+            
             token = (Token) this.tokens.get(id);
-            if(token != null) {
-                processTokenExpiry(token);
-            }else{
+            
+            if(token == null) {
                 //Try to find the token using attached refs & unattached refs
                 for (Iterator iterator = this.tokens.values().iterator(); iterator.hasNext();) {
                     Token tempToken = (Token) iterator.next();
@@ -171,9 +161,12 @@ public class SimpleTokenStore implements
                     if(elem != null && id.equals(this.getIdFromSTR(elem))) {
                         token = tempToken;
                     }
+                    
                 }
+            } else {
+                processTokenExpiry(token);
             }
-
+        
         } finally {
             readLock.unlock();
         }