//(c) University of Edinburgh, 2002 - 2006. //See OGSA-DAI-Licence.txt for licencing information. package uk.org.ogsadai.teragrid; import javax.xml.rpc.Stub; import org.globus.wsrf.impl.security.descriptor.ClientSecurityDescriptor; import org.globus.wsrf.impl.security.authorization.Authorization; import org.globus.wsrf.impl.security.authorization.SelfAuthorization; import org.globus.wsrf.impl.security.authentication.Constants; import org.gridforum.jgss.ExtendedGSSManager; import org.ietf.jgss.GSSCredential; import uk.org.ogsadai.activity.delivery.wsrf.GSISecureConversationProperty; import uk.org.ogsadai.client.CoGUtil; import uk.org.ogsadai.client.toolkit.GenericServiceFetcher; import uk.org.ogsadai.client.toolkit.security.wsrf.GSIAuthorizationType; import uk.org.ogsadai.client.toolkit.security.wsrf.GSIProtectionLevel; import uk.org.ogsadai.client.toolkit.security.wsrf.GSITransportEncryptionProperty; import uk.org.ogsadai.client.toolkit.service.DataService; /** * Demo client to test the TeraGrid/OGSA-DAI service that returns * the charge for a job. * * @author OGSA-DAI team */ public class DemoClient { public static void main(String args[]) throws Exception { if (args.length != 3) { // Usage error System.out.println( "Usage: java DemoClient serviceURL dataServiceResourceID gridJobID"); return; } String serviceUrl = args[0]; String resourceId = args[1]; String gridJobId = args[2]; // Print settings System.out.println("Service URL: " + serviceUrl); System.out.println("Data Service Resource ID: " + resourceId); System.out.println("Grid Job ID: " + gridJobId); //enable https CoGUtil.registerTransport(); // Display the user's DN ExtendedGSSManager manager = (ExtendedGSSManager)ExtendedGSSManager.getInstance(); GSSCredential cred = manager.createCredential(GSSCredential.INITIATE_AND_ACCEPT); System.out.println("User's DN: " + cred.getName().toString()); // Get the charge for the grid job ID DataService service = GenericServiceFetcher.getInstance().getWSRFDataService( serviceUrl, resourceId); /* GSISecureConversationProperty secConvProperty = new GSISecureConversationProperty(); secConvProperty.setAuthorization(GSIAuthorizationType.NONE); secConvProperty.setCredential(cred); secConvProperty.setProtectionLevel(GSIProtectionLevel.INTEGRITY); service.setConnectionProperty(secConvProperty); */ /* GSITransportEncryptionProperty gsiTransProperty = new GSITransportEncryptionProperty(); service.setConnectionProperty(gsiTransProperty); */ TeraGridGetChargeForJob chargeQuery = new TeraGridGetChargeForJob(gridJobId); service.perform(chargeQuery); double charge = chargeQuery.getCharge(); System.out.println("The charge for this job is: " + charge); } }