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