Dear all,
I have wrote successfully a simple client for the
grid services OGSA-DAI wsrf 2.1 deployed in Globus Toolkit 4.0.1. Before
executing it, I have to logon to My Proxy Server.
Now I’m writing a portlet JSR 168 compliant
for the gridsphere portal 2.1.4 using OGSA-DAI wsrf 2.1 API.
This is the code:
package ogsadai.OracleResource.portlets;
//(c) International Business Machines Corporation,
2005.
//(c) University of Edinburgh, 2005.
//See OGSA-DAI-Licence.txt for licencing
information.
import javax.portlet.GenericPortlet;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import java.util.List;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.File;
import uk.org.ogsadai.client.toolkit.GenericServiceFetcher;
import uk.org.ogsadai.client.toolkit.Response;
import uk.org.ogsadai.client.toolkit.activity.ActivityRequest;
import uk.org.ogsadai.client.toolkit.activity.sql.SQLQuery;
import uk.org.ogsadai.client.toolkit.activity.sql.WebRowSet;
import
uk.org.ogsadai.client.toolkit.security.wsrf.GSITransportEncryptionProperty;
import uk.org.ogsadai.client.toolkit.service.DataService;
import uk.org.ogsadai.client.toolkit.service.ConfigurableDataService;
import
uk.org.ogsadai.client.toolkit.security.wsrf.SecurityConfigProperty;
import uk.org.ogsadai.client.toolkit.exception.ServiceCommsException;
import
org.gridlab.gridsphere.portlet.service.spi.PortletServiceFactory;
import org.gridlab.gridsphere.portlet.service.PortletService;
import org.gridlab.gridsphere.portlet.service.spi.impl.SportletServiceFactory;
import org.gridlab.gridsphere.portlet.service.PortletServiceException;
import
org.gridlab.gridsphere.services.security.gss.CredentialManagerService;
import org.gridlab.gridsphere.portlet.impl.SportletProperties;
import org.gridlab.gridsphere.portlet.User;
import org.ietf.jgss.GSSCredential;
import uk.org.ogsadai.common.SecurityContext;
/**
* This example shows how to connect to a secure
data service using transport
* level security.
*
* @author The OGSA-DAI team.
*/
public class Client extends GenericPortlet {
public void doView(RenderRequest req, RenderResponse
resp) throws IOException
{
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
GSSCredential
credential = null;
CredentialManagerService
credentialManagerService = null;
PortletServiceFactory
factory = SportletServiceFactory.getInstance();
try
{
credentialManagerService
= (org.gridlab.gridsphere.services.security.gss.CredentialManagerService)factory.createPortletService(org.gridlab.gridsphere.services.security.gss.CredentialManagerService.class,null,true);
}
catch (PortletServiceException
e)
{
out.println("Unable to initialize required portlet services "+e);
}
User user = (User)req.getAttribute(SportletProperties.PORTLET_USER);
List credentialList
= credentialManagerService.getActiveCredentials(user);
if (credentialList.size()
> 0)
{
credential
= (GSSCredential)credentialList.get(0);
}
// set up service
URL and resource ID
String handle =
"https://my_machine:8443/wsrf/services/ogsadai/DataService";
String id = "OracleResource";
out.println(handle);
try
{
out.println("Credential
DN: "+ credential.getName().toString());
SecurityContext
s = new SecurityContext(credential.getName().toString(),credential);
}
catch (Exception e)
{
out.println("Errore
di sicurezza: "+e);
}
// Locate a Data
Service
//DataService secureService
= GenericServiceFetcher.getInstance().getWSRFDataService(handle, id);
// Setup message
level security
ConfigurableDataService
secureService = null;
try
{
secureService
= GenericServiceFetcher.getInstance().getConfigurableDataService(handle,id);
}
catch (ServiceCommsException
e)
{
out.println("
ERROR: "+e);
out.println("
URL: "+e.getURL());
}
catch (Exception e)
{
out.println("
ERROR: "+e);
}
SecurityConfigProperty
securityProperty = new SecurityConfigProperty(new File("/usr/local/ogsadai-wsrf-2.1/examples/src/uk/org/ogsadai/examples/clienttoolkit/MLSecurityDescriptor.xml"));
secureService.setConnectionProperty(securityProperty);
// Setup encryption
//secureService.setConnectionProperty(new
GSITransportEncryptionProperty());
out.println("Ready
to connect to secure data service at " + secureService.getURL());
// Now perform a
simple SQLQuery
SQLQuery query = new SQLQuery("select * from prova");
WebRowSet rowset =
new WebRowSet( query.getOutput() );
ActivityRequest
request = new ActivityRequest();
request.add( query
);
request.add( rowset
);
out.println("
Performing SQL query...");
Response
response=null;
try
{
response
= secureService.perform( request );
}
catch (Exception e)
{
out.println(e);
}
out.println("Response:\n"
+ response.getAsString());
}
}
When I run the portlet above deployed into GridSphere
2.1.4, I obtain the following error:
uk.org.ogsadai.client.toolkit.exception.ServiceCommsException:
A problem arose during communication with service
https://my_machine:8443/wsrf/services/ogsadai/DataService?WSDL. Message:
Default SSL context init failed: null An error arose in a non-OGSA-DAI class.
Message: Default SSL context init failed: null
I think it is related with context initilizing i.e
it’s necessary to pass credential to the method ‘getConfigurableDataService(String
handle,String id)’.
In the source code above I have recovered
portal’s user credential within MyProxy Server and I want to pass it when
I invoke getConfigurableDataService(handle,id) method.
Have you experiences with OGSA-DAI and in
particular with OGSA-DAI 2.1 in a web application?
Thanks in advance for your help and excuse me for
my English.
Vincenzo Gioviale