Changeset 10f5e84
- Timestamp:
- Mar 31, 2011 10:07:29 PM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- 9f8dbc1
- Parents:
- 56baf92
- Location:
- axis
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
axis/Create.java
r56baf92 r10f5e84 3 3 import java.net.URL; 4 4 import net.deterlab.isi.XTrustProvider; 5 import java.io.*; 6 import java.util.*; 7 8 import org.apache.axis.AxisFault; 9 10 import javax.net.*; 11 import javax.net.ssl.*; 12 import java.security.GeneralSecurityException; 13 14 import net.deterlab.abac.*; 5 15 6 16 class Create extends FeddCommand { 17 18 static public byte[] readNsFile(File f) throws IOException { 19 final int bsize = 4096; 20 byte[] buf = new byte[bsize]; 21 byte[] rv = new byte[0]; 22 int r = 0; 23 FileInputStream fs = new FileInputStream(f); 24 25 while ((r = fs.read(buf)) != -1 ) { 26 byte[] newRv = new byte[rv.length + r]; 27 System.arraycopy(rv, 0, newRv, 0, rv.length); 28 System.arraycopy(buf, 0, newRv, rv.length, r); 29 rv = newRv; 30 } 31 fs.close(); 32 return rv; 33 } 34 35 static public Credential delegate(Identity id, String dest) 36 throws IOException,GeneralSecurityException { 37 Credential c = new Credential(new Role(id.getKeyID()+".acting_for"), 38 new Role(dest)); 39 c.make_cert(id); 40 return c; 41 } 42 7 43 /** 8 44 * Dummy program to test an AXIS fedd implementation generated from the … … 21 57 */ 22 58 FeddPortType port = getPort("https://users.isi.deterlab.net:23235"); 23 setUpSecurity(); 59 Identity AbacID = null; 60 byte[] nsContents = null; 61 try { 62 nsContents = readNsFile(new File(args[1])); 63 } 64 catch (IOException e) { 65 System.err.println("Cannot read " + args[1] + ": " + e); 66 System.exit(20); 67 } 24 68 25 69 /* … … 27 71 */ 28 72 29 NewResponseType resp = null; 30 31 /* This magic turns off certificate chain checking. */ 32 XTrustProvider.install(); 33 34 /* This tells the SSL system where to find client certificate 35 * information. */ 36 String keyStore = "./keystore"; 37 String keyStorePassword = "importkey"; 38 39 System.setProperty("javax.net.ssl.keyStore", keyStore); 40 System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword); 41 IDType id = new IDType(); 42 43 NewRequestType req = new NewRequestType(null, 73 NewRequestType newReq = new NewRequestType(null, 44 74 new IDType(null, null, null, args[0], null), 45 75 null); 76 NewResponseType newResp = null; 46 77 47 78 48 79 try { 49 / * Build the message and make the call */50 resp = port._new(req);80 // Build the message and make the call 81 newResp = port._new(newReq); 51 82 } 52 catch ( FaultTypef) {83 catch (Exception f) { 53 84 System.err.println("Error in New: " + f); 54 85 System.exit(20); 55 86 } 56 87 ExperimentLabels newLabels = 57 new ExperimentLabels( resp.getExperimentID());88 new ExperimentLabels(newResp.getExperimentID()); 58 89 System.out.println("New success: " + newLabels.getLocalname() + "(" + 59 90 newLabels.getFedid() + ")"); 91 92 CreateRequestType createReq = new CreateRequestType(null, 93 new ExperimentDescriptionType(nsContents, null), 94 null, 95 //new IDType(null, null, null, newLabels.getLocalname(), null), 96 new IDType(null, null, null, args[0], null), 97 null); 98 CreateResponseType createResp = null; 99 port = getPort("https://users.isi.deterlab.net:23235"); 100 101 Credential c = null; 102 byte[][] ca = new byte[1][]; 103 try { 104 AbacID = new Identity(new File("./emulab.pem")); 105 c = delegate(AbacID, newLabels.getFedid()); 106 ca[0] = c.cert().getEncoded(); 107 createReq.setCredential(ca); 108 System.err.println(AbacID); 109 System.err.println(c); 110 } 111 catch (GeneralSecurityException e) { System.err.println(e); } 112 catch (IOException e) { System.err.println("IOException?!!" +e); } 113 114 try { 115 /* Build the message and make the call */ 116 createResp = port.create(createReq); 117 } 118 catch (AxisFault f) { 119 System.err.println(f.getClass().getName()); 120 System.err.println("AxisFault Error in Create: " + f); 121 System.exit(20); 122 } 123 catch (Exception f) { 124 System.err.println(f.getClass().getName()); 125 System.err.println("Error in Create: " + f); 126 System.exit(20); 127 } 128 ExperimentLabels createLabels = 129 new ExperimentLabels(createResp.getExperimentID()); 130 System.out.println("New success: " + createLabels.getLocalname() 131 + "(" + createLabels.getFedid() + ") " 132 + createResp.getExperimentStatus().getValue()); 60 133 } 61 134 } -
axis/FeddCommand.java
r56baf92 r10f5e84 1 1 import edu.isi.www.fedd_types.*; 2 2 import edu.isi.www.fedd_wsdl.*; 3 import java.net.URL; 3 import java.net.*; 4 import java.util.*; 5 4 6 import net.deterlab.isi.XTrustProvider; 5 7 import net.deterlab.isi.Fedid; 6 8 7 class FeddCommand { 9 import javax.net.ssl.*; 10 11 public class FeddCommand { 12 13 static { setUpSecurity(); } 8 14 9 15 static class ExperimentLabels { … … 43 49 System.setProperty("javax.net.ssl.keyStore", keyStore); 44 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); } 45 66 } 46 67 … … 50 71 * Boilerplate web services access stuff. 51 72 */ 73 clearSSLSessionCache(); 52 74 FeddServiceLocator service = new FeddServiceLocator(); 53 75 FeddPortType port = service.getfeddPort(new URL(server)); -
axis/MultiStatus.java
r56baf92 r10f5e84 20 20 21 21 FeddPortType port = getPort("https://users.isi.deterlab.net:23235"); 22 setUpSecurity();23 22 /* 24 23 * The various parts of the MultiInfo message and response … … 32 31 resp = port.multiInfo(req); 33 32 } 34 catch ( FaultTypee) {33 catch (Exception e) { 35 34 System.out.println(e); 36 35 System.exit(0);
Note: See TracChangeset
for help on using the changeset viewer.