In Part 1 of this article, I discussed using a Java application as a Web service client and a creative way to secure that client using JAAS and SAML. Part 2 is a consequence of the same application, but I examine how to attach a SAML token to a SOAP message from within a Java application to invoke a Web service that is secured using WS-Security SAML policy file. Here I focus on the mechanism needed to invoke a secure Web service.
I don't discuss configuring SAML on an application server, generating Web service client stubs, annotating a Web service to use SAML as a WS-Security token or configuring a SAML provider/authority. Those types of things are implementation-specific, but important when creating an end-to-end SOA security architecture.
Application Design
Using an IDE or Ant script, it is relatively easy to design and create Web services (and to compile the bindings) that invoke the service from a remote client application. Adding security to the application, on the other hand, is a horse of a different color. However, if security is not seriously considered, then you should face the fact that you are building what I call a "Pet Store" application.
SAML Application Architecture and the Security Workflow
Figure 1, a high-level view of the deployment architecture for the target Java application, depicts the security model workflow. In the model, the Java application makes an HTTP(S) call to the SAML authority inside the firewall using a .NET service that integrates with AFDS (Active Directory Federation Service). The return parameter is a signed, SAML token that is generated based on the user's credentials (i.e., a Kerberos ticket). This token is injected into a SOAP header from within a Java application, which can then invoke a secure Web service that is protected using WS-Security.
Client-side Java Application Objects Roles and Responsibilities
Figure 2 illustrates the objects used for marshaling Web services, including injecting a SAML token into the SOAP message:
- SAMLAuthenticationHandler extends GenericHandler, which is part of the javax.xml.rpc.handler package, and responsible for marshaling the SAML token into the SOAP header.
- Authenticator is an application object used to retrieve the SAML token from a third-party authority. This implementation is based on the SAML provider used in your target architecture and thus, not part of a Java package.
- Stub is part of the javax.xml.rpc.Stub package used for binding with a remote Web service. It provides SOAP RPC functionality.
- Service_Impl is a generated Web service object that is a local representation of the remote Web service object.
- HandlerInfo is part of the javax.xml.rpc.handler package, this class has a callback method that sets the SAMLAuthenticationHandler.class.
- HandlerRegistry is part of the javax.xml.rpc.handler package, which is responsible for registering the callback on the service object (Service_Impl).
- Properties is a part of the java.util package used to contain the application URLs, namespaces, SOAP ports, etc. Binding information for remote services will change overtime, if not contained in a dynamic Web service registry. It is recommended that these end-points be stored outside of the application in a properties file, if not stored in a service registry.