Download
To enable GSI security in Tomcat you will require download the J-Globus FX jars.
http://dev.globus.org/wiki/CoG_JGlobus_1.6.0
You will require following additional jars from
http://www.bouncycastle.org/latest_releases.html
1.bcprov-jdk16-143.jar
2.bcprov-ext-jdk14-143.jar
Note:
The binary distribution does not consist of a required class file. For this purpose you need to make the jars from source code.
Alternatively, you can download WS-Core binary distribution to obtain the required jar.
Configuring Tomcat Server with GSI Security
Make the following changes in $TOMCAT_HOME/conf/server.xml
(a) Add an HTTPS connector in the service tag.
<!-- Define a GSI HTTPS/1.1 Connector on port 8443
Supported parameters include:
proxy // proxy file for server to use
or
cert // server certificate file in PEM format
key // server key file in PEM format
cacertdir // directory location containing trusted CA certs
encryption (true/false) // enable/disable encryption
-->
<Connector port="9005"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" debug="0" scheme="https"
autoFlush="true"
protocolHandlerClassName="org.apache.coyote.http11.Http11Protocol"
socketFactory="org.globus.tomcat.catalina.net.BaseHTTPSServerSocketFactory"
proxy="Path to your proxy file"
cert="path to containers cert file"
key="path to containers key file"
cacertdir="path to certificates folder" />
< className="org.globus.tomcat.coyote.valves.HTTPSValve55"/>
When using ChunkedInputStream tomcat stores a 0 in its buffer every time a connection is closed. However, when obtaining a new request it does no ignore preceding 0’s resulting in a 0
This requires a minor change in tomcat’s source code.
In the class org.apache.coyote.http11.InternalInputBuffer’s parseRequestLine method
Replace the existing if block with the following while block.
do
{
// Read new bytes if needed.
if (pos >= lastValid)
{
if (!fill ())
throw new EOFException (sm.getString ("iib.eof.error"));
}
chr = buf [pos++];
}
while ((chr == Constants.CR) || (chr == Constants.LF) || chr == '0');
Replace the class file in $TOMCAT_HOME/server/lib/tomcat-http.jar
OR
Download the altered jar from
https://pegasus.isi.edu/svn/mcs/trunk/lib/tomcat-http.jar and replace it with $TOMCAT_HOME/server/lib/tomcat-http.jar
Refer To - http://mail-archives.apache.org/mod_mbox/tomcat-users/200904.mbox/%3C47CD64D7E22C3949A40CA4751EB20E811174077A70@boumail.infotrustgroup.com%3E
Some additional steps may be required if Globus is not installed on your machine.
Copying required JAR files
(a) Copy the following jars from the JGlobus FX distribution to $TOMCAT_HOME/common/lib
1.cog-jglobus.jar.
2.log4j-xxx.jar.jar.
3.puretls.jar.
4.cryptix32.jar.
5. cryptix-asn1.jar
(b) Copy the following jars from the JGlobus FX distribution If compile from source) OR from WS-Core Distribution to $TOMCAT_HOME/server/lib
1.cog-tomcat.jar
(c) Copy the following jar to $TOMCAT_HOME/common/lib
1. bcprov-jdk16-143.jar
2. bcprov-ext-jdk14-143.jar
Web Service (Axis 2) - Using GSI Security.
Server Side Implementation
Authentication is completely handled by the GSI security jars deployed on the tomcat server.
Obtaining the Authorized User DN can be accomplished with the following code snippet.
private String getAuthorizedUserDn ()
{
MessageContext messageContext = MessageContext.getCurrentMessageContext ();
HttpServletRequest httpRequest = (HttpServletRequest) messageContext.getProperty (HTTPConstants.MC_HTTP_SERVLETREQUEST);
return (String) httpRequest.getAttribute ("org.globus.gsi.authorized.user.dn");
}
The code snippet simply acquires the current HTTPServletRequest object from the message context of Axis2. Once the HTTPServletRequest object is obtained the authorized user DN can be obtained from the object using the getAttribute method of the object. The key o be passed to the getAttribute method is "org.globus.gsi.authorized.user.dn".
Client Side Implementation
The client side implementation is a bit tricky.
The JGlobus FX distribution provides an extended socket which handles GSI security. However, to be able to use this we need control over the socket that Tomcat server uses to send and receive SOAP messages.
Tomcat uses commons-http library for sending and receiving of HTTP messages. This library provides a mechanism with which we can provide it a custom socket. Since we need socket specific to a protocol the library requires us to register the custom socket factory class with the associated protocol.
Refer: http://hc.apache.org/httpclient-3.x/sslguide.html
Write the custom class to create a socket.
https://pegasus.isi.edu/svn/mcs/trunk/src/edu/isi/pegasus/httpclient/socket/MCSGSISocketFactory.java
Register the custom socket factory class with a protocol.
import org.apache.commons.httpclient.protocol.Protocol;
import edu.isi.pegasus.httpclient.socket.MCSGSISocketFactory;
Protocol protocol = new Protocol ("https", new MCSGSISocketFactory (), 8444);
Protocol.registerProtocol ("https", protocol);
Now, whenever tomcat requires a new socket to communicate using the https protocol it will call tomcats create socket method to obtain one.
References
http://dev.globus.org/wiki/CoG_JGlobus_1.6.0
http://www.bouncycastle.org/latest_releases.html
http://hc.apache.org/httpclient-3.x/sslguide.html
https://pegasus.isi.edu/svn/mcs/trunk/src/edu/isi/pegasus/httpclient/socket/MCSGSISocketFactory.java
https://pegasus.isi.edu/svn/mcs/trunk/src/edu/isi/pegasus/mcs/service/restful/MCSServiceImpl.java
http://mail-archives.apache.org/mod_mbox/tomcat-users/200904.mbox/%3C47CD64D7E22C3949A40CA4751EB20E811174077A70@boumail.infotrustgroup.com%3E