source: axis/FeddCommand.java @ 10f5e84

axis_examplecompt_changesinfo-ops
Last change on this file since 10f5e84 was 10f5e84, checked in by Ted Faber <faber@…>, 13 years ago

Create works!

  • Property mode set to 100644
File size: 2.0 KB
Line 
1import edu.isi.www.fedd_types.*;
2import edu.isi.www.fedd_wsdl.*;
3import java.net.*;
4import java.util.*;
5
6import net.deterlab.isi.XTrustProvider;
7import net.deterlab.isi.Fedid;
8
9import javax.net.ssl.*;
10
11public 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}
Note: See TracBrowser for help on using the repository browser.