Coverage Report - org.apache.ws.scout.registry.AuthTokenSingleton
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthTokenSingleton
0%
0/18
0%
0/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  0
         private static AuthTokenSingleton instance = new AuthTokenSingleton();
 8  0
         private static Hashtable cachedAuthTokenHash = new Hashtable();
 9  
         
 10  0
         private AuthTokenSingleton() {
 11  0
         }
 12  
 
 13  
         public static AuthToken getToken(String username) {
 14  0
                 if (instance == null) {
 15  0
                         instance = new AuthTokenSingleton();
 16  
                 }
 17  
 
 18  0
                 if (cachedAuthTokenHash.containsKey(username)) 
 19  0
                         return (AuthToken) cachedAuthTokenHash.get(username);
 20  
         
 21  0
                 return null;
 22  
         }         
 23  
         
 24  
         public synchronized static void addAuthToken(String username, 
 25  
                         AuthToken token) {
 26  0
                 if (instance == null) {
 27  0
                         instance = new AuthTokenSingleton();
 28  
                 }
 29  0
                 cachedAuthTokenHash.put(username, token);
 30  0
         }
 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  
 }