In this section you will learn how to switch on message-level or transport-level security in order to communicate with a secure service. Please note that these features are only supported on the OGSA-DAI WSRF platform.
In order to run the examples below, you must have:
The following steps show you how to write a Java client that contacts a secure data service. For this example, we assume a secure data service is available at https://myComputer.myCompany.com:8443/wsrf/services/ogsadai/SecureDataService with data resource MySQLResource.
static { CogUtil.registerTransport(); }
String handle = "https://myComputer.myCompany.com:8443/wsrf/services/ogsadai/SecureDataService"; String id = "MySQLResource"; DataService secureService = GenericServiceFetcher.getInstance().getWSRFDataService(handle, id);
GSITransportEncryptionProperty securityProperty = new GSITransportEncryptionProperty(); service.setConnectionProperty(securityProperty);
String sql = "select * from littleblackbook where id = 10"; SQLQuery query = new SQLQuery(sql); WebRowSet rowset = new WebRowSet(query.getOutput()); ActivityRequest request = new ActivityRequest(); request.add(query); request.add(rowset); service.perform(request);
See OGSA-DAI/examples/src/uk/org/ogsadai/examples/clienttoolkit/WSRFTransportLevelSecurityExample.java for an example solution.
The following steps show you how to write a Java client that contacts a secure data service using message-level security. For this example, we assume a secure data service is available at http://myComputer.myCompany.com:8999/wsrf/services/ogsadai/SecureDataService with data resource MySQLResource. Note that the http protocol and not the https protocol is used for message-level security.
String handle = "http://myComputer.myCompany.com:8999/wsrf/services/ogsadai/SecureDataService"; String id = "MySQLResource"; DataService secureService = GenericServiceFetcher.getInstance().getWSRFDataService(handle, id);Make sure you specify the correct protocol and port number in the handle because they will be different from the previous example!
SecurityConfigProperty securityProperty = new SecurityConfigProperty( new File("examples/src/uk/org/ogsadai/examples/clienttoolkit/MLSecurityDescriptor.xml")); secureService.setConnectionProperty(securityProperty);The provided security descriptor specifies that GSI secure conversation is to be used with privacy (encryption) and full delegation. Host authorization ensures that the server's host credential matches the hostname of the URL used to access the server.
See OGSA-DAI/examples/src/uk/org/ogsadai/examples/clienttoolkit/WSRFMessageLevelSecurityExample.java for an example solution.
Up: Using the Client Toolkit | ||
© International Business Machines Corporation, 2002-2006 | © The University of Edinburgh, 2002-2006 |