Changeset 10f5e84 for axis/Create.java
- Timestamp:
- Mar 31, 2011 10:07:29 PM (13 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- 9f8dbc1
- Parents:
- 56baf92
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.