This project has retired. For details please refer to its Attic page.
Coverage Report
Coverage Report - org.apache.ws.scout.registry.AuthTokenSingleton
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthTokenSingleton
61%
11/18
40%
4/10
2.5
 
 1  
 package org.apache.ws.scout.registry;
 2  
 
 3  
 import java.util.Hashtable;
 4  
 import org.apache.ws.scout.model.uddi.v2.AuthToken;
 5  
 
 6  
 public class AuthTokenSingleton {
 7  2
         private static AuthTokenSingleton instance = new AuthTokenSingleton();
 8  2
         private static Hashtable cachedAuthTokenHash = new Hashtable();
 9  
         
 10  2
         private AuthTokenSingleton() {
 11  2
         }
 12  
 
 13  
         public static AuthToken getToken(String username) {
 14  400
                 if (instance == null) {
 15  0
                         instance = new AuthTokenSingleton();
 16  
                 }
 17  
 
 18  400
                 if (cachedAuthTokenHash.containsKey(username)) 
 19  396
                         return (AuthToken) cachedAuthTokenHash.get(username);
 20  
         
 21  4
                 return null;
 22  
         }         
 23  
         
 24  
         public synchronized static void addAuthToken(String username, 
 25  
                         AuthToken token) {
 26  4
                 if (instance == null) {
 27  0
                         instance = new AuthTokenSingleton();
 28  
                 }
 29  4
                 cachedAuthTokenHash.put(username, token);
 30  4
         }
 31  
         
 32  
         public synchronized static void deleteAuthToken(String username) {
 33  0
                 if (instance == null) {
 34  0
                         instance = new AuthTokenSingleton();
 35  
                 } else {
 36  0
                         if (cachedAuthTokenHash.containsKey(username)) {
 37  0
                                 cachedAuthTokenHash.remove(username);
 38  
                         }
 39  
                 }
 40  0
         }
 41  
 }