1 | import edu.isi.www.fedd_types.*; |
---|
2 | import edu.isi.www.fedd_wsdl.*; |
---|
3 | import java.net.*; |
---|
4 | import java.util.*; |
---|
5 | |
---|
6 | import net.deterlab.isi.XTrustProvider; |
---|
7 | import net.deterlab.isi.Fedid; |
---|
8 | |
---|
9 | import javax.net.ssl.*; |
---|
10 | |
---|
11 | public class FeddCommand { |
---|
12 | |
---|
13 | static { setUpSecurity(); } |
---|
14 | |
---|
15 | static class ExperimentLabels { |
---|
16 | protected String fedid; |
---|
17 | protected String localname; |
---|
18 | |
---|
19 | public ExperimentLabels(IDType[] experimentID) { |
---|
20 | fedid = null; |
---|
21 | localname = null; |
---|
22 | |
---|
23 | for (IDType id: experimentID) { |
---|
24 | if (id.getLocalname() != null) localname = id.getLocalname(); |
---|
25 | if (id.getFedid() != null) { |
---|
26 | byte[] rawFedid = id.getFedid(); |
---|
27 | |
---|
28 | if (rawFedid != null) { |
---|
29 | Fedid f = new Fedid(rawFedid); |
---|
30 | |
---|
31 | if ( f != null) fedid = f.toString().substring(6); |
---|
32 | } |
---|
33 | } |
---|
34 | } |
---|
35 | } |
---|
36 | String getFedid() { return fedid; } |
---|
37 | String getLocalname() { return localname; } |
---|
38 | } |
---|
39 | |
---|
40 | public static void setUpSecurity() { |
---|
41 | /* This magic turns off certificate chain checking. */ |
---|
42 | XTrustProvider.install(); |
---|
43 | |
---|
44 | /* This tells the SSL system where to find client certificate |
---|
45 | * information. */ |
---|
46 | String keyStore = "./keystore"; |
---|
47 | String keyStorePassword = "importkey"; |
---|
48 | |
---|
49 | System.setProperty("javax.net.ssl.keyStore", keyStore); |
---|
50 | System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword); |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | static public void clearSSLSessionCache() { |
---|
55 | try { |
---|
56 | SSLContext sctxt = SSLContext.getDefault(); |
---|
57 | SSLSessionContext ssctxt = sctxt.getClientSessionContext(); |
---|
58 | Enumeration<byte[]> e = ssctxt.getIds(); |
---|
59 | while (e.hasMoreElements()) { |
---|
60 | SSLSession s = ssctxt.getSession(e.nextElement()); |
---|
61 | s.invalidate(); |
---|
62 | System.err.println("invalidated " + s); |
---|
63 | } |
---|
64 | } |
---|
65 | catch (Exception e) { System.err.println(e); } |
---|
66 | } |
---|
67 | |
---|
68 | public static FeddPortType getPort(String server) throws |
---|
69 | javax.xml.rpc.ServiceException, java.net.MalformedURLException { |
---|
70 | /* |
---|
71 | * Boilerplate web services access stuff. |
---|
72 | */ |
---|
73 | clearSSLSessionCache(); |
---|
74 | FeddServiceLocator service = new FeddServiceLocator(); |
---|
75 | FeddPortType port = service.getfeddPort(new URL(server)); |
---|
76 | |
---|
77 | return port; |
---|
78 | } |
---|
79 | } |
---|