Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

JVM Languages

SAML, JAAS, & Role-Based Access Control: Part 2

Frank Teti is a Consulting Technical Manager within Oracle's SOA practice. He can be reached at [email protected]

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.

[Click image to view at full size]
Figure 1: Java application acquires a SAML token to invoke a secure Web service requests.

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.

[Click image to view at full size]
Figure 2: UML View of Participating SOAP Message Handling Classes

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.