1 package fr.in2p3.jsaga.adaptor.security;
2
3 import java.util.HashMap;
4 import java.util.Iterator;
5 import java.util.Map;
6 import java.util.Set;
7
8
9
10
11
12
13
14
15
16
17 public class ProxyTypeMap {
18
19 public static final String TYPE_GLOBUS2 = "OLD";
20 public static final String TYPE_GLOBUS3 = "GLOBUS";
21 public static final String TYPE_RFC3820 = "RFC3820";
22 protected static Map<String, Integer> map = createMap();
23
24 private static Map<String, Integer> createMap() {
25 Map<String, Integer> map = new HashMap<String, Integer>();
26 map.put(TYPE_GLOBUS2, GlobusProxyFactory.OID_OLD);
27 map.put(TYPE_GLOBUS3, GlobusProxyFactory.OID_GLOBUS);
28 map.put(TYPE_RFC3820, GlobusProxyFactory.OID_RFC3820);
29 return java.util.Collections.unmodifiableMap(map);
30 }
31
32 public static int toProxyType(String type) {
33 return map.get(type.toUpperCase());
34 }
35
36 public static boolean isValid(String type) {
37 return map.containsKey(type.toUpperCase());
38 }
39
40 public static Set<String> getValidTypes() {
41 return map.keySet();
42 }
43
44 public static String getExpected() {
45 Set<String> valids = ProxyTypeMap.getValidTypes();
46 String msg = "\"" + GlobusContext.PROXYTYPE + "\": Expected: ";
47 for (Iterator<String> i = valids.iterator(); i.hasNext();) {
48 msg += i.next() + " | ";
49 }
50 return msg;
51 }
52 }