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 private static AuthTokenSingleton instance = new AuthTokenSingleton(); 8 private static Hashtable cachedAuthTokenHash = new Hashtable(); 9 10 private AuthTokenSingleton() { 11 } 12 13 public static AuthToken getToken(String username) { 14 if (instance == null) { 15 instance = new AuthTokenSingleton(); 16 } 17 18 if (cachedAuthTokenHash.containsKey(username)) 19 return (AuthToken) cachedAuthTokenHash.get(username); 20 21 return null; 22 } 23 24 public synchronized static void addAuthToken(String username, 25 AuthToken token) { 26 if (instance == null) { 27 instance = new AuthTokenSingleton(); 28 } 29 cachedAuthTokenHash.put(username, token); 30 } 31 32 public synchronized static void deleteAuthToken(String username) { 33 if (instance == null) { 34 instance = new AuthTokenSingleton(); 35 } else { 36 if (cachedAuthTokenHash.containsKey(username)) { 37 cachedAuthTokenHash.remove(username); 38 } 39 } 40 } 41 }