I wanted to start a discussion about securing web services within the J2EE platform, since the intersection of J2EE container security and WS-Security is a topic that does not get enough attention in the specifications or in vendor documentation.
With the release of JAX-RPC 1.1 as part of J2EE 1.4, we now have a standardized API for building SOAP-based web services in Java. However, the security story remains fragmented. The J2EE specification provides container-managed authentication and role-based authorization through JAAS, but these mechanisms were designed for servlet and EJB clients, not for SOAP message processing. The result is that each application server vendor has taken a different approach to bridging the gap between WS-Security tokens in SOAP headers and the J2EE security context.
JAX-RPC Handler Chains for Security Processing
The JAX-RPC specification defines a handler framework that allows request and response messages to be intercepted and processed before reaching the endpoint implementation. This is the natural place to implement WS-Security processing in a J2EE environment. A typical security handler chain would include:
<handler-chains>
<handler-chain>
<handler>
<handler-name>WSSTimestampHandler</handler-name>
<handler-class>com.xwss.handlers.TimestampValidationHandler</handler-class>
</handler>
<handler>
<handler-name>WSSSignatureHandler</handler-name>
<handler-class>com.xwss.handlers.SignatureVerificationHandler</handler-class>
</handler>
<handler>
<handler-name>WSSAuthHandler</handler-name>
<handler-class>com.xwss.handlers.UsernameTokenHandler</handler-class>
</handler>
</handler-chain>
</handler-chains>
The challenge is that JAX-RPC handlers operate on the SOAP message (as a SOAPMessageContext), but they have no direct access to the J2EE container's security infrastructure. After validating a UsernameToken or X.509 certificate in the handler, you need a way to establish a JAAS Subject and propagate it into the container's security context so that EJB method-level permissions and isCallerInRole() checks work correctly in the service implementation.
I would like to hear how others are handling this integration, particularly on WebLogic and WebSphere where the proprietary security SPIs differ significantly.
- Craig Brennan