1 package org.apache.ws.scout.registry; 2 3 import java.util.Hashtable; 4 import org.uddi.api_v3.AuthToken; 5 6 public class AuthTokenV3Singleton { 7 private static AuthTokenV3Singleton instance = new AuthTokenV3Singleton(); 8 private static Hashtable cachedAuthTokenHash = new Hashtable(); 9 10 private AuthTokenV3Singleton() { 11 } 12 13 public static AuthToken getToken(String username) { 14 if (instance == null) { 15 instance = new AuthTokenV3Singleton(); 16 } 17 if (cachedAuthTokenHash.containsKey(username)) 18 return (AuthToken)cachedAuthTokenHash.get(username); 19 20 return null; 21 } 22 23 public synchronized static void addAuthToken(String username, 24 AuthToken token) { 25 if (instance == null) { 26 instance = new AuthTokenV3Singleton(); 27 } 28 if (token!=null) cachedAuthTokenHash.put(username, token); 29 } 30 31 public synchronized static void deleteAuthToken(String username) { 32 if (instance == null) { 33 instance = new AuthTokenV3Singleton(); 34 } else { 35 if (cachedAuthTokenHash.containsKey(username)) { 36 cachedAuthTokenHash.remove(username); 37 } 38 } 39 } 40 }