<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7391783704166348052</id><updated>2012-02-22T05:02:51.053-08:00</updated><title type='text'>Open Source Security</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>59</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-708652703406709249</id><published>2012-02-22T05:02:00.000-08:00</published><updated>2012-02-22T05:02:51.065-08:00</updated><title type='text'>WS-Trust SPNego support in Apache CXF</title><content type='html'>Support for SPNego using WS-Trust has been &lt;a href="https://issues.apache.org/jira/browse/CXF-3635"&gt;added&lt;/a&gt; to Apache CXF and will be available in the forthcoming 2.4.7 and 2.5.3 releases. This new functionality allows a CXF client to integrate with WCF 4.0, as WCF 4.0 uses message level NTLM/Kerberos based on SPNego using WS-Trust. See the following &lt;a href="http://groovyjava-tom.blogspot.com/2012/01/cxf-and-ms-crm-2011.html"&gt;blog&lt;/a&gt; for an in-depth explanation of how to do exactly this. Support for obtaining and validating SPNEGO tokens was &lt;a href="https://issues.apache.org/jira/browse/WSS-327"&gt;added&lt;/a&gt; to Apache WSS4J in the 1.6.4 release. WSS4J 1.6.5 will feature &lt;a href="https://issues.apache.org/jira/browse/WSS-332"&gt;support&lt;/a&gt; for making the Spnego Client and Service Action classes pluggable, so that the user can specify a custom means of obtaining the ticket.    &lt;br /&gt;&lt;br /&gt;Using WS-Trust for SPNego is described in the following application &lt;a href="http://schemas.xmlsoap.org/ws/2005/02/trust/spnego/WSTrustForSPNego.pdf"&gt;note&lt;/a&gt;. The client contacts a KDC and obtains a SP Negotiation token, which it sends to the service provider via WS-Trust. If the negotiation is incomplete, the service provider can respond to the client to continue the negotiation. Once the negotiation is complete, a WS-Trust RequestedProofToken is created which contains a secret key that has been encrypted with the negotiated key, and this is returned to the client along with an Authenticator and a SecurityContextToken. The client can decrypt the EncryptedKey, and use this key with a symmetric encryption or signature algorithm to secure a request.&lt;br /&gt;&lt;br /&gt;Note that the focus is on making sure that a CXF client can interoperate with WCF, and hence the STS support for SPNego is only intended as a means of testing the client code. In particular, the STS does not return an Authenticator, which is required by the spec. One additional limitation is that the STS client does not currently support continued negotation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Running the WS-Trust SPNego system tests in Apache CXF&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To run the WS-Trust SPNego system tests in CXF, it is first necessary to set up a KDC correctly. Follow the &lt;a href="http://coheigea.blogspot.com/2011/10/using-kerberos-with-web-services-part-i.html"&gt;instructions&lt;/a&gt; given in section 1 in a previous blog post which describes how to run the Kerberos system tests in CXF. Next, make sure that the JDK has unlimited security policies installed, and then checkout the CXF trunk via:&lt;br /&gt;&lt;blockquote&gt;svn co https://svn.apache.org/repos/asf/cxf/trunk/&lt;/blockquote&gt;Go into the "trunk" directory, and compile and install CXF via "mvn -Pfastinstall" (this will avoid running tests). Finally go into the WS-Security system tests in "systests/ws-security". The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/spnego/SpnegoTokenTest.java?view=markup"&gt;SpnegoTokenTest&lt;/a&gt; contains two tests, which are @Ignore'd by default. Open SpnegoTokenTest.java and comment out the "@org.junit.Ignore" entries for both tests. If you want to see the message exchanges, open src/test/resources/logging.properties, and change the level from WARNING to INFO, and the ConsoleHandler level from SEVERE to INFO. Finally, run the tests via:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mvn test -Dtest=SpnegoTokenTest -Djava.security.auth.login.config=src/test/resources/kerberos.jaas&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.1) WS-SecurityPolicy configuration &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/spnego/DoubleItSpnego.wsdl?view=markup"&gt;wsdl&lt;/a&gt; that defines the service endpoints contains WS-SecurityPolicy expressions that define the security requirements of the endpoints. The following security policies are used for the tests:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;DoubleItSpnegoSymmetricProtectionPolicy: This uses a Symmetric binding, where the protection token is a SpnegoContextToken.&lt;/li&gt;&lt;li&gt;DoubleItSpnegoSymmetricProtectionDerivedPolicy: This uses a Symmetric binding, where the protection token is key derived from a SpnegoContextToken.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;1.2) Kerberos LoginModule configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Both the CXF client and service endpoint use JAAS to authenticate to the KDC. The JAAS &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/kerberos.jaas?view=markup"&gt;file&lt;/a&gt; used as part of the system test is passed to the tests via the System property "java.security.auth.login.config". The client (alice) uses the following login module: &lt;br /&gt;&lt;blockquote&gt;alice {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.sun.security.auth.module.Krb5LoginModule required&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; refreshKrb5Config=true useKeyTab=true keyTab="/etc/alice.keytab"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; principal="alice";&lt;br /&gt;};&lt;/blockquote&gt;and the service endpoint (bob) uses:&lt;br /&gt;&lt;blockquote&gt;bob {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.sun.security.auth.module.Krb5LoginModule required&lt;br /&gt;&amp;nbsp; &amp;nbsp; refreshKrb5Config=true useKeyTab=true storeKey=true&lt;br /&gt;&amp;nbsp; &amp;nbsp; keyTab="/etc/bob.keytab" principal="bob/service.ws.apache.org";&lt;br /&gt;};&lt;b&gt; &lt;/b&gt;&lt;/blockquote&gt;&lt;b&gt;1.3) Client and Service endpoint configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Both the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/spnego/server/server.xml?view=markup"&gt;service&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/spnego/client/client.xml?view=markup"&gt;client&lt;/a&gt; endpoints are spring-loaded. The contain the following JAX-WS properties, which are defined in &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?view=markup"&gt;SecurityConstants:&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&amp;nbsp;"ws-security.kerberos.jaas.context"  - This refers to the JAAS context given in the configuration file above. The clients use a value of "alice", and the service endpoints use "bob".&lt;/li&gt;&lt;li&gt;"ws-security.kerberos.spn"- This is only configured on the client side, and specifies the Kerberos Service Provider Name ("bob@service.ws.apache.org").&lt;/li&gt;&lt;/ul&gt;Finally, there is one additional JAX-WS property that can be defined on the client, if you want to plug in a custom WSS4J SpnegoClientAction implementation:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;"ws-security.spnego.client.action" - The SpnegoClientAction implementation to use for SPNEGO. This allows the user to plug in a different implementation to obtain a service ticket. See &lt;a href="http://groovyjava-tom.blogspot.com/2012/01/cxf-and-ms-crm-2011.html"&gt;here&lt;/a&gt; for more details on how to use this property.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-708652703406709249?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/708652703406709249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2012/02/ws-trust-spnego-support-in-apache-cxf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/708652703406709249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/708652703406709249'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2012/02/ws-trust-spnego-support-in-apache-cxf.html' title='WS-Trust SPNego support in Apache CXF'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6491232926998572522</id><published>2012-01-24T07:51:00.000-08:00</published><updated>2012-01-24T07:51:34.041-08:00</updated><title type='text'>Apache Santuario (XML Security for Java) 1.5.0 released</title><content type='html'>Apache Santuario (XML Security for Java) 1.5.0 has been released. It can be downloaded &lt;a href="http://santuario.apache.org/download.html"&gt;here&lt;/a&gt;. Please read the &lt;a href="http://santuario.apache.org/java150releasenotes.html"&gt;release notes&lt;/a&gt; (collated from my previous blog entries) if you are planning to upgrade.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6491232926998572522?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6491232926998572522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2012/01/apache-santuario-xml-security-for-java_24.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6491232926998572522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6491232926998572522'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2012/01/apache-santuario-xml-security-for-java_24.html' title='Apache Santuario (XML Security for Java) 1.5.0 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-3917287411426857447</id><published>2012-01-13T08:52:00.000-08:00</published><updated>2012-01-13T08:52:48.750-08:00</updated><title type='text'>Apache Santuario (XML Security for Java) 1.5.0 RC2</title><content type='html'>I &lt;a href="http://coheigea.blogspot.com/2011/12/apache-santuario-xml-security-for-java.html"&gt;posted&lt;/a&gt; a RC1 for Apache Santuario (XML Security for Java) almost a month ago now. Since then, a large number of changes have been made to address some inconsistencies in RC1 as well to add some new functionality. The RC2 release is available &lt;a href="http://people.apache.org/%7Ecoheigea/stage/xmlsec/1.5.0-RC2/"&gt;here&lt;/a&gt;. Please download it and post any issues that are found to the &lt;a href="http://santuario.apache.org/mailing.html"&gt;mailing list&lt;/a&gt;. The changes compared to the RC1 release (documented &lt;a href="http://coheigea.blogspot.com/2011/12/apache-santuario-xml-security-for-java.html"&gt;here&lt;/a&gt;) are as follows:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Support for RSA-OAEP key transport algorithms with strong digests&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The 1.4.x releases only support using SHA-1 with the RSA-OAEP key transport algorithm for encryption and decryption. The 1.5.0 RC2 release &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-282"&gt;supports&lt;/a&gt; stronger digests using the ds:DigestMethod child of xenc:EncrytionMethod. In addition, it fully supports the xenc11:MGF Algorithm as &lt;a href="http://www.w3.org/TR/xmlenc-core1/#sec-RSA-OAEP"&gt;documented&lt;/a&gt; in the XML Encryption 1.1 specification. &lt;br /&gt;&lt;br /&gt;To test this functionality, all of the XML Encryption 1.1 Key Wrapping &lt;a href="http://www.w3.org/2008/xmlsec/Drafts/xmlenc-core-11/test-cases/"&gt;test-cases&lt;/a&gt; have been &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-293"&gt;implemented&lt;/a&gt;, both for encryption and decryption. These tests also serve to better test the support for GCM algorithms in the 1.5.0 release. Support for 192 bit AES-GCM was added as part of this work.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Major changes to how Elements are resolved&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The release notes for RC1 described how the IdResolver no longer searches the current Document for an Element matching the requested Id in certain "known" namespaces, and instead how it was the responsibility of the user to register Elements by Id in the IdResolver (or via &lt;a href="http://docs.oracle.com/javase/6/docs/api/javax/xml/crypto/dom/DOMCryptoContext.html#setIdAttributeNS%28org.w3c.dom.Element,%20java.lang.String,%20java.lang.String%29"&gt;setIdAttributeNS&lt;/a&gt; if using the JSR-105 API), if they are required as part of the signature validation process. &lt;br /&gt;&lt;br /&gt;In RC2, the static cache of Id-&amp;gt;Elements that was maintained in the IdResolver has been removed. Instead, the ResourceResolver implementations that are responsible for resolving same-Document URI references resolve Elements by querying Document.&lt;a href="http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/Document.html#getElementById%28java.lang.String%29"&gt;getElementById&lt;/a&gt;(). The IdResolver has been deprecated, so that it is no longer possible to register an Element by Id, and the "get" methods simply delegate to the DOM call above.&lt;br /&gt;&lt;br /&gt;So what does this mean for the user? The user is now responsible for registering any same-Document Elements by Id, which must be resolved as part of the signature creation/validation process. This can be done in two ways:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Using the DOM APIs: &lt;a href="http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/Element.html"&gt;Element&lt;/a&gt;.setIdAttribute*&lt;/li&gt;&lt;li&gt;Using the JSR-105 API: DOMCryptoContext.&lt;a href="http://docs.oracle.com/javase/6/docs/api/javax/xml/crypto/dom/DOMCryptoContext.html#setIdAttributeNS%28org.w3c.dom.Element,%20java.lang.String,%20java.lang.String%29"&gt;setIdAttributeNS&lt;/a&gt;&lt;b&gt; &lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;3) Better protection against Signature Wrapping Attacks&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A Signature Wrapping attack can occur when a malicious entity duplicates some signed Element in a document, and then modifies the content of the duplicated Element, but keeps the same Id. If the signature validation process only finds the initial Element, then signature validation will pass, and the user might be fooled into thinking that the modified Element has been signed, as it has the same Id as the original validated Element.&lt;br /&gt;&lt;br /&gt;The implication of this attack is that it is vital that the user checks that the Elements that were signed correspond to the Elements that he/she expects to be signed. In other words, the Elements that were signed should be located in a specific "known" place in the Document. The best way of facilitating this check is to make sure that the signature validation process returns the Elements that it validated. The JSR-105 API supports this via the "javax.xml.crypto.dsig.cacheReference" boolean property, that can be set on the &lt;a href="http://docs.oracle.com/javase/6/docs/api/javax/xml/crypto/dsig/XMLValidateContext.html"&gt;context&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;However, the older &lt;a href="http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignature.java?view=markup"&gt;XMLSignature&lt;/a&gt;, which pre-dates the JSR-105 API, did not include this functionality. This has been &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-292"&gt;fixed&lt;/a&gt; in the RC2 release, e.g.:&lt;br /&gt;&lt;br /&gt;XMLSignature signature = ...&lt;br /&gt;// Perform validation and then... &lt;br /&gt;SignedInfo signedInfo = signature.getSignedInfo();&lt;br /&gt;for (int i = 0; i &amp;lt; signedInfo.getLength(); i++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Reference reference = signedInfo.item(i);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ReferenceData refData = reference.getReferenceData();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;....&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;a href="http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/reference/ReferenceData.java?view=markup"&gt;ReferenceData&lt;/a&gt; is a new interface that duplicates the way the JSR-105 API returns references. Three different implementations have been &lt;a href="http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/reference/"&gt;provided&lt;/a&gt; depending on whether the dereferenced Element is a NodeSet, Element or OctetStream.&lt;br /&gt;&lt;br /&gt;Finally, some new functionality has been added when secure validation is enabled, to ensure that when an Element is de-referenced via Document.getElementById() (as described above), no other Element in the tree has an Attribute that is also registered as an Id with the same value. This is done via a tree search, and guarantees that the Element retrieved via the getElementById call is unique in the Document (something that is not guaranteed by the contract of getElementById). However note that another Element could still exist in the tree with a matching Id in another namespace.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-3917287411426857447?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/3917287411426857447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2012/01/apache-santuario-xml-security-for-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3917287411426857447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3917287411426857447'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2012/01/apache-santuario-xml-security-for-java.html' title='Apache Santuario (XML Security for Java) 1.5.0 RC2'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6681082904770496178</id><published>2012-01-13T06:25:00.000-08:00</published><updated>2012-01-13T06:25:18.713-08:00</updated><title type='text'>Apache CXF 2.5.1 STS updates</title><content type='html'>Last year I wrote a series of blog posts (starting &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-i.html"&gt;here&lt;/a&gt;) documenting the Security Token Service (STS) implementation included as part of Apache CXF 2.5.0. Apache CXF 2.5.1 was &lt;a href="http://cxf.apache.org/cxf-251-release-notes.html"&gt;released&lt;/a&gt; a few weeks ago, and includes a number of bug fixes and improvements to the STS. In this post I'll document the more important changes.&lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;1) Support to configure keystores per SAML realm&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;In CXF 2.5.0 it was possible to sign an issued SAML Token using a different private key per realm, by setting the "signatureAlias" property of the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/SAMLRealm.java?view=markup"&gt;SAMLRealm&lt;/a&gt; class. However, the signature alias is used with a single KeyStore, which is shared across all realms. This problem has been &lt;a href="https://issues.apache.org/jira/browse/CXF-3924"&gt;fixed&lt;/a&gt; in CXF 2.5.1, where it is now possible to also configure a keystore to use per-realm.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Support to handle claims per realm&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;In CXF 2.5.1 support has been &lt;a href="https://issues.apache.org/jira/browse/CXF-3930"&gt;added&lt;/a&gt; to handle claims per-realm. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsHandler.java?view=markup"&gt;ClaimsHandler&lt;/a&gt; interface has been updated to so that the current realm and WebServiceContext object are available when retrieving claim values. This means that any custom ClaimsHandler implementation based on CXF 2.5.0 must be updated to reflect the changed method signature.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) Support validating a token per realm&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;In CXF 2.5.0 the current realm is ignored when validating a token. In CXF 2.5.1, support has been &lt;a href="https://issues.apache.org/jira/browse/CXF-3929"&gt;added&lt;/a&gt; to include the current realm when querying a TokenValidator implementation to see if it can "handle" a given token. In addition, all TokenValidator implementations that ship with the STS return a Principal as part of the TokenValidatorResponse object, regardless of whether validation was successful or not.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) OnBehalfOf Token Validation&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;In CXF 2.5.0 the responsibility for validating "OnBehalfOf" tokens was delegated to the TokenProvider implementation. In CXF 2.5.1, OnBehalfOf Token Validation has been &lt;a href="https://issues.apache.org/jira/browse/CXF-3928"&gt;moved&lt;/a&gt; to the TokenIssueOperation, and so OnBehalfOf Tokens are validated for all subsequent TokenProviders. This validation is achieved by querying a list of TokenValidator implementations to see if any can validate the received token. If validation is successful, then the state of the ReceivedToken (&lt;span class="hl_identifier"&gt;VALID&lt;/span&gt;, &lt;span class="hl_identifier"&gt;INVALID&lt;/span&gt;, &lt;span class="hl_identifier"&gt;NONE) &lt;/span&gt;is updated to reflect this. If no TokenValidator implementation exists that can validate the OnBehalfOf token, then the token has a state set to INVALID. Identity Mapping also now applies to the (VALID) OnBehalfOf Token.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5) Support for OnBehalfOf in the SAMLTokenProvider&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;In CXF 2.5.0, the SAMLTokenProvider can issue a SAML token based on the authenticated principal associated with the request, e.g. the principal associated with the security token in the WS-Security header. It does not support the scenario that a client is requesting a SAML token "OnBehalfOf" another SAML Token, in other words that the principal name associated with the "OnBehalfOf" token is used as the subject name of the issued SAML token. This functionality has been &lt;a href="https://issues.apache.org/jira/browse/CXF-3923"&gt;added&lt;/a&gt; in CXF 2.5.1.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;6) Validate SAML Conditions against the current time&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Support has been &lt;a href="https://issues.apache.org/jira/browse/CXF-3931"&gt;added&lt;/a&gt; to validate the Conditions of a received SAML Token against the current time.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6681082904770496178?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6681082904770496178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2012/01/apache-cxf-251-sts-updates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6681082904770496178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6681082904770496178'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2012/01/apache-cxf-251-sts-updates.html' title='Apache CXF 2.5.1 STS updates'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7457614560493749618</id><published>2011-12-20T04:35:00.000-08:00</published><updated>2011-12-20T04:35:57.815-08:00</updated><title type='text'>WS-SecurityPolicy Examples in Apache CXF</title><content type='html'>The OASIS WS-SecurityPolicy Examples Version 1.0 &lt;a href="http://docs.oasis-open.org/ws-sx/security-policy/examples/ws-sp-usecases-examples.html"&gt;specification&lt;/a&gt; gives a set of example policies for standard security deployments, as well as the corresponding message exchanges generated by those policies. The policies in the spec cover UsernameTokens, X509 Tokens, SAML Tokens and SecureConversation, used in conjunction with various security bindings (symmetric/asymmetric/transport).&lt;br /&gt;&lt;br /&gt;I have &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/"&gt;implemented&lt;/a&gt; a set of system tests in Apache CXF that use these policies with a standard "double it" web service invocation. All of the policies in the specification are covered, apart from &lt;a href="http://docs.oasis-open.org/ws-sx/security-policy/examples/ws-sp-usecases-examples.html#_Toc274723248"&gt;2.2.2.1&lt;/a&gt; which is an uncommon use-case of using an IssuedToken policy to reference an agreed out-of-band token.&lt;br /&gt;&lt;br /&gt;The example tests are a good way of understanding how to implement and use various security policies. Here are links to the various tests and WSDLs which include the corresponding security policies:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Username Token: &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/UsernameTokenTest.java?view=markup"&gt;Test&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/ut/DoubleItUt.wsdl?view=markup"&gt;WSDL&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;X509 Token: &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/x509/X509TokenTest.java?view=markup"&gt;Test&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/x509/DoubleItX509.wsdl?view=markup"&gt;WSDL&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;SAML Token: &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/saml/SamlTokenTest.java?view=markup"&gt;Test&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/saml/DoubleItSaml.wsdl?view=markup"&gt;WSDL&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Secure Conversation: &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/secconv/SecureConversationTest.java?view=markup"&gt;Test&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/secconv/DoubleItSecConv.wsdl?view=markup"&gt;WSDL&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7457614560493749618?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7457614560493749618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/12/ws-securitypolicy-examples-in-apache.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7457614560493749618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7457614560493749618'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/12/ws-securitypolicy-examples-in-apache.html' title='WS-SecurityPolicy Examples in Apache CXF'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-1990135778242331714</id><published>2011-12-19T08:16:00.000-08:00</published><updated>2011-12-19T08:16:58.064-08:00</updated><title type='text'>Apache Santuario (XML Security for Java) 1.5.0 RC1</title><content type='html'>A release candidate for Apache Santuario (XML Security for Java) 1.5.0 has been &lt;a href="http://thread.gmane.org/gmane.text.xml.security.devel/7508"&gt;published&lt;/a&gt;. Please download it and post any issues that are found to the &lt;a href="http://santuario.apache.org/mailing.html"&gt;mailing list&lt;/a&gt;. The 1.5.0 release is not binary compatible with the 1.4.x code due to extensive refactoring. Some of the more significant changes are as follows:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) JDK 1.4.x support dropped&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The 1.5.0 release drops support for JDK 1.4.x (see &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-256"&gt;here&lt;/a&gt; and &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-255"&gt;here&lt;/a&gt;). The APIs have been updated to use generics where possible.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Xalan is no longer a required dependency &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Xalan/Xerces/Xml-apis are now &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-252"&gt;optional&lt;/a&gt; dependencies, and have been marked as such in the pom. These libraries are only required if you want to support the XPath &lt;a href="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/#function-here"&gt;here()&lt;/a&gt; function, which is not supported by the XPath API in the JDK.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) GCM support added &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Support for GCM &lt;a href="http://www.w3.org/TR/xmlenc-core1/#sec-AES-GCM"&gt;algorithms&lt;/a&gt; has been &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-288"&gt;added&lt;/a&gt; via a third-party provider. See &lt;a href="https://issues.apache.org/jira/browse/WSS-325"&gt;here&lt;/a&gt; for an example of how this is done in Apache WSS4J via BouncyCastle.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) JSR-105 provider has been renamed&lt;/b&gt;&lt;br /&gt; &lt;br /&gt;The Santuario JSR-105 &lt;a href="https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/XMLDSigRI.java"&gt;provider&lt;/a&gt; "org.jcp.xml.dsig.internal.XMLDSigRI" has been renamed as "org.apache.jcp.xml.dsig.internal.XMLDSigRI". This is to avoid conflict with the JDK provider of the same name. In addition, the XMLDSigRI provider's name has changed from "XMLDSig" to "ApacheXMLDSig". See &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-287"&gt;here&lt;/a&gt; for more details.&lt;br /&gt;&lt;br /&gt;Please note that  it won't be possible to drop in the xmlsec.jar inthe endorsed directory anymore and expect it to override the JDK's JSR 105provider. You will need to edit the java.security file to register the newprovider, or hard-code the provider name in your application code.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5) Secure Validation property&lt;/b&gt;&lt;br /&gt; &lt;br /&gt;A new property has been &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-290"&gt;added&lt;/a&gt; to enable "secure validation". This property is false by default. When set to true, it enforces the following processing rules:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Limits the number of Transforms per Reference to a maximum of 5.&lt;/li&gt;&lt;li&gt;Does not allow XSLT transforms.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Does not allow a RetrievalMethod to reference another RetrievalMethod.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Does not allow a Reference to call the ResolverLocalFilesystem orthe ResolverDirectHTTP (references to local files and HTTP resourcesare forbidden).&amp;nbsp;&lt;/li&gt;&lt;li&gt;Limits the number of references per Manifest (SignedInfo) to a maximum of 30.&amp;nbsp;&lt;/li&gt;&lt;li&gt;MD5 is not allowed as a SignatureAlgorithm or DigestAlgorithm.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;This functionality is supported in the core library through additional method signatures which take a boolean, and in the JSR-105 API via the property "org.apache.jcp.xml.dsig.secureValidation, e.g.: &lt;br /&gt;&lt;br /&gt;XMLValidateContext context = new DOMValidateContext(key, elem);&lt;br /&gt;context.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;6) Dynamic registration of default algorithms&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The 1.4.x release loads all supported algorithms/implementations by reading and parsing an xml configuration file. This gives the user the power to override the default configuration file by setting the appropriate system property, and to add/remove algorithms as desired.&lt;br /&gt;&lt;br /&gt;The downside to the current configuration approach is the performance issue of reading a file from the filesystem, parsing it, and then class-loading all of the implementations. Given that the majority of users probably just use the default algorithms that come with the library, this represents a performance issue on start-up.&lt;br /&gt;&lt;br /&gt;In 1.5.0, the default algorithms are loaded dynamically. To revert to the older behaviour of loading algorithms from a properties file then set the System property "org.apache.xml.security.resource.config" to point to the file.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;7) The IdResolver no longer searches for Elements in "known" namespaces&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/IdResolver.java"&gt;IdResolver&lt;/a&gt; class is responsible for retrieving Elements for a given Id. In the 1.5.0 release it will no longer attempt to search the current Document for an Element matching the requested Id in certain "known" namespaces (e.g. SOAP Message Security). It is the responsibility of the user to register Elements by Id in the IdResolver, if they are required as part of the signature validation process. This can be done via the "&lt;a href="http://docs.oracle.com/javase/6/docs/api/javax/xml/crypto/dom/DOMCryptoContext.html#setIdAttributeNS%28org.w3c.dom.Element,%20java.lang.String,%20java.lang.String%29"&gt;setIdAttributeNS&lt;/a&gt;" method in the &lt;a href="http://docs.oracle.com/javase/6/docs/api/javax/xml/crypto/dom/DOMCryptoContext.html"&gt;DOMCryptoContext&lt;/a&gt; for users of the JSR-105 API.&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-1990135778242331714?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/1990135778242331714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/12/apache-santuario-xml-security-for-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1990135778242331714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1990135778242331714'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/12/apache-santuario-xml-security-for-java.html' title='Apache Santuario (XML Security for Java) 1.5.0 RC1'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7143982839356913819</id><published>2011-11-22T08:57:00.001-08:00</published><updated>2011-11-23T09:05:26.202-08:00</updated><title type='text'>Apache CXF STS documentation - part XII</title><content type='html'>&lt;p&gt;A &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii.html"&gt;previous&lt;/a&gt; blog post detailed the AbstractOperation class that provides some core  functionality for the STS operations, such as parsing the client request into a format that the TokenProviders/TokenValidators/TokenCancellers can consume. In this, the final post of this series of articles on the Apache CXF STS, we will examine an extension of AbstractOperation that is used to cancel tokens. Finally, we will look at the STS sample that ships with the CXF 2.5.x distribution.&lt;/p&gt;&lt;b&gt;1) The TokenCancelOperation&lt;/b&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenCancelOperation.java?view=markup"&gt;TokenCancelOperation&lt;/a&gt; is used to cancel tokens in the STS. It implements the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/CancelOperation.java?view=markup"&gt;CancelOperation&lt;/a&gt; interface in the STS provider framework. In addition to the properties that it inherits from AbstractOperation (detailed previously), it has a  single property that can be configured: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/canceller/TokenCanceller.java?view=markup"&gt;TokenCanceller&lt;/a&gt;&amp;gt; tokencancellers - A list of TokenCanceller implementations to use to cancel tokens.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Recall that AbstractOperation uses the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java?view=markup"&gt;RequestParser&lt;/a&gt; to parse a client request into &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt;objects. TokenCancelOperation first checks that a "CancelTarget" token was received and successfully parsed (if so it will be stored in the TokenRequirements object). If no token was received then an exception is thrown.&lt;/p&gt;&lt;p&gt;TokenCancelOperation then populates a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/canceller/TokenCancellerParameters.java?view=markup"&gt;TokenCancellerParameters&lt;/a&gt;object with values extracted from the TokenRequirements and KeyRequirements objects. It iterates through the list of defined TokenCanceller implementations to see if any "can handle" the received token. If no TokenCanceller is defined, or if no TokenCanceller can handle the received token, then an exception is thrown. Otherwise, the received token is cancelled. If there is an error in cancelling the token, then an exception is also thrown. A response is constructed with the context attribute (if applicable), and the cancelled token type.&lt;/p&gt;&lt;b&gt;2) The STS sample in Apache CXF&lt;/b&gt;&lt;br /&gt;&lt;p&gt;Finally, we'll take a brief look at the STS sample that ships with Apache CXF. &lt;a href="http://cxf.apache.org/download.html"&gt;Download&lt;/a&gt; and extract the Apache CXF 2.5.x distribution. Navigate into "samples/sts" and take a look at the README.txt. The service provider has a policy that requires a SAML 2.0 token issued by an STS. The client authenticates itself to the STS with a UsernameToken over the symmetric binding. The STS issues a SAML 2.0 token to the client, which sends it to the service. The IssuedToken is defined as an InitiatorToken of an Asymmetric binding in the policy of the service, and so the client will use the secret key associated with the Subject of the Assertion to sign various parts of the message.&lt;/p&gt;&lt;p&gt;Build the sample with "mvn install", and then open up three separate command prompts. Start the STS with "mvn -Psts" in one, and start the service with "mvn -Pserver" in another. Finally, start the sample in the other window with "mvn -Pclient". You will see the (encrypted) messages flowing first between the client and the STS, and then between the client and the service provider.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7143982839356913819?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7143982839356913819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-xii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7143982839356913819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7143982839356913819'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-xii.html' title='Apache CXF STS documentation - part XII'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-2730486322101493228</id><published>2011-11-21T06:14:00.000-08:00</published><updated>2011-11-21T09:18:52.565-08:00</updated><title type='text'>Apache CXF STS documentation - part XI</title><content type='html'>&lt;p&gt;A &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii.html"&gt;previous&lt;/a&gt; blog post detailed the AbstractOperation class that provides some core functionality for the STS operations, such as parsing the client request into a format that the TokenProviders/TokenValidators/TokenCancellers can consume. In this post we will examine an extension of AbstractOperation that is used to validate tokens.&lt;/p&gt;&lt;b&gt;1) The TokenValidateOperation&lt;/b&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java?view=markup"&gt;TokenValidateOperation&lt;/a&gt; is used to validate tokens in the STS. It implements the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/ValidateOperation.java?view=markup"&gt;ValidateOperation&lt;/a&gt; interface in the STS provider framework. In addition to the properties that it inherits from AbstractOperation (detailed previously), it has a single property that can be configured: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidator.java?view=markup"&gt;TokenValidator&lt;/a&gt;&amp;gt; tokenValidators - A list of TokenValidator implementations to use to validate tokens.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Recall that AbstractOperation uses the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java?view=markup"&gt;RequestParser&lt;/a&gt; to parse a client request into &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt; objects. TokenValidateOperation first checks that a "ValidateTarget" token was received and successfully parsed (if so it will be stored in the TokenRequirements object). If no token was received then an exception is thrown.&lt;/p&gt;&lt;b&gt;2) Token validation and response&lt;/b&gt;&lt;br /&gt;&lt;p&gt;TokenValidateOperation then populates a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorParameters.java?view=markup"&gt;TokenValidatorParameters&lt;/a&gt; object with values extracted from the TokenRequirements and KeyRequirements objects. It iterates through the list of defined TokenValidator implementations to see if any "can handle" the received token. If no TokenValidator is defined, or if no TokenValidator can handle the received token, then an exception is thrown. Otherwise, the received token is validated. The TokenValidateOperation then checks to see whether token transformation is required.&lt;/p&gt;&lt;b&gt;2.1) Token Transformation&lt;/b&gt;&lt;br /&gt;&lt;p&gt;If the received token is successfully validated, and if the client supplies a TokenType in the request that does not correspond to the WS-Trust "status" namespace, then the TokenValidateOperation attempts to transform the validated token into a token of the requested type. Token transformation works in a similar way to token issuing, as detailed &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii_10.html"&gt;previously&lt;/a&gt;. A TokenProviderParameters object is constructed and the same processing steps (Realm parsing, AppliesTo parsing) are followed as for token issuing.&lt;/p&gt;&lt;p&gt;One additional processing step occurs before the token is transformed. If the TokenValidatorResponse object has a principal that was set by the TokenValidator implementation, then it is set as the principal of the TokenProviderParameters object. However, it is possible that the token is being issued in a different realm to that of the validated token, and the principal might also need to be transformed. Recall that the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; configuration object &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii.html"&gt;defined&lt;/a&gt; on AbstractOperation has an &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/IdentityMapper.java?view=markup"&gt;IdentityMapper&lt;/a&gt; property. This interface is used to map identities across realms. It has a single method:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Principal mapPrincipal(String sourceRealm, Principal sourcePrincipal, String targetRealm) - Map a principal from a source realm to a target realm&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If the source realm is not null (the realm of the validated token as returned in TokenValidatorResponse), and if it does not equal the target realm (as set by the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/RealmParser.java?view=markup"&gt;RealmParser&lt;/a&gt;), then the identity mapper is used to map the principal to the target realm and this is stored in TokenProviderParameters for use in token generation. After the (optional) identity mapping step, TokenValidateOperation iterates through the TokenProvider list to find an implementation that can "handle" the desired token type in the given (target) realm (if applicable). If no TokenProvider is defined, or if no TokenProvider can handle the desired token type, then an exception is thrown.&lt;/p&gt;&lt;b&gt;2.2) Token response&lt;/b&gt;&lt;br /&gt;&lt;p&gt;After token validation has been performed, and after any optional token transformation steps, a response object is constructed containing the following items:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The context attribute (if any was specified).&lt;/li&gt;&lt;li&gt;The received Token Type (if any was specified, or the "status" token type if validation was successful).&lt;/li&gt;&lt;li&gt;Whether the received token was valid or not (status code &amp;amp; reason).&lt;/li&gt;&lt;li&gt;If the received token was valid, and if token transformation successfully occurred:&lt;ul&gt;&lt;li&gt;The transformed token.&lt;/li&gt;&lt;li&gt;The lifetime of the transformed token.&lt;/li&gt;&lt;li&gt;A number of references to that token (can be disabled by configuration).&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;3) TokenValidateOperation example&lt;/b&gt;&lt;br /&gt;&lt;p&gt;Finally, it's time to look at an example of how to spring-load the STS so that it can validate tokens. This particular &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-transport.xml?view=markup"&gt;example&lt;/a&gt; uses a security policy that requires a UsernameToken over the transport binding (client auth is disabled). As the STS is a web service, we first define an endpoint:&lt;/p&gt;&lt;pre&gt;&amp;lt;jaxws:endpoint id="transportSTS"&lt;br /&gt;    implementor="#transportSTSProviderBean"&lt;br /&gt;    address="http://.../SecurityTokenService/Transport"&lt;br /&gt;    wsdlLocation=".../ws-trust-1.4-service.wsdl"&lt;br /&gt;    xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"&lt;br /&gt;    serviceName="ns1:SecurityTokenService"&lt;br /&gt;    endpointName="ns1:Transport_Port"&amp;gt;&lt;br /&gt;    &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;        &amp;lt;entry key="ws-security.callback-handler" value="..."/&amp;gt;&lt;br /&gt;    &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:endpoint&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The CallbackHandler JAX-WS property is used to validate the UsernameToken. The "implementor" of the jaxws:endpoint is the SecurityTokenServiceProvider class defined in the STS provider framework:&lt;/p&gt;&lt;pre&gt;&amp;lt;bean id="transportSTSProviderBean"&lt;br /&gt;    class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider"&amp;gt;&lt;br /&gt;    ...&lt;br /&gt;    &amp;lt;property name="validateOperation" ref="transportValidateDelegate"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This bean supports the Validate Operation via a TokenValidateOperation instance:&lt;/p&gt;&lt;pre&gt;&amp;lt;bean id="transportValidateDelegate"&lt;br /&gt;    class="org.apache.cxf.sts.operation.TokenValidateOperation"&amp;gt;&lt;br /&gt;    &amp;lt;property name="tokenValidators" ref="transportTokenValidators"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="stsProperties" ref="transportSTSProperties"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This TokenValidateOperation instance has a number of different TokenValidator instances configured:&lt;/p&gt;&lt;pre&gt;&amp;lt;util:list id="transportTokenValidators"&amp;gt;&lt;br /&gt;    &amp;lt;ref bean="transportSamlTokenValidator"/&amp;gt;&lt;br /&gt;    &amp;lt;ref bean="transportX509TokenValidator"/&amp;gt;&lt;br /&gt;    &amp;lt;ref bean="transportUsernameTokenValidator"/&amp;gt;&lt;br /&gt;&amp;lt;/util:list&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="transportX509TokenValidator"&lt;br /&gt;    class="org.apache.cxf.sts.token.validator.X509TokenValidator"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="transportUsernameTokenValidator"&lt;br /&gt;    class="org.apache.cxf.sts.token.validator.UsernameTokenValidator"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="transportSamlTokenValidator"&lt;br /&gt;    class="org.apache.cxf.sts.token.validator.SAMLTokenValidator"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Finally the STSPropertiesMBean object that is used is given as follows:&lt;/p&gt;&lt;pre&gt;&amp;lt;bean id="transportSTSProperties"&lt;br /&gt;    class="org.apache.cxf.sts.StaticSTSProperties"&amp;gt;&lt;br /&gt;    &amp;lt;property name="signaturePropertiesFile" value="..."/&amp;gt;&lt;br /&gt;    &amp;lt;property name="signatureUsername" value="mystskey"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="callbackHandlerClass" value="..."/&amp;gt;&lt;br /&gt;    &amp;lt;property name="encryptionPropertiesFile" value="..."/&amp;gt;&lt;br /&gt;    &amp;lt;property name="issuer" value="DoubleItSTSIssuer"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="encryptionUsername" value="myservicekey"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-2730486322101493228?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/2730486322101493228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-xi.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/2730486322101493228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/2730486322101493228'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-xi.html' title='Apache CXF STS documentation - part XI'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-3368787547802336872</id><published>2011-11-15T06:56:00.001-08:00</published><updated>2011-11-18T09:35:21.290-08:00</updated><title type='text'>Apache CXF STS documentation - part X</title><content type='html'>&lt;p&gt;The &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii_10.html"&gt;previous&lt;/a&gt; blog post introduced the TokenIssueOperation, which is used to issue tokens in the STS. The article covered the various processing steps that the TokenIssueOperation does on the parsed request, before it calls a TokenProvider instance to provide a token that is returned to the client. One step that was not covered was claims handling, as this is a complex topic that merits a deeper discussion. In this post, we will look at how claims are handled in the STS as a whole.&lt;/p&gt;&lt;b&gt;1) Claims Handling in the STS&lt;/b&gt;&lt;br/&gt;&lt;p&gt;A typical scenario for WS-Trust is when the client requires a particular security token from an STS to access a service provider. The service provider can let the client know what the requirements are for the security token in an IssuedToken policy embedded in the WSDL of the service. In particular, the service provider can advertise the claims that the security token must contain in the policy (either directly as a child element of IssuedToken, or else as part of the RequestSecurityTokenTemplate). An &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/claims/DoubleIt.wsdl?view=markup"&gt;example&lt;/a&gt; is contained in the STS systests:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;    &amp;lt;t:TokenType&amp;gt;http://...#SAMLV1.1&amp;lt;/t:TokenType&amp;gt;&lt;br /&gt;    &amp;lt;t:KeyType&amp;gt;http://.../PublicKey&amp;lt;/t:KeyType&amp;gt;&lt;br /&gt;    &amp;lt;t:Claims Dialect="http://.../identity"&amp;gt;&lt;br /&gt;        &amp;lt;ic:ClaimType Uri="http://.../claims/role"/&amp;gt;&lt;br /&gt;    &amp;lt;/t:Claims&amp;gt;&lt;br /&gt;&amp;lt;/sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This template specifies that a SAML 1.1 Assertion is required with an embedded X509 Certificate in the subject of the Assertion. The issued Assertion must also contain a "role" claim. The template is sent verbatim by the client to the STS when requesting a security token.&lt;/p&gt;&lt;b&gt;1.1) Parsing claims&lt;/b&gt;&lt;br/&gt;&lt;p&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java?view=markup"&gt;RequestParser&lt;/a&gt; object parses the client request into TokenRequirements and KeyRequirements objects. As part of this processing it converts a received Claims element into a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/RequestClaimCollection.java?view=markup"&gt;RequestClaimCollection&lt;/a&gt; object. The RequestClaimCollection is just a list of RequestClaim objects, along with a dialect URI. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/RequestClaim.java?view=markup"&gt;RequestClaim&lt;/a&gt; object holds the claimType URI as well as a boolean indicating whether the claim is optional or not.&lt;/p&gt;&lt;b&gt;1.2) The ClaimsHandler&lt;/b&gt;&lt;br/&gt;&lt;p&gt;The ClaimsHandler is an interface that the user must implement to be able to "handle" a requested claim. It has two methods:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;List&lt;URI&gt; getSupportedClaimTypes() - Return the list of ClaimType URIs that this ClaimHandler object can handle.&lt;/li&gt;&lt;li&gt;ClaimCollection retrieveClaimValues(Principal principal, RequestClaimCollection claims) - Return the claim values associated with the requested claims (and client principal).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimCollection.java?view=markup"&gt;ClaimCollection&lt;/a&gt; object that is returned is just a list of &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/Claim.java?view=markup"&gt;Claim&lt;/a&gt; objects. This object represents a Claim that has been processed by a ClaimsHandler instance. It essentially contains a number of properties that the ClaimsHandler implementation will set, e.g.:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;URI claimType - The claimtype URI as received from the client.&lt;/li&gt;&lt;li&gt;String value - The claim value&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Each Claim object in a ClaimCollection corresponds to a RequestClaim object in the RequestClaimCollection, and contains the Claim value corresponding to the requested claim. How the ClaimsHandler is invoked to create the ClaimCollection will be covered later. The STS ships with a single ClaimsHandler implementation, the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/LdapClaimsHandler.java?view=markup"&gt;LDAPClaimsHandler&lt;/a&gt;, which can retrieve claims from an LDAP store. A simpler &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/CustomClaimsHandler.java?view=markup"&gt;example&lt;/a&gt; is available in the unit tests.&lt;/p&gt;&lt;b&gt;1.3) The ClaimsManager&lt;/b&gt;&lt;br/&gt;&lt;p&gt;Recall that in the &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii_10.html"&gt;previous&lt;/a&gt; post, the TokenIssueOperation has a single additional property that can be configured:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;ClaimsManager claimsManager - An object that is used to handle claims.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsManager.java?view=markup"&gt;ClaimsManager&lt;/a&gt; holds a list of &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsHandler.java?view=markup"&gt;ClaimsHandler&lt;/a&gt; objects. So to support claim handling in the STS, it is necessary to implement one or more ClaimsHandler objects for whatever Claim URIs you wish to support, and register them with a ClaimsManager instance, which will be configured on the TokenIssueOperation object. &lt;/p&gt;&lt;p&gt;As detailed in the previous article, the TokenIssueOperation gets the realm of the current request, and does some processing of the AppliesTo address, after the RequestParser has finished parsing the request. The RequestClaimCollection object that has been constructed by the RequestParser is then processed. For each RequestClaim in the collection, it checks to see whether the ClaimsManager has a ClaimsHandler implementation registered that can "handle" that Claim (by checking the URIs). If it does not, and if the requested claim is not optional, then an exception is thrown. &lt;/p&gt;&lt;p&gt;If a ClaimsHandler implementation is registered with the ClaimsManager that can handle the desired claim, then the claims are passed through to the TokenProvider implementation, which is expected to be able to invoke the relevant ClaimHandler object, and insert the processed Claim into the generated security token. How this is done is entirely up to the user. For example, for the use-case given above of a SAML 1.1 token containing a "role" claim, the user could implement a custom &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AttributeStatementProvider.java?view=markup"&gt;AttributeStatementProvider&lt;/a&gt; instance that evaluates the claim values (via a custom ClaimsHandler implementation registered with the ClaimsManager) and constructs a set of Attributes accordingly in an AttributeStatement. An &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/CustomAttributeProvider.java?view=markup"&gt;example&lt;/a&gt; of how to do this is given in the unit tests. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-3368787547802336872?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/3368787547802336872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-x.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3368787547802336872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3368787547802336872'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-x.html' title='Apache CXF STS documentation - part X'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-8869747415400995065</id><published>2011-11-10T06:35:00.001-08:00</published><updated>2011-11-14T09:01:25.540-08:00</updated><title type='text'>Apache CXF STS documentation - part IX</title><content type='html'>&lt;p&gt;The &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii.html"&gt;previous&lt;/a&gt; blog post detailed the AbstractOperation class that provides some core functionality for the STS operations, such as parsing the client request into a format that the TokenProviders/TokenValidators/TokenCancellers can consume. In this post we will examine an extension of AbstractOperation that is used to issue tokens.&lt;/p&gt;&lt;p&gt;&lt;b&gt;1) The TokenIssueOperation&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java?view=markup"&gt;TokenIssueOperation&lt;/a&gt; is used to issue tokens in the STS. It implements the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java?view=markup"&gt;IssueOperation&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueSingleOperation.java?view=markup"&gt;IssueSingleOperation&lt;/a&gt; interfaces in the STS provider framework. In addition to the properties that it inherits from AbstractOperation (detailed in the previous post), it has a single property that can be configured:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;ClaimsManager claimsManager - An object that is used to handle claims. This will be covered in a future post.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Recall that AbstractOperation uses the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java?view=markup"&gt;RequestParser&lt;/a&gt; to parse a client request into &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt; objects. TokenIssueOperation populates a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderParameters.java?view=markup"&gt;TokenProviderParameters&lt;/a&gt; object with values extracted from the TokenRequirements and KeyRequirements objects. A number of different processing steps then occur before a TokenProvider implementation is used to retrieve the desired token, comprising of realm parsing, claims handling, and AppliesTo parsing.Claims handling will be discussed in the next article.&lt;/p&gt;&lt;p&gt;&lt;b&gt;1.1) Realm Parsing&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We have &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iv.html"&gt;discussed&lt;/a&gt; how realms are used with TokenProviders to provide tokens, and &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-vi.html"&gt;also&lt;/a&gt; how they work with TokenValidators to validate a given token. However, we did not cover how realms are defined in the first place. Recall that the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; configuration object &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii.html"&gt;defined&lt;/a&gt; on AbstractOperation has a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/RealmParser.java?view=markup"&gt;RealmParser&lt;/a&gt; property. The RealmParser is an interface which defines a pluggable way of defining a realm for the current request. It has a single method:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;String parseRealm(WebServiceContext context) - Return the realm of the current request given a WebServiceContext object.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Therefore if you wish to issue tokens in multiple realms, it is necessary to create an implementation of the RequestParser which will return a realm String given a context object. For example, different realms could be returned based on the endpoint URL or a HTTP parameter. This realm will then get used to select a TokenProvider implementation to use to issue a token of the desired type. It will also be used for token validation in a similar way.&lt;/p&gt;&lt;p&gt;&lt;b&gt;1.2) AppliesTo parsing&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;An AppliesTo element contains an address that refers to the recipient of the issued token. If an AppliesTo element was sent as part of the request then the CXF STS requires that it must be explicitly handled. This is done by the list of &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/service/ServiceMBean.java?view=markup"&gt;ServiceMBean&lt;/a&gt; objects that can be configured on AbstractOperation. The ServiceMBean interface represents a service, and has the following methods (amongst others):&lt;/p&gt;&lt;ul&gt;&lt;li&gt;boolean isAddressInEndpoints(String address) - Return true if the supplied address corresponds to a known address for this service.&lt;/li&gt;&lt;li&gt;void setEndpoints(List&amp;lt;String&amp;gt; endpoints) - Set the list of endpoint addresses that correspond to this service.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The STS ships with a single implementation of this interface, the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/service/StaticService.java?view=markup"&gt;StaticService&lt;/a&gt;. For the normal use-case of handling an AppliesTo element, the user creates a StaticService object and calls setEndpoints with a set of Strings that correspond to a list of regular expressions that match the allowable set of token recipients (by address). The TokenIssueOperation will extract the URL address from the EndpointReference child of the received AppliesTo element, and then iterate through the list of ServiceMBean objects and ask each one whether the given address is known to that ServiceMBean object. If an AppliesTo address is received, and no ServiceMBean is configured that can deal with that URL, then an exception is thrown.&lt;/p&gt;&lt;p&gt;The ServiceMBean also defines a number of optional configuration options, such as the default KeyType and TokenType Strings to use for that Service, if the client does not supply them. It also allows the user to set a custom &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/service/EncryptionProperties.java?view=markup"&gt;EncryptionProperties&lt;/a&gt; object, which defines a set of acceptable encryption algorithms to use to encrypt issued tokens for that service.&lt;/p&gt;&lt;p&gt;&lt;b&gt;2) Token creation and response&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Once the TokenIssuerOperation has processed the client request, it iterates through the list of defined TokenProvider implementations to see if each "can handle" the desired token type in the configured realm (if any). If no TokenProvider is defined, or if no TokenProvider can handle the desired token type, then an exception is thrown. Otherwise, a token is created, and a response object is constructed containing the following items:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The context attribute (if any was specified).&lt;/li&gt;&lt;li&gt;The Token Type.&lt;/li&gt;&lt;li&gt;The requested token (possibly encrypted, depending on configuration).&lt;/li&gt;&lt;li&gt;A number of references to that token (can be disabled by configuration).&lt;/li&gt;&lt;li&gt;The received AppliesTo address (if any).&lt;/li&gt;&lt;li&gt;The RequestedProofToken (if a Computed Key Algorithm was used).&lt;/li&gt;&lt;li&gt; The Entropy generated by the STS (if any, can be encrypted).&lt;/li&gt;&lt;li&gt;The lifetime of the generated token.&lt;/li&gt;&lt;li&gt;The KeySize that was used (if any).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;b&gt;3) TokenIssueOperation Example &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Finally, it's time to look at an example of how to spring-load the STS so that it can issue tokens. This particular &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-ut.xml?view=markup"&gt;example&lt;/a&gt; uses a security &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/ws-trust-1.4-service.wsdl?view=markup"&gt;policy&lt;/a&gt; that requires a UsernameToken over the symmetric binding. As the STS is a web service, we first define an endpoint:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;jaxws:endpoint id="UTSTS"&lt;br /&gt;    implementor="#utSTSProviderBean"&lt;br /&gt;    address="http://.../SecurityTokenService/UT"&lt;br /&gt;    wsdlLocation=".../ws-trust-1.4-service.wsdl"&lt;br /&gt;    xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"&lt;br /&gt;    serviceName="ns1:SecurityTokenService"&lt;br /&gt;    endpointName="ns1:UT_Port"&amp;gt;&lt;br /&gt;    &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;        &amp;lt;entry key="ws-security.callback-handler" value="..."/&amp;gt;&lt;br /&gt;        &amp;lt;entry key="ws-security.signature.properties" value="stsKeystore.properties"/&amp;gt;&lt;br /&gt;    &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:endpoint&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The jaxws:properties are required to parse the incoming message. The CallbackHandler is used to validate the UsernameToken and provide the password required to access the private key defined in the signature properties parameter. The "implementor" of the jaxws:endpoint is the SecurityTokenServiceProvider class defined in the STS provider framework:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;bean id="utSTSProviderBean"&lt;br /&gt;    class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider"&amp;gt;&lt;br /&gt;    &amp;lt;property name="issueOperation" ref="utIssueDelegate"/&amp;gt;&lt;br /&gt;    ...&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This bean supports the Issue Operation via a TokenIssueOperation instance:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;bean id="utIssueDelegate"&lt;br /&gt;    class="org.apache.cxf.sts.operation.TokenIssueOperation"&amp;gt;&lt;br /&gt;    &amp;lt;property name="tokenProviders" ref="utSamlTokenProvider"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="services" ref="utService"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="stsProperties" ref="utSTSProperties"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This TokenIssueOperation instance has a single TokenProvider configured to issue SAML Tokens (with a default Subject and Attribute statement):&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;bean id="utSamlTokenProvider"&lt;br /&gt;    class="org.apache.cxf.sts.token.provider.SAMLTokenProvider"&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The TokenIssueOperation also refers to a single StaticService implementation, which in turn defines a single URL expression to use to compare any received AppliesTo addresses:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;bean id="utService"&lt;br /&gt;    class="org.apache.cxf.sts.service.StaticService"&amp;gt;&lt;br /&gt;    &amp;lt;property name="endpoints" ref="utEndpoints"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;util:list id="utEndpoints"&amp;gt;&lt;br /&gt;    &amp;lt;value&amp;gt;http://localhost:(\d)*/(doubleit|metrowsp)/services/doubleit(UT|.*symmetric.*|.*)&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/util:list&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Finally, the TokenIssueOperation is configured with a StaticSTSProperties object. This class contains properties that define what private key to use to sign issued SAML tokens, as well as the Issuer name to use in the generated token.&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;bean id="utSTSProperties"&lt;br /&gt;    class="org.apache.cxf.sts.StaticSTSProperties"&amp;gt;&lt;br /&gt;    &amp;lt;property name="signaturePropertiesFile" value="stsKeystore.properties"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="signatureUsername" value="mystskey"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="callbackHandlerClass" value="..."/&amp;gt;&lt;br /&gt;    &amp;lt;property name="issuer" value="DoubleItSTSIssuer"/&amp;gt;&lt;br /&gt;    ...&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-8869747415400995065?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/8869747415400995065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii_10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8869747415400995065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8869747415400995065'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii_10.html' title='Apache CXF STS documentation - part IX'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-4482675658177834263</id><published>2011-11-08T09:29:00.000-08:00</published><updated>2011-11-08T09:29:21.541-08:00</updated><title type='text'>Apache CXF STS documentation - part VIII</title><content type='html'>Previous blog posts on the Apache CXF STS have focused on how tokens are &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;provided&lt;/a&gt;, &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-v.html"&gt;validated&lt;/a&gt; and &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-vii.html"&gt;canceled&lt;/a&gt; in the STS. These operations are (at least in theory) relatively independent of WS-Trust. For example, they could be used as an API to provide/validate/etc tokens. In the next couple of posts we will look at the bigger picture of how this internal token handling functionality works in the context of a client invocation. In this post we will cover some common functionality that is used by all of the WS-Trust operations in the STS implementation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) AbstractOperation&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In the first post of this series of articles, the STS provider framework in Apache CXF was &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-i.html"&gt;introduced&lt;/a&gt;. A number of interfaces were defined for each of the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/"&gt;operations&lt;/a&gt; that can be invoked on the STS. Before looking at the implementations of these interfaces that ship with the STS, we will look a base class that all of the operations extend, namely the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java?view=markup"&gt;AbstractOperation&lt;/a&gt; class. This class defines a number of properties that are shared with any subclasses, and can be accessed via set/get methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; stsProperties - A configuration MBean that holds the configuration for the STS as a whole, such as information about the private key to use to sign issued tokens, etc. &lt;/li&gt;&lt;li&gt;boolean encryptIssuedToken - Whether to encrypt an issued token or not. The default is false.&lt;/li&gt;&lt;li&gt; List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/service/ServiceMBean.java?view=markup"&gt;ServiceMBean&lt;/a&gt;&amp;gt; services - A list of ServiceMBean objects, which correspond to "known" services. This will be covered later.&lt;/li&gt;&lt;li&gt;List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProvider.java?view=markup"&gt;TokenProvider&lt;/a&gt;&amp;gt; - A list of TokenProvider implementations to use to issue tokens.&lt;/li&gt;&lt;li&gt; boolean returnReferences - Whether to return SecurityTokenReference elements to the client or not, that point to the issued token. The default is true.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/STSTokenStore.java?view=markup"&gt;STSTokenStore&lt;/a&gt; tokenStore - A cache used to store/retrieve tokens.&lt;/li&gt;&lt;/ul&gt;Several of the properties refer to issuing tokens - this is because this functionality is shared between the issuing and validating operations. At least one TokenProvider implementation must be configured, if the STS is to support issuing a token. Some of these properties have been seen in previous posts, for example the STSTokenStore cache was covered in a &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;previous&lt;/a&gt; blog post. This cache could be shared across a number of different operations, or else kept separate. AbstractOperation also contains some common functionality to parse requests, encrypt tokens, create references to return to the client, etc.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.1) STSPropertiesMBean&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The AbstractOperation object must be configured with an &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; object. This is an interface that encapsulates some configuration common to a number of different operations of the STS:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void configureProperties() - load and process the properties&lt;/li&gt;&lt;li&gt;void setCallbackHandler(CallbackHandler callbackHandler) - Set a CallbackHandler object. This is used in the TokenProviders/TokenValidators to retrieve passwords for various purposes.&lt;/li&gt;&lt;li&gt;void setSignatureCrypto(&lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Crypto.java?view=markup"&gt;Crypto&lt;/a&gt; signatureCrypto) - Set a WSS4J Crypto object to use to sign tokens, or validate signed requests, etc.&lt;/li&gt;&lt;li&gt;void setSignatureUsername(String signatureUsername) - Set the default signature username to use (e.g. corresponding to a keystore alias)&lt;/li&gt;&lt;li&gt;void setEncryptionCrypto(&lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Crypto.java?view=markup"&gt;Crypto&lt;/a&gt; encryptionCrypto) - Set a WSS4J Crypto object to use to encrypt issued tokens.&lt;/li&gt;&lt;li&gt;void setEncryptionUsername(String encryptionUsername) - Set the default encryption username to use (e.g. corresponding to a keystore alias)&lt;/li&gt;&lt;li&gt;void setIssuer(String issuer) - Set the default issuer name of the STS&lt;/li&gt;&lt;li&gt;void setSignatureProperties(&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/SignatureProperties.java?view=markup"&gt;SignatureProperties&lt;/a&gt; signatureProperties) - Set the SignatureProperties object corresponding to the STS. &lt;/li&gt;&lt;li&gt;void setRealmParser(&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/RealmParser.java?view=markup"&gt;RealmParser&lt;/a&gt; realmParser) - Set the object used to define what realm a request is in. This will be covered later.&lt;/li&gt;&lt;li&gt;void setIdentityMapper(&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/IdentityMapper.java?view=markup"&gt;IdentityMapper&lt;/a&gt; identityMapper) - Set the object used to map identities across realms. This will be covered later.&lt;/li&gt;&lt;/ul&gt;The STS ships with a single implementation of the STSPropertiesMBean interface - &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/StaticSTSProperties.java?view=markup"&gt;StaticSTSProperties&lt;/a&gt;. This class has two additional methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setSignaturePropertiesFile(String signaturePropertiesFile)&lt;/li&gt;&lt;li&gt;void setEncryptionPropertiesFile(String encryptionPropertiesFile)&lt;/li&gt;&lt;/ul&gt;If no Crypto objects are supplied to StaticSTSProperties, then it will try to locate a properties file using these values, and create a WSS4J Crypto object internally from the properties that are parsed.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.2) SignatureProperties&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/SignatureProperties.java?view=markup"&gt;SignatureProperties&lt;/a&gt; object can be defined on the STSPropertiesMBean. Note that this is unrelated to the signaturePropertiesFile property of StaticSTSProperties. This class provides some configuration relating to the signing of an issued token, as well as symmetric key generation. It has the following properties:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;boolean useKeyValue - Whether to use a KeyValue or not to refer to a certificate in a signature. The default is false.&lt;/li&gt;&lt;li&gt;long keySize - The (default) key size to use when generating a symmetric key. The default is 256 bits.&lt;/li&gt;&lt;li&gt; long minimumKeySize - The minimum key size to use when generating a symmetric key. The requestor can specify a KeySize value to use. The default is 128 bits.&amp;nbsp;&lt;/li&gt;&lt;li&gt;long maximumKeySize - The maximum key size to use when generating a symmetric key. The requestor can specify a KeySize value to use. The default is 512 bits.&lt;/li&gt;&lt;/ul&gt;For example, when the client sends a "KeySize" element to the STS when requesting a SAML Token (and sending a SymmetricKey KeyType URI), the SAMLTokenProvider will check that the requested keysize falls in between the minimum and maximum key sizes defined above. If it does not, then the default key size is used.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Request Parsing&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The first thing any of the AbstractOperation implementations do on receiving a request is to call some functionality in AbstractOperation to parse the request. This parsing is done by the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java?view=markup"&gt;RequestParser&lt;/a&gt; object, which iterates through the objects of the JAXB RequestSecurityTokenType. The request is parsed into two components, &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt;, which are available on the RequestParser object and are subsequently passed to the desired TokenProvider/TokenValidator/etc objects.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.1) TokenRequirements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; class holds a set of properties that have been extracted and parsed by RequestParser. These properties loosely relate to the token itself, rather than anything to do with keys. The properties that can be set by RequestParser are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;String tokenType - The desired TokenType URI. This is required if a token is to be issued.&lt;/li&gt;&lt;li&gt;Element appliesTo - The AppliesTo element that was received in the request. This normally holds a URL that indicates who the recipient of the issued token will be. &lt;/li&gt;&lt;li&gt;String context - The context attribute of the request.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/ReceivedToken.java?view=markup"&gt;ReceivedToken&lt;/a&gt; validateTarget - This object holds the contents of a received "ValidateTarget" element, i.e. a token to validate.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/ReceivedToken.java?view=markup"&gt;ReceivedToken&lt;/a&gt; onBehalfOf - This object holds the contents of a received "OnBehalfOf" element.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/ReceivedToken.java?view=markup"&gt;ReceivedToken&lt;/a&gt; actAs - This object holds the contents of a received "ActAs" element.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/ReceivedToken.java?view=markup"&gt;ReceivedToken&lt;/a&gt; cancelTarget - This object holds the contents of a received "CancelTarget" element, i.e. a token to cancel.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/Lifetime.java?view=markup"&gt;Lifetime&lt;/a&gt; lifetime - The requested lifetime of the issued token. This just holds created and expires Strings, that are parsed from the request.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/RequestClaimCollection.java?view=markup"&gt;RequestClaimCollection&lt;/a&gt; claims - A collection of requested claims that are parsed from the request. This will be covered later.&lt;/li&gt;&lt;/ul&gt;The ReceivedToken class mentioned above parses a received token object, which can be a JAXBElement&amp;lt;?&amp;gt; or a DOM Element. If it is a JAXBElement then it must be either a UsernameToken, SecurityTokenReference, or BinarySecurityToken. If it is a reference to a security token in the security header of the request, then this token is retrieved and set as the ReceivedToken instead.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.2) KeyRequirements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt; class holds a set of properties that have been extracted and parsed by RequestParser. These properties are anything to do with key handling or creation. The properties that can be set by RequestParser are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;String authenticationType - An optional authentication type URI. This is currently not used in the STS.&lt;/li&gt;&lt;li&gt;String keyType - The desired KeyType URI.&lt;/li&gt;&lt;li&gt;long keySize - The requested KeySize to use when generating symmetric keys.&lt;/li&gt;&lt;li&gt;String signatureAlgorithm - The requested signature algorithm to use when signing an issued token. This is currently not used in the STS.&lt;/li&gt;&lt;li&gt;String encryptionAlgorithm - The requested encryption algorithm to use when encrypting an issued token. &lt;/li&gt;&lt;li&gt;String c14nAlgorithm - The requested canonicalization algorithm to use when signing an issued token. This is currently not used in the STS.&lt;/li&gt;&lt;li&gt;String computedKeyAlgorithm - The computed key algorithm to use when creating a symmetric key.&lt;/li&gt;&lt;li&gt;String keywrapAlgorithm - The requested KeyWrap algorithm to use when encrypting a symmetric key.&lt;/li&gt;&lt;li&gt;X509Certificate certificate - A certificate that has been extracted from a "UseKey" element, for use in the SAML case when a PublicKey KeyType URI is specified.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/Entropy.java?view=markup"&gt;Entropy&lt;/a&gt; entropy - This object holds entropy information extracted from the client request for use in generating a symmetric key. Only BinarySecret elements are currently supported.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;2.3) SecondaryParameters&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;RequestParser also supports parsing a "SecondaryParameters" element that might be in the request. This could be extracted from the WSDL of a service provider that specifies an IssuedToken policy by the client and sent to the STS as part of the RequestSecurityToken request. Only KeySize, TokenType, KeyType and Claims child elements are currently parsed.&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-4482675658177834263?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/4482675658177834263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4482675658177834263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4482675658177834263'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-viii.html' title='Apache CXF STS documentation - part VIII'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-601824519366867224</id><published>2011-11-07T09:00:00.000-08:00</published><updated>2011-11-07T09:00:56.413-08:00</updated><title type='text'>Apache CXF STS documentation - part VII</title><content type='html'>Previous blog entries have covered &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;TokenProviders&lt;/a&gt; and &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-v.html"&gt;TokenValidators&lt;/a&gt;, used by the STS to provide and validate tokens respectively. The STS does not currently have any support for renewing tokens - although this may change in the future. The other STS operation on tokens that is of interest is the ability to cancel tokens that were issued by the STS. In this post I will detail an interface used to cancel tokens, as well as an implementation that ships with the STS.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) The TokenCanceller interface&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SecurityTokens are cancelled in the STS via the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/canceller/TokenCanceller.java?view=markup"&gt;TokenCanceller&lt;/a&gt; interface. This interface is very similar to the TokenProvider and TokenValidator interfaces. It contains three methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; void setVerifyProofOfPossession(boolean verifyProofOfPossession) - Whether to enable or disable proof-of-possession verification.&lt;/li&gt;&lt;li&gt;boolean canHandleToken(ReceivedToken cancelTarget) - Whether this TokenCanceller implementation can cancel the given token&lt;/li&gt;&lt;li&gt;TokenCancellerResponse cancelToken(TokenCancellerParameters tokenParameters) - Cancel a token using the given parameters&lt;/li&gt;&lt;/ul&gt;A client can cancel a security token via the STS by invoking the "cancel" operation. Assuming that the client request is authenticated and well-formed, the STS will iterate through a list of TokenCanceller implementations to see if they can "handle" the received token. If they can, then the implementation is used to cancel the received security token, and the cancellation result is returned to the client. The STS currently ships with a single TokenCanceller implementation, which can cancel SecurityContextTokens that were issued by the STS. Before we look at this implementation, let's look at the "cancelToken" operation in more detail. This method takes a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/canceller/TokenCancellerParameters.java?view=markup"&gt;TokenCancellerParameters&lt;/a&gt; instance, and returns a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/canceller/TokenCancellerResponse.java?view=markup"&gt;TokenCancellerResponse&lt;/a&gt; object.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) TokenCancellerParameters and &lt;/b&gt;&lt;b&gt;TokenCanceller&lt;/b&gt;&lt;b&gt;Response&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The TokenCancellerParameters class is nothing more than a collection of configuration properties to use in cancelling the token, which are populated by the STS operations using information collated from the request, or static configuration, etc. The properties of the TokenCancellerParameters are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; stsProperties - A configuration MBean that holds the configuration for the STS as a whole.&lt;/li&gt;&lt;li&gt;Principal principal - The current client Principal object &lt;/li&gt;&lt;li&gt;WebServiceContext webServiceContext - The current web service context object. This allows access to the client request.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt; keyRequirements - A set of configuration properties relating to keys. This will be covered later.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; tokenRequirements - A set of configuration properties relating to the token. This will be covered later.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/STSTokenStore.java?view=markup"&gt;STSTokenStore&lt;/a&gt; tokenStore - A cache used to retrieve tokens.&lt;/li&gt;&lt;/ul&gt;The "cancelToken" method returns an object of type &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/canceller/TokenCancellerResponse.java?view=markup"&gt;TokenCancellerResponse&lt;/a&gt;. Similar to the TokenCancellerParameters object, this just holds a collection of objects that is parsed by the STS operation to construct a response to the client. It currently only has a single property:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;boolean tokenCancelled - Whether the token was cancelled or not.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;3) The SCTCanceller&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The STS ships with a single implementation of the TokenCanceller interface, namely the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/canceller/SCTCanceller.java?view=markup"&gt;SCTCanceller&lt;/a&gt;. The SCTCanceller is used to cancel a token  known as a SecurityContextToken, that is defined in the &lt;a href="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/ws-secureconversation-1.3-os.html#_Toc162064047"&gt;WS-SecureConversation&lt;/a&gt; specification. The &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;SCTProvider&lt;/a&gt; and the &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-v.html"&gt;SCTValidator&lt;/a&gt; were covered previously.  A SecurityContextToken essentially consists of a String Identifier which is associated with a particular secret key. The SCTCanceller can cancel a SecurityContextToken in either of the following namespaces:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;http://schemas.xmlsoap.org/ws/2005/02/sc/sct&lt;/li&gt;&lt;li&gt;http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512&lt;/li&gt;&lt;/ul&gt;Recall that the SCTValidator validates a received SecurityContextToken by checking to see whether it is stored in the cache. Therefore it is a requirement to configure a cache for the STS if you want to validate SecurityContextTokens. The same applies for the SCTCanceller. A received SecurityContextToken is successfully cancelled only if it is stored in the cache and is removed from the cache without any errors. This generally implies that the STS must have previously issued the SecurityContextToken and stored it in the cache, unless the STS is sharing a distributed cache with other STS instances.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.1) Enforcing proof-of-possession&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Recall that the TokenCanceller interface has a method "setVerifyProofOfPossession" which defines whether proof-of-possession is required or not to cancel a security token. The default value for the SCTCanceller is "true". This means that for the client to successfully cancel a SecurityContextToken it must prove to the STS that it knows the secret key associated with that SecurityContextToken. The client must do this by signing some portion of the request with the same secret key that the SCTCanceller retrieves from the security token stored in the cache.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-601824519366867224?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/601824519366867224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-vii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/601824519366867224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/601824519366867224'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-vii.html' title='Apache CXF STS documentation - part VII'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-8968453359448794673</id><published>2011-11-04T09:45:00.000-07:00</published><updated>2011-11-04T09:46:00.716-07:00</updated><title type='text'>Apache CXF STS documentation - part VI</title><content type='html'>In the previous &lt;a href="http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-v.html"&gt;post&lt;/a&gt;, I covered the TokenValidator interface that is used by the CXF STS to validate tokens, and two implementations that ship with the STS to validate SecurityContextTokens and BinarySecurityTokens (X509 Certificates). In this post I will cover the other two TokenValidator implementations that ship with the STS, which can validate UsernameTokens and SAML Tokens  (both 1.1 and 2.0).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) The UsernameTokenValidator&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/UsernameTokenValidator.java?view=markup"&gt;UsernameTokenValidator&lt;/a&gt; is used to validate WS-Security UsernameTokens. Two properties can be set directly on the UsernameTokenValidator:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setValidator(Validator validator) - Set the WSS4J &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java?view=markup"&gt;Validator&lt;/a&gt; instance to use to validate the received UsernameToken. The default is the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/UsernameTokenValidator.java?view=markup"&gt;UsernameTokenValidator&lt;/a&gt; (note that this is in WSS4J and not the same as the UsernameTokenValidator in the STS!).&lt;/li&gt;&lt;li&gt;void setUsernameTokenRealmCodec(UsernameTokenRealmCodec usernameTokenRealmCodec) - Set the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/UsernameTokenRealmCodec.java?view=markup"&gt;UsernameTokenRealmCodec&lt;/a&gt; instance to use to return a realm from a validated token. This will be explained later.&lt;/li&gt;&lt;/ul&gt;The UsernameToken is first checked to make sure that it is well-formed. If it has no password element then it is rejected. If a cache is configured, then it sees if the UsernameToken has been previously stored in the cache (searching by wsu:Id). If it is, and if the retrieved SecurityToken has an "associated hash" corresponding to the hashcode of the received UsernameToken, then the received UsernameToken has already been validated, and no further validation is required. It is necessary to check the "associated hash" value, in case two different UsernameTokens are being compared that have the same wsu:Id. Note that the CXF STS does not have a UsernameTokenProvider as of yet, so for this use-case perhaps the cache is shared with a custom TokenProvider.&lt;br /&gt;&lt;br /&gt;If the token is not stored in the cache, then the WSS4J Validator instance is used to validate the received UsernameToken. As stated above, the default implementation that is used is the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/UsernameTokenValidator.java?view=markup"&gt;UsernameTokenValidator&lt;/a&gt; in WSS4J. This implementation uses a CallbackHandler to supply a password to validate the UsernameToken. This CallbackHandler implementation is supplied by the STSPropertiesMBean object. WSS4J also ships with an &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/JAASUsernameTokenValidator.java?view=markup"&gt;implementation&lt;/a&gt; that validates a UsernameToken via a JAAS LoginModule, which can be plugged in to the STS UsernameTokenValidator. If validation is successful, then a principal is created from the received UsernameToken and set on the response. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Realms in the TokenValidators&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Recall that the TokenValidator interface has a method that takes a realm parameter:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;boolean canHandleToken(ReceivedToken validateTarget, String realm) - Whether this TokenValidator implementation can validate the given token in the given realm&lt;/li&gt;&lt;/ul&gt;How the STS knows what the desired realm is will be covered in a future post.&amp;nbsp;&amp;nbsp; &lt;br /&gt;Realms are handled in a slightly different way in TokenValidators compared to TokenProviders. Recall that for &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iv.html"&gt;TokenProviders&lt;/a&gt;, the implementation is essentially asked whether it can provide a token in a given realm. For the SCTProvider, the realm is ignored in this method. However, when creating a token, the SCTProvider will store the given realm as a property associated with that token in the cache. The SAMLTokenProvider checks to see if the given realm is null, and if it is not null then the realmMap *must* contain a key which matches the given realm.&lt;br /&gt;&lt;br /&gt;There is a subtle distinction between the realm passed to "canHandleToken" for TokenValidators and the realm returned after a token is validated as part of the TokenValidatorResponse object. The realm passed to "canHandleToken" is the realm to validate the token in. So for example, you could have two TokenValidator instances registered to validate the same token, but in different realms. All of the TokenValidator implementations that ship with the STS ignore the realm as part of this method. However, the method signature gives the user the option to validate tokens in different realms in a more flexible manner.&lt;br /&gt;&lt;br /&gt;The realm that is returned as part of the TokenValidatorResponse is the realm that the validated token is in (if any). This can be different to the realm the token was validated in. The X509TokenValidator ignores this parameter altogether. The SCTValidator checks to see whether the SecurityToken that was stored in the cache has a realm property, and if so sets this on the TokenValidatorResonse. The UsernameTokenValidator and SAMLTokenValidator handle realms in a more sophisticated manner. I will cover the UsernameTokenValidator here, and the SAMLTokenValidator later. Recall that the UsernameTokenValidator has the following method:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setUsernameTokenRealmCodec(UsernameTokenRealmCodec usernameTokenRealmCodec) - Set the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/UsernameTokenRealmCodec.java?view=markup"&gt;UsernameTokenRealmCodec&lt;/a&gt; instance to use to return a realm from a validated token.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;The UsernameTokenRealmCodec has a single method:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;String getRealmFromToken(UsernameToken usernameToken) - Get the realm associated with the UsernameToken parameter.&lt;/li&gt;&lt;/ul&gt;No UsernameTokenRealmCodec implementation is set by default on the UsernameTokenValidator, hence no realm is returned in TokenValidatorResponse. If an implemention is specified, then the UsernameTokenValidator will retrieve a realm from the UsernameTokenRealmCodec implementation corresponding to the validated UsernameToken. If a cache is configured, and the UsernameToken was already stored in the cache, then the realm is compared to the realm of the cached token, stored under the tag "org.apache.cxf.sts.token.realm".&lt;b&gt; &lt;/b&gt;If they do not match then validation fails.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) The SAMLTokenValidator&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SAMLTokenValidator.java?view=markup"&gt;SAMLTokenValidator&lt;/a&gt; is used to validate SAML (1.1 and 2.0) tokens. The following properties can be set directly on the SAMLTokenValidator:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setValidator(Validator validator) - Set the WSS4J &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java?view=markup"&gt;Validator&lt;/a&gt; instance to use to validate the received certificate. The default is &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java?view=markup"&gt;SignatureTrustValidator&lt;/a&gt;.&lt;/li&gt;&lt;li&gt; void setSamlRealmCodec(&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/SAMLRealmCodec.java?view=markup"&gt;SAMLRealmCodec&lt;/a&gt; samlRealmCodec) - Set the SAMLRealmCodec instance to use to return a realm from a validated token. &lt;/li&gt;&lt;li&gt;void setSubjectConstraints(List&amp;lt;String&amp;gt; subjectConstraints) - Set a list of Strings corresponding to regular expression constraints on the subject DN of a certificate that was used to sign an Assertion.&lt;/li&gt;&lt;/ul&gt;These methods are covered in more detail below. The Assertion is first checked to make sure that it is well-formed. If a cache is defined, then the signature value of the received assertion (if it is signed) is hashed and compared against the tokens in the cache (via getTokenByAssociatedHash()). If a match is found in the cache, then the Assertion is taken to be valid. If a match is not found, then the Assertion is validated. &lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;b&gt;3.1) Validating a received SAML Assertion&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If the token is not stored in the cache then it must be validated. Firstly a check is performed to make sure that the Assertion is signed, if it is not then it is rejected. The signature of the Assertion is then validated using the Crypto object retrieved from the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; passed in the TokenValidatorParameters. Finally, trust is verified in the certificate/public-key used to sign the Assertion. This is done using the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java?view=markup"&gt;Validator&lt;/a&gt; object that can be configured via "setValidator". The default Validator is the WSS4J &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java?view=markup"&gt;SignatureTrustValidator,&lt;/a&gt; which checks that the received certificate is known (or trusted) by the STS Crypto object.&lt;br /&gt;&lt;br /&gt;Recall that a List of Strings can be set on the SAMLTokenValidator via the "setSubjectConstraints" method. These Strings correspond to regular expression constraints on the subject DN of a certificate that was used to sign an Assertion. This provides additional flexibility to validate a received SAML Assertion. For example, the Assertion could be signed by an entity that has a certificate issued by a particular CA, which in turn is trusted by the STS Crypto object. However, one might want to restrict the list of "valid" entities who can sign a SAML Assertion. This can be done by adding a list of regular expressions that match the Subject DN of all acceptable certificates that might be used to sign a valid SAML Assertion. This matching is done by the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/CertConstraintsParser.java?view=markup"&gt;CertConstraintsParser&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.2) Realm handling in the SAMLTokenValidator&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Recall that the SAMLTokenValidator has the following method:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setSamlRealmCodec(&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/SAMLRealmCodec.java?view=markup"&gt;SAMLRealmCodec&lt;/a&gt; samlRealmCodec) - Set the SAMLRealmCodec instance to use to return a realm from a validated token. &lt;/li&gt;&lt;/ul&gt;The SAMLRealmCodec has a single method:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;String getRealmFromToken(AssertionWrapper assertion) - Get the realm associated with the (SAML Assertion) parameter.&lt;/li&gt;&lt;/ul&gt;No SAMLRealmCodec implementation is set by default on the SAMLTokenValidator, hence no realm is returned in TokenValidatorResponse. If an implemention is specified, then the SAMLTokenValidator will retrieve a realm from theSAMLRealmCodec&amp;nbsp; implementation corresponding to the validated Assertion. If a cache is configured, and the Assertion was already stored in the cache, then the realm is compared to the realm of the cached token, stored under the tag "org.apache.cxf.sts.token.realm". If they do not match then validation fails.&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-8968453359448794673?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/8968453359448794673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-vi.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8968453359448794673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8968453359448794673'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-vi.html' title='Apache CXF STS documentation - part VI'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7017580921783714177</id><published>2011-11-02T09:38:00.000-07:00</published><updated>2011-11-02T09:45:57.891-07:00</updated><title type='text'>Apache CXF STS documentation - part V</title><content type='html'>In the previous couple of posts (&lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;here&lt;/a&gt; and &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iv.html"&gt;here&lt;/a&gt;) I detailed the TokenProvider interface, which is used to generate tokens in the STS, as well as two implementations that ship with the STS to generate SecurityContextTokens and SAML Tokens. In this post I will describe the interface that is used for validating tokens, as well as two implementations that ship with the STS, which are used to validate SecurityContextTokens, and (X.509) BinarySecurityTokens. In the next post, I will detail implementations which can validate a UsernameToken and a SAML Token.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) The TokenValidator interface&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SecurityTokens are validated in the STS via the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidator.java?view=markup"&gt;TokenValidator&lt;/a&gt; interface. It is very similar to the TokenProvider interface (hence some duplication of documentation from previous blog entries on the TokenProvider). It has three methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;boolean canHandleToken(ReceivedToken validateTarget) - Whether this TokenValidator implementation can validate the given token&lt;/li&gt;&lt;li&gt;boolean canHandleToken(ReceivedToken validateTarget, String realm) - Whether this TokenValidator implementation can validate the given token in the given realm&lt;/li&gt;&lt;li&gt;TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) - Validate a token using the given parameters.&lt;/li&gt;&lt;/ul&gt;A client can validate a security token via the STS by invoking the "validate" operation. Assuming that the client request is authenticated and well-formed, the STS will iterate through a list of TokenValidator implementations to see if they can "handle" the received token. If they can, then the implementation is used to validate the received security token, and the validation result is returned to the client. The second "canHandleToken" method which also takes a "realm" parameter will be covered in a future post.&lt;br /&gt;&lt;br /&gt;So to support the validation of a particular token type in an STS deployment, it is necessary to specify a TokenValidator implementation that can handle that token. The STS currently ships with four TokenValidator&amp;nbsp; implementations, to validate SecurityContextTokens, SAML Assertions, UsernameTokens, and BinarySecurityTokens. Before we look at these implementations, let's take a look at the "validateToken" operation in more detail. This method takes a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorParameters.java?view=markup"&gt;TokenValidatorParameters&lt;/a&gt; instance.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) TokenValidatorParameters&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The TokenValidatorParameters class is nothing more than a collection of configuration properties to use in validating the token, which are populated by the STS operations using information collated from the request, or static configuration, etc. The properties of the TokenValidatorParameters are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; stsProperties - A configuration MBean that holds the configuration for the STS as a whole.&lt;/li&gt;&lt;li&gt;Principal principal - The current client Principal object &lt;/li&gt;&lt;li&gt;WebServiceContext webServiceContext - The current web service context object. This allows access to the client request.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt; keyRequirements - A set of configuration properties relating to keys. This will be covered later.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; tokenRequirements - A set of configuration properties relating to the token. This will be covered later.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/STSTokenStore.java?view=markup"&gt;STSTokenStore&lt;/a&gt; tokenStore - A cache used to retrieve tokens.&lt;/li&gt;&lt;li&gt;String realm - The realm to validate the token in (this should be the same as the realm passed to "canHandleToken"). This will be covered later.&lt;/li&gt;&lt;/ul&gt;If this looks complicated then remember that the STS will take care of populating all of these properties from the request and some additional configuration. You only need to worry about the TokenValidatorParameters object if you are creating your own TokenValidator implementation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) TokenValidatorResponse&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The "validateToken" method returns an object of type &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorResponse.java?view=markup"&gt;TokenValidatorResponse&lt;/a&gt;. Similar to the TokenValidatorParameters object, this just holds a collection of objects that is parsed by the STS operation to construct a response to the client. The properties are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;boolean valid - Whether the token is valid or not.&lt;/li&gt;&lt;li&gt;Principal principal - A principal corresponding to the validated token.&lt;/li&gt;&lt;li&gt;Map&amp;lt;String, Object&amp;gt; additionalProperties - Any additional properties associated with the validated token.&lt;/li&gt;&lt;li&gt;String realm - The realm of the validated token.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;4) The SCTValidator&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Now that we've covered the TokenValidator interface, let's look at an implementation that is shipped with the STS. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SCTValidator.java?view=markup"&gt;SCTValidator&lt;/a&gt; is used to validate a token  known as a SecurityContextToken, that is defined in the &lt;a href="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/ws-secureconversation-1.3-os.html#_Toc162064047"&gt;WS-SecureConversation&lt;/a&gt; specification. The SCTProvider was covered in a &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;previous&lt;/a&gt; post. A SecurityContextToken essentially consists of a String Identifier which is associated with a particular secret key. If a service provider receives a SOAP message with a digital signature which refers to a SecurityContextToken in the KeyInfo of the signature, then the service provider knows that it must somehow obtain a secret key associated with that particular Identifier to verify the signature.&lt;br /&gt;&lt;br /&gt;One way to do this would be if the service provider shares a (secured) distributed cache with an STS instance. An alternative solution would be for the service provider to send the SCT to an STS for validation, and to receive a SAML token in response with the embedded (encrypted) secret key. The SCTValidator can accommodate this latter scenario, albeit indirectly as will be explained shortly.&lt;br /&gt;&lt;br /&gt;The SCTValidator can validate a SecurityContextToken in either of the following namespaces:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;http://schemas.xmlsoap.org/ws/2005/02/sc/sct&lt;/li&gt;&lt;li&gt;http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512&lt;/li&gt;&lt;/ul&gt;The SCTValidator validates a received SecurityContextToken by checking to see whether it is stored in the cache. Therefore it is a requirement to configure a cache for the STS if you want to validate SecurityContextTokens. If the SecurityContextToken is stored in the cache (for example, by the SCTProvider), then the received SecurityToken is taken to be valid. The secret associated with the SecurityContextToken is also retrieved from the cache, and set as an "additional property" in the TokenValidatorResponse using the key "sct-validator-secret". If the cached token has a stored principal, then this is also returned in the TokenValidatorResponse.&lt;br /&gt;&lt;br /&gt;If you want to support the scenario of returning the secret key associated with the SecurityContextToken to the client (of the STS), then it is possible to do so via token transformation. This is where the client sends an additional Token Type (in this case for a SAML Token). After the token is validated, the SAMLTokenProvider is called with the additional properties map obtained from the SCTValidator. The SAMLTokenProvider then has access to the secret key via the "sct-validator-secret" tag, which it can insert into the Assertion using a custom AttributeProvider. Token Transformation will be covered in more detail in a future post.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5) The X509TokenValidator&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Another TokenValidator implementation that ships with the STS is the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/X509TokenValidator.java?view=markup"&gt;X509TokenValidator&lt;/a&gt;.  This class validates an X.509 V.3 certificate (received as a BinarySecurityToken). The BinarySecurityToken must use Base-64 encoding. &lt;br /&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr class="vc_row_odd" id="l50"&gt;&lt;td class="vc_file_line_text"&gt;The received cert must be known (or trusted) by the STS crypto object, that is set on the STSPropertiesMBean object. The X509TokenValidator has a single property that can be configured:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setValidator(Validator validator) - Set the WSS4J &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java?view=markup"&gt;Validator&lt;/a&gt; instance to use to validate the received certificate. The default is &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java?view=markup"&gt;SignatureTrustValidator&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;No proof-of-possession is done with the received certificate. The subject principal of the certificate is set on the response, if validation is successful. Note that no caching is used in this TokenValidator implementation.&lt;/td&gt;&lt;/tr&gt;&lt;tr class="vc_row_odd" id="l51"&gt;&lt;td class="vc_file_line_number"&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class="vc_file_line_text"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7017580921783714177?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7017580921783714177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-v.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7017580921783714177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7017580921783714177'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/apache-cxf-sts-documentation-part-v.html' title='Apache CXF STS documentation - part V'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7036744750837626856</id><published>2011-11-02T09:15:00.000-07:00</published><updated>2011-11-02T09:15:14.465-07:00</updated><title type='text'>New Apache Santuario and CXF releases</title><content type='html'>Apache Santuario 1.4.6 has been released - it is available for download &lt;a href="http://santuario.apache.org/download.html"&gt;here&lt;/a&gt;.  This release fixes a thread safety issue with XML Signature, a bug fix for the Canonical XML 1.1 algorithm, as well as a number of other bug fixes. See the &lt;a href="http://santuario.apache.org/java146releasenotes.html"&gt;release notes&lt;/a&gt; for more information. &lt;br /&gt;&lt;br /&gt;Also, Apache CXF 2.5.0 has been &lt;a href="http://mail-archives.apache.org/mod_mbox/cxf-dev/201111.mbox/%3C1462045.AR89JkKHR9@dilbert.dankulp.com%3E"&gt;released&lt;/a&gt;. This release features a brand new STS implementation - something I have been blogging extensively about. See Dan Kulp's blog for more &lt;a href="http://www.dankulp.com/blog/?p=342"&gt;thoughts&lt;/a&gt; on this release.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7036744750837626856?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7036744750837626856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/11/new-santuario-and-cxf-releases.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7036744750837626856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7036744750837626856'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/11/new-santuario-and-cxf-releases.html' title='New Apache Santuario and CXF releases'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-1050044971788381095</id><published>2011-10-27T04:45:00.000-07:00</published><updated>2011-10-27T04:45:50.309-07:00</updated><title type='text'>Apache CXF STS documentation - part IV</title><content type='html'>In the previous &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;post&lt;/a&gt; I covered the TokenProvider interface, which is used to generate tokens in the STS, and an implementation that ships with the STS to generate SecurityContextTokens. In this post, I will cover the other TokenProvider implementation that ships with the STS, which issues SAML Tokens (both 1.1 and 2.0). &lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) The SAMLTokenProvider&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SAMLTokenProvider.java?view=markup"&gt;SAMLTokenProvider&lt;/a&gt; can issue SAML 1.1 and SAML 2.0 tokens. To request a SAML 1.1 token, the client must use one of the following Token Types:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1&lt;/li&gt;&lt;li&gt;urn:oasis:names:tc:SAML:1.0:assertion&lt;/li&gt;&lt;/ul&gt;To request a SAML 2.0 token, the client must use one of the following Token Types:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0 &lt;/li&gt;&lt;li&gt;urn:oasis:names:tc:SAML:2.0:assertion&lt;/li&gt;&lt;/ul&gt;The following properties can be configured on the SAMLTokenProvider directly:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AttributeStatementProvider.java?view=markup"&gt;AttributeStatementProvider&lt;/a&gt;&amp;gt; attributeStatementProviders - A list of objects that can add attribute statements to the token.&lt;/li&gt;&lt;li&gt;List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AuthenticationStatementProvider.java?view=markup"&gt;AuthenticationStatementProvider&lt;/a&gt;&amp;gt; authenticationStatementProviders - A list of objects that can add authentication statements to the token.&lt;/li&gt;&lt;li&gt;List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AuthDecisionStatementProvider.java?view=markup"&gt;AuthDecisionStatementProvider&lt;/a&gt;&amp;gt; authDecisionStatementProviders - A list of objects that can add authorization decision statements to the token.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SubjectProvider.java?view=markup"&gt;SubjectProvider&lt;/a&gt; subjectProvider - An object used to add a Subject to the token.&lt;/li&gt;&lt;li&gt; &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/ConditionsProvider.java?view=markup"&gt;ConditionsProvider&lt;/a&gt; conditionsProvider - An object used to add a Conditions statement to the token.&lt;/li&gt;&lt;li&gt;boolean signToken - Whether to sign the token or not. The default is true.&lt;/li&gt;&lt;li&gt; Map&amp;lt;String, &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/SAMLRealm.java?view=markup"&gt;SAMLRealm&lt;/a&gt;&amp;gt; realmMap - A map of realms to SAMLRealm objects.&lt;/li&gt;&lt;/ul&gt;We will explain each of these properties in more detail in the next few sections.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Realms in the TokenProviders&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;As explained in the previous &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html"&gt;post,&lt;/a&gt; the TokenProvider interface has a method that takes a realm parameter:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;boolean canHandleToken(String tokenType, String realm) - Whether this TokenProvider implementation can provide a token of the given type, in the given realm&lt;/li&gt;&lt;/ul&gt;In other words, the TokenProvider implementation is being asked whether it can supply a token corresponding to the Token Type in a particular realm. How the STS knows what the desired realm is will be covered in a future post. However, we will explain how the realm is handled by the TokenProviders here. The SCTProvider ignores the realm in the canHandleToken method. In other words, the SCTProvider can issue a SecurityContextToken in *any* realm. If a realm is passed through via the TokenProviderParameters when creating the token, the SCTProvider will cache the token with the associated realm as a property (this was explained in the previous post).&lt;br /&gt;&lt;br /&gt;Unlike the SCTProvider, the SAMLTokenProvider does not ignore the realm parameter to the "canHandleToken" method. Recall that the SAMLTokenProvider has a property "Map&amp;lt;String, SAMLRealm&amp;gt; realmMap". The canHandleToken method checks to see if the given realm is null, and if it is not null then the realmMap *must* contain a key which matches the given realm. So if the STS implementation is designed to issue tokens in different realms, then the realmMap of the SAMLTokenProvider must contain the corresponding realms in the key-set of the map. &lt;br /&gt;&lt;br /&gt;The realmMap property maps realm Strings to &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/realm/SAMLRealm.java?view=markup"&gt;SAMLRealm&lt;/a&gt; objects. The SAMLRealm class contains the following properties:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;String issuer - the Issuer String to use in this realm&lt;/li&gt;&lt;li&gt;String signatureAlias - the keystore alias to use to retrieve the private key the SAMLTokenProvider uses to sign the generated token&lt;/li&gt;&lt;/ul&gt;In other words, if the SAMLTokenProvider is "realm aware", then it can issue tokens with an issuer name and signing key specific to a given realm. If no realm is passed to the SAMLTokenProvider, then these properties are obtained from the "system wide" properties defined in the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; object passed as part of the TokenProviderParameters, which can be set via the following methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setSignatureUsername(String signatureUsername)&lt;/li&gt;&lt;li&gt; void setIssuer(String issuer) &lt;/li&gt;&lt;/ul&gt;Two additional properties are required when signing SAML Tokens. A password is required to access the private key in the keystore, which is supplied by a CallbackHandler instance. A WSS4J "Crypto" instance is also required which controls access to the keystore. These are both set on the STSPropertiesMBean object via:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;void setCallbackHandler(CallbackHandler callbackHandler)&lt;/li&gt;&lt;li&gt;void setSignatureCrypto(Crypto signatureCrypto)&lt;/li&gt;&lt;/ul&gt;Note that the signature of generated SAML Tokens can be disabled, by setting the "signToken" property of the SAMLTokenProvider to "false". As per the SCTProvider, the generated SAML tokens are stored in the cache with the associated realm stored as a property. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) Populating SAML Tokens&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In the previous section we covered how a generated SAML token is signed, how to configure the key used to sign the assertion, and how to set the Issuer of the Assertion. In this section we will describe how to populate the SAML Token itself. The SAMLTokenProvider is designed to be able to issue a wide range of SAML Tokens. It does this by re-using the SAML abstraction &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/bean/"&gt;library&lt;/a&gt; that ships with Apache WSS4J, which defines a collection of beans that are configured and then assembled in a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SamlCallbackHandler.java?view=markup"&gt;CallbackHandler&lt;/a&gt; to create a SAML assertion. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.1) Configure a Conditions statement&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The SAMLTokenProvider has a "&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/ConditionsProvider.java?view=markup"&gt;ConditionsProvider&lt;/a&gt; conditionsProvider" property, which can be used to configure the generated Conditions statement which is added to the SAML Assertion. The ConditionsProvider has a method to return a &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/bean/ConditionsBean.java?view=markup"&gt;ConditionsBean&lt;/a&gt; object, and a method to return a lifetime in seconds. The ConditionsBean holds properties such as the not-before and not-after dates, etc. The SAMLTokenProvider ships with a default ConditionsProvider implementation that is used to insert a Conditions statement in every SAML token that is generated. This &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/DefaultConditionsProvider.java?view=markup"&gt;implementation &lt;/a&gt;uses a default lifetime of 5 minutes, and set the Audience Restriction URI of the Conditions Statement to be the received "AppliesTo" address, which is obtained from the TokenProviderParameters object.&lt;br /&gt;&lt;br /&gt;The DefaultConditionsProvider can be configured to change the lifetime of the issued token. If you want to remove the ConditionsProvider altogether from the generation assertion, or implement a custom Conditions statement, then you must implement an instance of the ConditionsProvider interface, and set it on the SAMLTokenProvider.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.2) Configure a Subject&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The SAMLTokenProvider has a "&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SubjectProvider.java?view=markup"&gt;SubjectProvider&lt;/a&gt; subjectProvider" property, which can be used to configure the Subject of the generated token, regardless of the version of the token. The SubjectProvider interface defines a single method to return a &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/bean/SubjectBean.java?view=markup"&gt;SubjectBean&lt;/a&gt;, given the token provider parameters, the parent Document of the assertion, and a secret key to use (if any). The SubjectBean contains the Subject name, name-qualifier, confirmation method, and KeyInfo element, amongst other properties. The SAMLTokenProvider ships with a default SubjectProvider implementation that is used to insert a Subject into every SAML Token that is generated. &lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/DefaultSubjectProvider.java?view=markup"&gt;DefaultSubjectProvider&lt;/a&gt; has a single configuration method to set the subject name qualifier. It creates a subject confirmation method by checking the received key type. The subject name is the name of the principal obtained from TokenProviderParameters. Finally, a KeyInfo element is set on the SubjectBean under the following conditions:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If a "SymmetricKey" Key Type algorithm is specified by the client, then the secret key passed through to the SubjectProvider is encrypted with the X509Certificate of the recipient, and added to the KeyInfo element. How the provider knows the public key of the recipient will be covered later.&lt;/li&gt;&lt;li&gt;If a "PublicKey" KeyType algorithm is specified by the client, the X509Certificate that is received as part of the "UseKey" request is inserted into the KeyInfo element of the Subject.&lt;/li&gt;&lt;/ul&gt;If a "Bearer" KeyType algorithm is specified by the client, then no KeyInfo element is added to the Subject. For the "SymmetricKey" Key Type case, the SAMLTokenProvider creates a secret key using a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SymmetricKeyHandler.java?view=markup"&gt;SymmetricKeyHandler&lt;/a&gt; instance. The SymmetricKeyHandler first checks the key size that is supplied as part of the KeyRequirements object, by checking that it fits in between a minimum and maximum key size that can be configured. It also checks any client entropy that is supplied, as well as the computed key algorithm. It then creates some entropy and a secret key.&lt;br /&gt;&lt;br /&gt;To add a custom Subject element to an assertion, you must create your own SubjectProvider implementation, and set it on the SAMLTokenProvider. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.3) Adding Attribute Statements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The SAMLTokenProvider has a "List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AttributeStatementProvider.java?view=markup"&gt;AttributeStatementProvider&lt;/a&gt;&amp;gt; attributeStatementProviders" property, which can be used to add AttributeStatments to the generated assertion. Each object in the list adds a single Attribute statement. The AttributeStatementProvider contains a single method to return an &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/bean/AttributeStatementBean.java?view=markup"&gt;AttributeStatementBean&lt;/a&gt; given the TokenProviderParameters object. This contains a SubjectBean (for SAML 1.1 assertions), and a list of &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/bean/AttributeBean.java?view=markup"&gt;AttributeBeans&lt;/a&gt;. The AttributeBean object holds the attribute name/qualified-name/name-format, and a list of attribute values, amongst other properties.&lt;br /&gt;&lt;br /&gt;If no statement provider is configured in the SAMLTokenProvider, then the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/DefaultAttributeStatementProvider.java?view=markup"&gt;DefaultAttributeStatementProvider&lt;/a&gt; is invoked to create an Attribute statement to add to the assertion. It creates a default "authenticated" attribute, and also creates separate Attributes for any "OnBehalfOf" or "ActAs" elements that were received in the request. If the received OnBehalfOf/ActAs element was a UsernameToken, then the username is added as an Attribute. If the received element was a SAML Assertion, then the subject name is added as an Attribute.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.4) Adding Authentication Statements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The SAMLTokenProvider has a "List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AuthenticationStatementProvider.java?view=markup"&gt;AuthenticationStatementProvider&lt;/a&gt;&amp;gt; authenticationStatementProviders" property, which can be used to add AuthenticationStatements to the generated assertion. Each object in the list adds a single Authentication statement. The AuthenticationStatementProvider contains a single method to return an &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/bean/AuthenticationStatementBean.java?view=markup"&gt;AuthenticationStatementBean&lt;/a&gt; given the TokenProviderParameters object. This contains a SubjectBean (for SAML 1.1 assertions), an authentication instant, authentication method, and other properties. No default implementation of the AuthenticationStatementProvider interface is provided in the STS, so if you want to issue Authentication Statements you will have to write your own.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.5) Adding Authorization Decision Statements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The SAMLTokenProvider has a "List&amp;lt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AuthDecisionStatementProvider.java?view=markup"&gt;AuthDecisionStatementProvider&lt;/a&gt;&amp;gt; authDecisionStatementProviders" property, which can be used to add AuthzDecisionStatements to the generated assertion. Each object in the list adds a single statement. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AuthDecisionStatementProvider.java?view=markup"&gt;AuthDecisionStatementProvider&lt;/a&gt;&amp;nbsp; contains a single method to return an &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/bean/AuthDecisionStatementBean.java?view=markup"&gt;AuthDecisionStatementBean&lt;/a&gt; given the TokenProviderParameters object. This contains a SubjectBean (for SAML 1.1 assertions), the decision (permit/indeterminate/deny), the resource URI, a list of ActionBeans, amongst other properties. No default implementation of the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/AuthDecisionStatementProvider.java?view=markup"&gt;AuthDecisionStatementProvider&lt;/a&gt; interface is provided in the STS.&lt;br /&gt;&lt;br /&gt;Note that for SAML 1.1 tokens, the Subject is embedded in one of the Statements. When creating a SAML 1.1 Assertion, if a given Authentication/Attribute/AuthzDecision statement does not have a subject, then the standalone Subject is inserted into the statement. Finally, once a SAML token has been created, it is stored in the cache (if one is configured), with a lifetime corresponding to that of the Conditions statement. A TokenProviderResponse object is created with the DOM representation of the SAML Token, the SAML Token ID, lifetime, entropy bytes, references, etc.&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-1050044971788381095?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/1050044971788381095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iv.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1050044971788381095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1050044971788381095'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iv.html' title='Apache CXF STS documentation - part IV'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7966869711456679757</id><published>2011-10-25T09:08:00.000-07:00</published><updated>2011-10-25T09:08:06.145-07:00</updated><title type='text'>Apache CXF STS documentation - part III</title><content type='html'>In the next couple of blog posts I will describe how to generate tokens in the new STS implementation shipped as part of Apache CXF 2.5. In this post I will detail the interface that is used for generating tokens, as well as an implementation to generate SecurityContextTokens that ships with the STS. In the next post, I will describe how to generate SAML tokens.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) The TokenProvider interface &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Security tokens are created in the STS via the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProvider.java?view=markup"&gt;TokenProvider&lt;/a&gt; interface. It has three methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;boolean canHandleToken(String tokenType) - Whether this TokenProvider implementation can provide a token of the given type&lt;/li&gt;&lt;li&gt; boolean canHandleToken(String tokenType, String realm) - Whether this TokenProvider implementation can provide a token of the given type, in the given realm&lt;/li&gt;&lt;li&gt;TokenProviderResponse createToken(TokenProviderParameters tokenParameters) - Create a token using the given parameters&lt;/li&gt;&lt;/ul&gt;A client can request a security token from the STS by either invoking the "issue" operation and supplying a desired token type, or else calling the "validate" operation and passing a (different) token type (token transformation). Assuming that the client request is authenticated and well-formed, the STS will iterate through a list of TokenProvider implementations to see if they can "handle" the received token type. If they can, then the implementation is used to create a security token, which is returned to the client. The second "canHandleToken" method which also takes a "realm" parameter will be covered in a future post.&lt;br /&gt;&lt;br /&gt;So to support the issuing of a particular token type in an STS deployment, it is necessary to specify a TokenProvider implementation that can handle that token type. The STS currently ships with two TokenProvider implementations, one for generating SecurityContextTokens, and one for generating SAML Assertions. Before we look at these two implementations, let's take a look at the "createToken" operation in more detail. This method takes a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderParameters.java?view=markup"&gt;TokenProviderParameters&lt;/a&gt; instance.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) TokenProviderParameters &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The TokenProviderParameters class is nothing more than a collection of configuration properties to use in creating the token, which are populated by the STS operations using information collated from the request, or static configuration, etc. The properties of the TokenProviderParameters are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSPropertiesMBean.java?view=markup"&gt;STSPropertiesMBean&lt;/a&gt; stsProperties - A configuration MBean that holds the configuration for the STS as a whole, such as information about the private key to use to sign issued tokens, etc. This will be covered later. &lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/service/EncryptionProperties.java?view=markup"&gt;EncryptionProperties&lt;/a&gt; encryptionProperties - A properties object that holds encryption information relevant to the intended recipient of the token. This will be covered later.&lt;/li&gt;&lt;li&gt;Principal principal - The current client Principal object. This can be used as the "subject" of the generated token.&lt;/li&gt;&lt;li&gt;WebServiceContext webServiceContext - The current web service context object. This allows access to the client request.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/RequestClaimCollection.java?view=markup"&gt;RequestClaimCollection&lt;/a&gt; requestedClaims - The requested claims in the token. This will be covered later.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/KeyRequirements.java?view=markup"&gt;KeyRequirements&lt;/a&gt; keyRequirements - A set of configuration properties relating to keys. This will be covered later.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java?view=markup"&gt;TokenRequirements&lt;/a&gt; tokenRequirements - A set of configuration properties relating to the token. This will be covered later.&lt;/li&gt;&lt;li&gt;String appliesToAddress - The URL that corresponds to the intended recipient of the token&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsManager.java?view=markup"&gt;ClaimsManager&lt;/a&gt; claimsManager - An object that can manage claims. This will be covered later.&lt;/li&gt;&lt;li&gt;Map&amp;lt;String, Object&amp;gt; additionalProperties - Any additional (custom) properties that might be used by a TokenProvider implementation.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/STSTokenStore.java?view=markup"&gt;STSTokenStore&lt;/a&gt; tokenStore - A cache used to store tokens.&lt;/li&gt;&lt;li&gt;String realm - The realm to create the token in (this should be the same as the realm passed to "canHandleToken"). This will be covered later.&lt;/li&gt;&lt;/ul&gt;If this looks complicated then remember that the STS will take care of populating all of these properties from the request and some additional configuration. You only need to worry about the TokenProviderParameters object if you are creating your own TokenProvider implementation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) TokenProviderResponse&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The "createToken" method returns an object of type &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderResponse.java?view=markup"&gt;TokenProviderResponse&lt;/a&gt;. Similar to the TokenProviderParameters object, this just holds a collection of objects that is parsed by the STS operation to construct a response to the client. The properties are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Element token - The (DOM) token that was created by the TokenProvider.&lt;/li&gt;&lt;li&gt;String tokenId - The ID of the token&lt;/li&gt;&lt;li&gt;long lifetime - The lifetime of the token&lt;/li&gt;&lt;li&gt;byte[] entropy - Any entropy associated with the token&lt;/li&gt;&lt;li&gt;long keySize - The key size of a secret key associated with the token.&lt;/li&gt;&lt;li&gt;boolean computedKey - Whether a computed key algorithm was used in generating a secret key.&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenReference.java?view=markup"&gt;TokenReference&lt;/a&gt; attachedReference - An object which gives information how to refer to the token when it is "attached".&lt;/li&gt;&lt;li&gt;&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenReference.java?view=markup"&gt;TokenReference&lt;/a&gt; unAttachedReference" - An object which gives information how to refer to the token when it is "unattached".&lt;/li&gt;&lt;/ul&gt;Most of these properties are optional as far as the STS operation is concerned, apart from the token and token ID. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenReference.java?view=markup"&gt;TokenReference&lt;/a&gt; object contains information about how to refer to the token (direct reference vs. Key Identifier, etc.), that is used by the STS to generate the appropriate reference to return to the client.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) The SCTProvider&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Now that we've covered the TokenProvider interface, let's look at an implementation that is shipped with the STS. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SCTProvider.java?view=markup"&gt;SCTProvider&lt;/a&gt; is used to provide a token  known as a SecurityContextToken, that is defined in the &lt;a href="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/ws-secureconversation-1.3-os.html#_Toc162064047"&gt;WS-SecureConversation&lt;/a&gt; specification. A SecurityContextToken essentially consists of a String Identifier which is associated with a particular secret key. If a service provider receives a SOAP message with a digital signature which refers to a SecurityContextToken in the KeyInfo of the signature, then the service provider knows that it must somehow obtain a secret key associated with that particular Identifier to verify the signature. How this is done is "out of band" (more on this later).&lt;br /&gt;&lt;br /&gt;To request a SecurityContextToken, the client must use one of the following Token Types:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;http://schemas.xmlsoap.org/ws/2005/02/sc/sct&lt;/li&gt;&lt;li&gt;http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512&lt;/li&gt;&lt;/ul&gt;Two properties can be configured on the SCTProvider directly:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;long lifetime - The lifetime of the generated SCT. The default is 5 minutes.&lt;/li&gt;&lt;li&gt;boolean returnEntropy - Whether to return any entropy bytes to the client or not. The default is true.&lt;/li&gt;&lt;/ul&gt;The SCTProvider generates a secret key using the KeyRequirements object that was supplied, and constructs a SecurityContextToken with a random Identifier. It creates a CXF SecurityToken object that wraps this information, and stores it in the supplied cache using the given lifetime. The SecurityContextToken element is then returned, along with the appropriate references, lifetime element, entropy, etc.&lt;br /&gt;&lt;br /&gt;When requesting a token from an STS, the client will typically present some entropy along with a computed key algorithm. The STS will generate some entropy of its own, and combine it with the client entropy using the computed key algorithm to generate the secret key. Alternatively, the client will present no entropy, and the STS will supply all of the entropy. Any entropy the STS generates is then returned to the client, who can recreate the secret key using its own entropy, the STS entropy, and the computed key algorithm.&lt;br /&gt;&lt;br /&gt;This secret key is then used for the SCT use-case to encrypt/sign some part of a message. The SecurityContextToken is placed in the security header of the message, and referred to in the KeyInfo element of the signed/encrypted structure. As noted earlier, the service provider must obtain somehow the secret key corresponding to the SecurityContextToken identifier. Perhaps the service provider shares a (secured) distributed cache with an STS instance. Or perhaps the service provider sends the SCT to an STS instance to "validate" it, and receives a SAML token in response with the embedded (encrypted) secret key.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5) Token caching in the TokenProvider&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Finally, we will cover token caching in a TokenProvider implementation. The SCTProvider is essentially useless without a cache, as otherwise there is no way for a third-party to know the secret key corresponding to a SecurityContextToken. Any TokenProvider implementation can cache a generated token in the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/STSTokenStore.java?view=markup"&gt;STSTokenStore&lt;/a&gt; object supplied as part of the TokenProviderParameters. This object simply wraps the TokenStore interface in the CXF WS-Security runtime, which itself contains basic methods for adding/removing/querying CXF &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java?view=markup"&gt;SecurityToken&lt;/a&gt; objects.&lt;br /&gt;&lt;br /&gt;The SCTProvider creates a SecurityToken with the ID of the SCT, the secret key associated with the SCT and the client principal. If a "realm" is passed through, then this is recorded as a property of the SecurityToken (keyed via &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/STSConstants.java?view=markup"&gt;STSConstants&lt;/a&gt;.TOKEN_REALM). Finally, the STS ships with two STSTokenStore implementations, an in-memory &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/DefaultInMemoryTokenStore.java?view=markup"&gt;implementation&lt;/a&gt; based on eh-cache, and an &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/HazelCastTokenStore.java?view=markup"&gt;implementation&lt;/a&gt; that uses Hazelcast.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7966869711456679757?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7966869711456679757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7966869711456679757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7966869711456679757'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-iii.html' title='Apache CXF STS documentation - part III'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-519290488660478196</id><published>2011-10-21T09:22:00.000-07:00</published><updated>2011-10-21T09:22:05.682-07:00</updated><title type='text'>Apache CXF STS documentation - part II</title><content type='html'>In &lt;a href="http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-i.html"&gt;part I&lt;/a&gt; of the series of posts on the new Apache CXF STS implementation, I talked about what a Security Token Service can do, as well as the STS provider framework in CXF since the 2.4.0 release. In this part, I will leave the STS implementation to one side for the moment, and instead focus on how a client interacts with the STS in CXF.&lt;br /&gt;&lt;br /&gt;A simple example of how a CXF client can obtain a security token from the STS is shown in the "basic" STS system test "&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java?view=markup"&gt;IssueUnitTest&lt;/a&gt;". This test starts an instance of the new CXF STS and obtains a number of different security tokens, all done completely programmatically, i.e. with no spring configuration. The STS instance that is used for the test-cases is configured with a number of different endpoints that use different security bindings (defined in the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/ws-trust-1.4-service.wsdl?view=markup"&gt;wsdl&lt;/a&gt; of the STS). For the purposes of this test, the Transport binding is used:&lt;br /&gt;&lt;br /&gt;&amp;lt;wsp:Policy wsu:Id="Transport_policy"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:ExactlyOne&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:All&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:TransportBinding&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:TransportToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:HttpsToken RequireClientCertificate="false"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:TransportToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:AlgorithmSuite&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:Basic128 /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:AlgorithmSuite&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:Layout&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:Lax /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:Layout&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:IncludeTimestamp /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:TransportBinding&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:SignedSupportingTokens&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:UsernameToken&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sp:IncludeToken=".../AlwaysToRecipient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssUsernameToken10 /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:UsernameToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:SignedSupportingTokens&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:All&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:ExactlyOne&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&lt;br /&gt;In other words, this security policy requires that a one-way TLS connection must be used to communicate with the STS, and that authentication is performed via a Username Token in the SOAP header.&lt;br /&gt;&lt;br /&gt;The object that communicates with an STS in CXF is the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java?view=markup"&gt;STSClient&lt;/a&gt;. Typically, the user constructs an STSClient instance (normally via Spring), sets it with certain properties such as the WSDL location of the STS, what service/port to use, various crypto properties, etc, and then stores this object on the message context using the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?view=markup"&gt;SecurityConstants&lt;/a&gt; tag "ws-security.sts.client". This object is then controlled by the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/IssuedTokenInterceptorProvider.java?view=markup"&gt;IssuedTokenInterceptorProvider&lt;/a&gt; in the ws-security runtime in CXF. This interceptor provider is triggered by the "IssuedToken" policy assertion, which is typically in the WSDL of the service provider. This policy assertion informs the client that it must obtain a particular security token from an STS and include it in the service request. The IssuedTokenInterceptorProvider takes care of using the STSClient to get a Security Token from the STS, and handles how long the security token should be cached, etc.&lt;br /&gt;&lt;br /&gt;An example of a simple IssuedToken policy that might appear in the WSDL of a service provider is as follows:&lt;br /&gt;&lt;br /&gt;&amp;lt;sp:IssuedToken sp:IncludeToken=".../AlwaysToRecipient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/t:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;t:KeyType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/t:KeyType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; ... &lt;br /&gt;&amp;lt;/sp:IssuedToken&amp;gt;&lt;br /&gt;&lt;br /&gt;This policy states that the client should include a SAML 2.0 Assertion of subject confirmation method "Bearer" in the request. The client must know how to communicate with an STS to obtain such a token. This is done by providing the STSClient object with the appropriate information.&lt;br /&gt;&lt;br /&gt;We will come back to the IssuedTokenInterceptorProvider at a later date. The IssueUnitTest referred to above uses the STSClient programmatically to obtain a security token. Let's look at the "requestSecurityToken" method called by the tests. An STSClient is instantiated via the CXF bus, and the WSDL location of the STS, plus service and port names are configured:&lt;br /&gt;&lt;br /&gt;STSClient stsClient = new STSClient(bus);&lt;br /&gt;stsClient.setWsdlLocation("https://.../SecurityTokenService/Transport?wsdl");&lt;br /&gt;stsClient.setServiceName("{...}SecurityTokenService");&lt;br /&gt;stsClient.setEndpointName("{...}Transport_Port");&lt;br /&gt;&lt;br /&gt;A map is then populated with various properties and set on the STSClient. It is keyed with a different number of &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?view=markup"&gt;SecurityConstants&lt;/a&gt; tags. A username is supplied for use as the "user" in the UsernameToken. A CallbackHandler class is supplied to get the password to use in the UsernameToken. Compliance of the Basic Security Profile 1.1 is turned off, this is to prevent CXF throwing an exception when receiving a non-spec compliant response from a non-CXF STS:&lt;br /&gt;&lt;br /&gt;Map&amp;lt;String, Object&amp;gt; properties = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;stsClient.setProperties(properties); &lt;br /&gt;properties.put(SecurityConstants.USERNAME, "alice");&lt;br /&gt;properties.put(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityConstants.CALLBACK_HANDLER, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "org.apache.cxf.systest.sts.common.CommonCallbackHandler"&lt;br /&gt;);&lt;br /&gt;properties.put(SecurityConstants.IS_BSP_COMPLIANT, "false");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;If the KeyType is a "PublicKey", then an X.509 Certificate is presented to the STS in the request to embed in the generated SAML Assertion. The X.509 Certificate is obtained from the keystore defined in "clientKeystore.properties", with the alias "myclientkey". Finally, the "useCertificateForConfirmationKeyInfo" property of the STSClient means that the entire certificate is to be included in the request, instead of a KeyValue (which is the default):&lt;br /&gt;&lt;br /&gt;if (PUBLIC_KEY_KEYTYPE.equals(keyType)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties.put(SecurityConstants.STS_TOKEN_USERNAME, "myclientkey");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "clientKeystore.properties");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stsClient.setUseCertificateForConfirmationKeyInfo(true);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Finally, the token type is set on the STSClient (the type of token that is being requested), as well as the KeyType (specific to a SAML Assertion), and a security token is requested, passing the endpoint address which is sent to the STS in the "AppliesTo" element:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stsClient.setTokenType(tokenType);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stsClient.setKeyType(keyType);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return stsClient.requestSecurityToken(endpointAddress);&lt;br /&gt;&lt;br /&gt;The returned &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java?view=markup"&gt;SecurityToken&lt;/a&gt; object contains the received token as a DOM element, the ID of the received token, any reference elements that were returned - which show how to reference the token, any secret associated with the token, and the lifetime of the token.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-519290488660478196?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/519290488660478196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-ii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/519290488660478196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/519290488660478196'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-ii.html' title='Apache CXF STS documentation - part II'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-4264305693816829850</id><published>2011-10-19T09:00:00.000-07:00</published><updated>2011-10-19T09:00:30.072-07:00</updated><title type='text'>Apache CXF STS documentation - part I</title><content type='html'>The forthcoming Apache CXF 2.5 release will have an STS (Security Token Service) &lt;a href="http://coheigea.blogspot.com/2011/09/talend-donate-security-token-service.html"&gt;implementation&lt;/a&gt; which has been donated by &lt;a href="http://www.talend.com/index.php"&gt;Talend&lt;/a&gt;. This is the first in a series of blog posts where I will be going into the STS implementation in detail. In this post I will be explaining what an STS is and talking about the STS provider framework in CXF.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) What is a Security Token Service?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;An informal description of a Security Token Service is that it is a web service that offers some or all of the following services (amongst others):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It can issue a Security Token of some sort based on presented or configured credentials.&lt;/li&gt;&lt;li&gt;It can say whether a given Security Token is valid or not&lt;/li&gt;&lt;li&gt;It can renew (extend the validity of) a given Security Token &lt;/li&gt;&lt;li&gt;It can cancel (remove the validity of) a given Security Token&lt;/li&gt;&lt;li&gt;It can transform a given Security Token into a Security Token of a different sort.&lt;/li&gt;&lt;/ul&gt;Offloading this functionality to another service greatly simplifies client and service provider functionality, as they can simply call the STS appropriately rather than have to figure out the security requirements themselves. For example, the WSDL of a service provider might state that a particular type of security token is required to access the service. A client of the service can ask an STS for a Security Token of that particular type, which is then sent to the service provider. The service provider could choose to validate the received token locally, or dispatch the token to an STS for validation. These are the two most common use-cases of an STS.&lt;br /&gt;&lt;br /&gt;A client can communicate with the STS via a protocol defined in the WS-Trust &lt;a href="http://docs.oasis-open.org/ws-sx/ws-trust/v1.4/ws-trust.html"&gt;specification&lt;/a&gt;. The SOAP Body of the request contains a "RequestSecurityToken" element that looks like:&lt;br /&gt;&lt;br /&gt;&amp;lt;wst:RequestSecurityToken Context="..." xmlns:wst="..."&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:TokenType&amp;gt;...&amp;lt;/wst:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:RequestType&amp;gt;...&amp;lt;/wst:RequestType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:SecondaryParameters&amp;gt;...&amp;lt;/wst:SecondaryParameters&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;lt;/wst:RequestSecurityToken&amp;gt;&lt;br /&gt;&lt;br /&gt;The Apache CXF STS implementation supports a wide range of parameters that are passed in the RequestSecurityToken element. The SOAP Body of the response from the STS will contain a "RequestSecurityTokenResponse(Collection)" element, e.g.:&lt;br /&gt;&lt;br /&gt;&amp;lt;wst:RequestSecurityTokenResponseCollection xmlns:wst="..."&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:RequestSecurityTokenResponse&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wst:RequestSecurityTokenResponse&amp;gt;&lt;br /&gt;&amp;lt;/wst:RequestSecurityTokenResponseCollection&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.1 A sample request/response for issuing a Security Token&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A sample client request is given here, where the client wants the STS to issue a SAML 2.0 token for the "http://cxf.apache.org:8080/service" service:&lt;br /&gt;&lt;br /&gt;&amp;lt;wst:RequestSecurityToken Context="..." xmlns:wst="..."&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wst:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:RequestType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wst:RequestType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:AppliesTo&amp;gt;http://cxf.apache.org:8080/service&amp;lt;/wsp:AppliesTo&amp;gt;&lt;br /&gt;&amp;lt;/wst:RequestSecurityToken&amp;gt;&lt;br /&gt;&lt;br /&gt;The STS responds with:&lt;br /&gt;&lt;br /&gt;&amp;lt;wst:RequestSecurityTokenResponseCollection xmlns:wst="..."&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:RequestSecurityTokenResponse&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/wst:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:RequestedSecurityToken&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;saml2:Assertion xmlns:saml2="..." ... /&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wst:RequestedSecurityToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wst:RequestSecurityTokenResponse&amp;gt;&lt;br /&gt;&amp;lt;/wst:RequestSecurityTokenResponseCollection&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) The STS provider framework in Apache CXF &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The first support for an STS in Apache CXF &lt;a href="https://issues.apache.org/jira/browse/CXF-1940"&gt;appeared&lt;/a&gt; in the 2.4.0 release with the addition of an STS &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/"&gt;provider&lt;/a&gt; framework in the WS-Security module. This is essentially an API that can be used to create your own STS implementation. As the STS implementation shipped in CXF 2.5 is based on this provider framework, it makes sense to examine it in more detail.&lt;br /&gt;&lt;br /&gt;The SEI (Service Endpoint Interface) is available &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenService.java?view=markup"&gt;here&lt;/a&gt;. It contains the following methods that are relevant to the STS features discussed above:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;RequestSecurityTokenResponseCollectionType issue(RequestSecurityTokenType request) - to issue a security token&lt;/li&gt;&lt;li&gt;RequestSecurityTokenResponseType issueSingle( RequestSecurityTokenType request) - to issue a security token that is not contained in a "Collection" wrapper (for legacy applications). &lt;/li&gt;&lt;li&gt;RequestSecurityTokenResponseType cancel(RequestSecurityTokenType request) - to cancel a security token&lt;/li&gt;&lt;li&gt;RequestSecurityTokenResponseType validate(RequestSecurityTokenType request) - to validate a security token&lt;/li&gt;&lt;li&gt;RequestSecurityTokenResponseType renew(RequestSecurityTokenType request) - to renew a security token&lt;/li&gt;&lt;/ul&gt;The SEI &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceImpl.java?revision=1174872&amp;amp;view=markup"&gt;implementation&lt;/a&gt; handles each request by delegating it to a particular &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/"&gt;operation&lt;/a&gt;, which is just an interface that must be implemented by the provider framework implementation. Finally, a JAX-WS provider is &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java?view=markup"&gt;available&lt;/a&gt;, which dispatches a request to the appropriate operation.&lt;br /&gt;&lt;br /&gt;Significant updates to the STS Provider framework after the CXF 2.4.0 release include support for SOAP 1.2, a major bug &lt;a href="https://issues.apache.org/jira/browse/CXF-3606"&gt;fix&lt;/a&gt; to support operations other than issue,&amp;nbsp; better exception &lt;a href="https://issues.apache.org/jira/browse/CXF-3693"&gt;propagation&lt;/a&gt;, and adding support for the WS-Trust 1.4 schema. These features are all available in the Apache CXF 2.4.3 release onwards.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-4264305693816829850?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/4264305693816829850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-i.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4264305693816829850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4264305693816829850'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-documentation-part-i.html' title='Apache CXF STS documentation - part I'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-3043093811206833412</id><published>2011-10-11T09:03:00.000-07:00</published><updated>2011-11-02T07:08:55.510-07:00</updated><title type='text'>Using Kerberos with Web Services - part II</title><content type='html'>This is the second of a two-part series on using Kerberos with Web Services, with Apache WSS4J and CXF. &lt;a href="http://coheigea.blogspot.com/2011/10/using-kerberos-with-web-services-part-i.html"&gt;Part I&lt;/a&gt; showed how to set up a KDC distribution, and how to generate client and service principals to use in some CXF system tests. The system tests showed how to obtain a Kerberos token from a KDC, package it in a BinarySecurityToken, and send it to a service endpoint for validation. In other words, part I illustrated how to use Kerberos for client authentication in a web service setting.&lt;br /&gt;&lt;br /&gt;This article builds on part I by showing how to use the secret key associated with a Kerberos Token to secure (sign and encrypt) the request. This functionality was &lt;a href="https://issues.apache.org/jira/browse/WSS-307"&gt;added&lt;/a&gt; as part of WSS4J 1.6.3, and the related WS-SecurityPolicy functionality was released as part of CXF 2.4.3. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Setting up the Kerberos system tests in Apache CXF&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If you have not done so already, follow the instructions in &lt;a href="http://coheigea.blogspot.com/2011/10/using-kerberos-with-web-services-part-i.html"&gt;part I&lt;/a&gt; to install a Kerberos distribution and to generate client and service principals to run the CXF Kerberos system tests. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/kerberos/KerberosTokenTest.java?view=markup"&gt;KerberosTokenTest&lt;/a&gt; in Apache CXF contains a number of different Kerberos tests. In this article we will examine the tests that involve obtaining a Kerberos Token, and using the associated secret key to secure some part of the request. &lt;br /&gt;&lt;br /&gt;Firstly, make sure that the JDK has unlimited security policies installed, and then checkout the CXF trunk via:&lt;br /&gt;&lt;blockquote&gt;svn co https://svn.apache.org/repos/asf/cxf/trunk/&lt;/blockquote&gt;Go into the "trunk" directory, and compile and install CXF via "mvn -Pfastinstall" (this will avoid running tests). Finally go into the WS-Security system tests in "systests/ws-security"&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.1) Installing a custom KerberosTokenDecoder &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Once the client obtains an AP-REQ token from the KDC, the client also has easy access to the session key, which can be used to secure the request in some way. Unfortunately, there appears to be no easy way to obtain the session key on the receiving side. WSS4J does not support extracting a Kerberos session key on the receiving side to decrypt/verify a secured request out-of-the-box. Instead, a &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/KerberosTokenDecoder.java?view=markup"&gt;KerberosTokenDecoder&lt;/a&gt; interface is provided, which defines methods for setting the AP-REQ token and current Subject, and a method to then get a session key. An implementation must be set on the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/KerberosTokenValidator.java?view=markup"&gt;KerberosTokenValidator&lt;/a&gt; to obtain a session key to decrypt or verify a signed request.&lt;br /&gt;&lt;br /&gt;To run the Kerberos system tests that require a secret key on the receiving side, download an implementation of the KerberosTokenValidator interface &lt;a href="https://docs.google.com/leaf?id=0B5V34LIZViDgMWI4OTUwMTItMWZjZi00MmQ4LWI5YjMtZGUxNGYwZTY5ODhh&amp;amp;hl=en_US"&gt;here&lt;/a&gt;, and copy it to "systests/ws-security/src/test/java/org/apache/cxf/systest/ws/kerberos/server". The implementation is based on code written by the &lt;a href="http://thejavamonkey.blogspot.com/2008/05/how-to-decrypt-kerberos-gss-ap-req.html"&gt;Java Monkey&lt;/a&gt;, and uses internal sun APIs, and so can't be shipped in Apache CXF/WSS4J. Once this implementation has been copied into the ws-security module, then you must compile or run any tests with the "-Pnochecks" profile enabled, as otherwise the code fails checkstyle.&lt;br /&gt;&lt;br /&gt;Open the server configuration &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/kerberos/server/server.xml?view=markup"&gt;file&lt;/a&gt; ("src/test/resources/org/apache/cxf/systest/ws/kerberos/server/server.xml"), and uncomment the "kerberosTicketDecoderImpl" bean, and the property of the "kerberosValidator" bean that refers to it:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;bean id="kerberosTicketDecoderImpl"&amp;nbsp;&amp;nbsp; class="org.apache.cxf.systest.ws.kerberos.server.KerberosTokenDecoderImpl"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="kerberosValidator"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="org.apache.ws.security.validate.KerberosTokenValidator"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="contextName" value="bob"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="serviceName" value="bob@service.ws.apache.org"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="kerberosTokenDecoder" ref="kerberosTicketDecoderImpl"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt; &lt;/blockquote&gt;&lt;b&gt;1.2) Running the tests &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Open KerberosTokenTest.java and comment out the "@org.junit.Ignore" entries for the last four tests, "testKerberosOverTransportEndorsing", "testKerberosOverAsymmetricEndorsing", "testKerberosOverSymmetricProtection" and "testKerberosOverSymmetricDerivedProtection". Finally, run the tests via:&lt;br /&gt;&lt;blockquote&gt;mvn -Pnochecks test -Dtest=KerberosTokenTest -Djava.security.auth.login.config=src/test/resources/kerberos.jaas&lt;b&gt; &lt;/b&gt;&lt;/blockquote&gt;&lt;b&gt;2) The tests in more detail&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In this section, we'll look at the tests in more detail.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.1) WS-SecurityPolicy configuration &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/wsdl_systest_wssec/kerberos/DoubleItKerberos.wsdl?view=markup"&gt;wsdl&lt;/a&gt; that defines the service endpoints contains WS-SecurityPolicy expressions that define the security requirements of the endpoints. The following security policies are used for the four tests defined above:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;testKerberosOverTransportEndorsing:  A (one-way) transport binding is defined, with a KerberosToken required as an EndorsingSupportingToken.&amp;nbsp;&lt;/li&gt;&lt;li&gt;testKerberosOverAsymmetricEndorsing: An asymmetric binding is used, where a KerberosToken is required as an EndorsingSupportingToken.&lt;/li&gt;&lt;li&gt;testKerberosOverSymmetricProtection: A symmetric binding is used, where a KerberosToken is specified as a ProtectionToken of the binding.&lt;/li&gt;&lt;li&gt;testKerberosOverSymmetricDerivedProtection: The same as the previous test-case, except that any secret keys that are used must be derived.&lt;/li&gt;&lt;/ul&gt;The first two test-cases use an EndorsingSupportingToken, which means that the secret key associated with the KerberosToken is used to sign (endorse) some message part (the timestamp for the Transport binding). This illustrates proof-of-possession. For the latter two test-cases, the KerberosToken is defined as a ProtectionToken, meaning that the secret key is used to sign/encrypt the request (e.g. instead of using an X.509 Token to encrypt a session key). &lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.2) Kerberos LoginModule configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Both the CXF client and service endpoint use JAAS to authenticate to the KDC. The JAAS &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/kerberos.jaas?view=markup"&gt;file&lt;/a&gt; used as part of the system test is passed to the tests via the System property "java.security.auth.login.config". The client (alice) uses the following login module:&lt;br /&gt;&lt;blockquote&gt;alice {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.sun.security.auth.module.Krb5LoginModule required&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; refreshKrb5Config=true useKeyTab=true keyTab="/etc/alice.keytab"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; principal="alice";&lt;br /&gt;};&lt;/blockquote&gt;and the service endpoint (bob) uses:&lt;br /&gt;&lt;blockquote&gt;bob {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.sun.security.auth.module.Krb5LoginModule required&lt;br /&gt;&amp;nbsp; &amp;nbsp; refreshKrb5Config=true useKeyTab=true storeKey=true&lt;br /&gt;&amp;nbsp; &amp;nbsp; keyTab="/etc/bob.keytab" principal="bob/service.ws.apache.org";&lt;br /&gt;};&lt;b&gt; &lt;/b&gt;&lt;/blockquote&gt;&lt;b&gt;2.3) Service endpoint configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The service &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/kerberos/server/server.xml?view=markup"&gt;endpoints&lt;/a&gt; are spring-loaded. Each endpoint definition contains the JAX-WS property "ws-security.bst.validator" which is defined in &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?view=markup"&gt;SecurityConstants&lt;/a&gt;. WSS4J uses &lt;a href="http://coheigea.blogspot.com/2011/06/custom-token-validation-in-apache-cxf.html"&gt;Validator&lt;/a&gt; implementations to perform validation on received security tokens. This particular property means that BinarySecurityTokens are to be validated by the given reference, e.g.:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&amp;lt;jaxws:endpoint ...&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.bst.validator" value-ref="kerberosValidator"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:endpoint&amp;gt; &lt;/blockquote&gt;"kerberosValidator" is a  &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/KerberosTokenValidator.java?view=markup"&gt;KerberosTokenValidator&lt;/a&gt; instance given above. It requires a "contextName" property, which corresponds to the JAAS context name, as well as an optional "serviceName" property, and an optional "kerberosTokenDecoder" property to use to obtain a secret key. Combined with the JAAS properties file, this is all that is required for the service endpoint to validate a received Kerberos Token.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.4 Client configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Finally, the client must contact a KDC and obtain a Kerberos Token, once it sees that the service endpoint has a security policy that requires a KerberosToken. The client configuration is available &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/kerberos/client/client.xml?view=markup"&gt;here&lt;/a&gt;. A sample configuration for the Kerberos Test case is as follows:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;jaxws:client name="{...}DoubleItKerberosTransportPort" &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; createdFromAPI="true"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.kerberos.client"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean class="org.apache.cxf.ws.security.kerberos.KerberosClient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg ref="cxf"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="contextName" value="alice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="serviceName" value="bob@service.ws.apache.org"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/entry&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:client&amp;gt;&lt;/blockquote&gt;The JAX-WS property "ws-security.kerberos.client" (again, defined in SecurityConstants) corresponds to a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/kerberos/KerberosClient.java?view=markup"&gt;KerberosClient&lt;/a&gt; object. Similar to the KerberosTokenValidator on the receiving side, this is configured with a JAAS context Name and service Name.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-3043093811206833412?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/3043093811206833412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/using-kerberos-with-web-services-part.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3043093811206833412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3043093811206833412'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/using-kerberos-with-web-services-part.html' title='Using Kerberos with Web Services - part II'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-1505647934111970482</id><published>2011-10-11T06:21:00.000-07:00</published><updated>2011-10-11T06:21:10.333-07:00</updated><title type='text'>Apache CXF STS articles</title><content type='html'>Two of my colleagues have written excellent articles on the forthcoming STS (Security Token Service) implementation in Apache CXF, complete with sample projects. See &lt;a href="http://owulff.blogspot.com/2011/10/configure-and-deploy-cxf-25-sts-part-i.html"&gt;here&lt;/a&gt; for the article from Oliver Wulff, and &lt;a href="http://www.jroller.com/gmazza/date/20111004"&gt;here&lt;/a&gt; for the article from Glen Mazza.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-1505647934111970482?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/1505647934111970482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-articles.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1505647934111970482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1505647934111970482'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-cxf-sts-articles.html' title='Apache CXF STS articles'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-4094033355869823248</id><published>2011-10-10T09:00:00.000-07:00</published><updated>2011-11-02T07:07:21.425-07:00</updated><title type='text'>Using Kerberos with Web Services - part I</title><content type='html'>This is the first of a two-part series on using Kerberos with Web Services, with Apache WSS4J and CXF. WSS4J 1.6.2 adds &lt;a href="https://issues.apache.org/jira/browse/WSS-251"&gt;support &lt;/a&gt;for obtaining a Kerberos ticket from a KDC (Key Distribution Center) and converting it to a BinarySecurityToken to be inserted into the security header of a SOAP request. On the receiving side, support has been added to validate the received Kerberos ticket accordingly. CXF 2.4.2 &lt;a href="https://issues.apache.org/jira/browse/CXF-3674"&gt;extends&lt;/a&gt; the Kerberos functionality available in WSS4J 1.6.2 to add support for WS-SecurityPolicy. No support is available yet (as of CXF 2.4.2) to use a secret key to sign and encrypt message parts, this will be the subject of part II.&lt;br /&gt;&lt;br /&gt;In this post we will talk about installing the MIT Kerberos distribution in Ubuntu, and creating the necessary credentials to run some tests. Then we will go into some system tests in CXF that show how a client can get a Kerberos AP-REQ ticket from a KDC and send it to a service provider, who then authenticates the ticket, all driven by some spring configuration and WS-SecurityPolicy.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Installing MIT Kerberos&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.1) Installing the product &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In this section we cover how to install the MIT Kerberos distribution in Ubuntu. This is needed to run the CXF Kerberos system tests. See &lt;a href="https://help.ubuntu.com/community/Kerberos"&gt;here&lt;/a&gt; for more information on using Kerberos on Ubuntu. Open a command prompt and type:&lt;br /&gt;&lt;blockquote&gt;sudo apt-get install krb5-kdc krb5-admin-server&lt;/blockquote&gt;When the product is installing you'll be asked for the default Kerberos Version 5 realm. Enter:&lt;br /&gt;&lt;blockquote&gt;WS.APACHE.ORG &lt;/blockquote&gt;You will then be prompted for the hostnames of Kerberos servers in the WS.APACHE.ORG Kerberos realm. As we are installing the KDC and running the tests on the same machine, we only need to enter "localhost". Similarly, enter "localhost" when prompted for the Administrative server for the Kerberos realm.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.2) Modifying configuration &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Once apt-get has finished, we need to modify the Kerberos configuration file ("sudo vi /etc/krb5.conf"):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Under the "[realms]" section, add a "default_domain" entry for ws.apache.org. The entire entry should look like:&lt;br /&gt;&lt;blockquote&gt;&lt;blockquote&gt;WS.APACHE.ORG = {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kdc = localhost&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; admin_server = localhost&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; default_domain = ws.apache.org&lt;br /&gt;}&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Under the "[domain_realm]" section, add the following:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;ws.apache.org = WS.APACHE.ORG&amp;nbsp;&amp;nbsp;&lt;br /&gt;.ws.apache.org = WS.APACHE.ORG&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;Finally, add a logging section:&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;[logging]&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kdc = FILE:/var/log/krb5kdc.log&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; admin_server = FILE:/var/log/kadmin.log&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; default = FILE:/var/log/krb5lib.log &lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;b&gt;1.3) Create principals &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The next step is to create some principals. Create a master key via:&lt;br /&gt;&lt;blockquote&gt;sudo kdb5_util create -s&lt;/blockquote&gt;The next step is to start kadmin locally via:&lt;br /&gt;&lt;blockquote&gt;sudo kadmin.local&lt;/blockquote&gt;If you run "listprincs" at the prompt you should see the ticket-granting-ticket principal "krbtgt/WS.APACHE.ORG@WS.APACHE.ORG". We will add a client principal and service principal:&lt;br /&gt;&lt;blockquote&gt;addprinc alice&lt;br /&gt;addprinc bob/service.ws.apache.org&lt;/blockquote&gt;"quit" the kadmin prompt, and start the KDC with "sudo krb5kdc". If you see no error messages then everything should be working correctly. To test this try to get a ticket for "alice" via "kinit alice", entering the password given when creating the "alice" principal.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.4) Create keytabs&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To avoid having to enter passwords when running the tests, we will create Keytabs. Start kadmin.local again ("sudo kadmin.local"), and enter:&lt;br /&gt;&lt;blockquote&gt;ktadd -k /etc/alice.keytab alice&lt;br /&gt;ktadd -k /etc/bob.keytab bob/service.ws.apache.org&lt;/blockquote&gt;To check that the keytabs were create correctly, you can inspect them with klist, e.g. "sudo klist -k /etc/alice.keytab". Finally make sure the keytabs are readable via "sudo chmod og+r /etc/*.keytab" - obviously this is not secure, but it is sufficient for this test application.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Running the Kerberos system tests in Apache CXF &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Now that we have installed Kerberos and created the relevant principals, we can run the Kerberos system tests in Apache CXF. These tests are @Ignore'd by default. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/kerberos/KerberosTokenTest.java?view=markup"&gt;KerberosTokenTest&lt;/a&gt; contains a number of different Kerberos tests. In this article we will just examine the tests that involve obtaining a Kerberos Token, and not any of the tests that involve using the secret key associated with a Kerberos Token to secure some part of the request.&lt;br /&gt;&lt;br /&gt;Firstly, make sure that the JDK has unlimited security policies installed, and then checkout the CXF trunk via:&lt;br /&gt;&lt;blockquote&gt;svn co https://svn.apache.org/repos/asf/cxf/trunk/&lt;/blockquote&gt;Go into the "trunk" directory, and compile and install CXF via "mvn -Pfastinstall" (this will avoid running tests). Finally go into the WS-Security system tests in "systests/ws-security". Open KerberosTokenTest.java and comment out the "@org.junit.Ignore" entries for the first four tests, "testKerberosOverTransport", "testKerberosOverSymmetric", "testKerberosOverSymmetricSupporting" and "testKerberosOverAsymmetric". Finally, run the tests via:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mvn test -Dtest=KerberosTokenTest -Djava.security.auth.login.config=src/test/resources/kerberos.jaas&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.1) WS-SecurityPolicy configuration &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/wsdl_systest_wssec/kerberos/DoubleItKerberos.wsdl?view=markup"&gt;wsdl&lt;/a&gt; that defines the service endpoints contains WS-SecurityPolicy expressions that define the security requirements of the endpoints. The following security policies are used for the four tests defined above:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;testKerberosOverTransport: A (one-way) transport binding is defined, with a KerberosToken required as a SupportingToken. Essentially, this means that the communication is secured with TLS, and authentication is handled by a Kerberos token.&lt;/li&gt;&lt;li&gt;testKerberosOverSymmetric: A symmetric binding is used, where a KerberosToken is required as a SignedSupportingToken.&amp;nbsp;&lt;/li&gt;&lt;li&gt;testKerberosOverSymmetricSupporting: A symmetric binding is used, where a KerberosToken is required as a SupportingToken.&lt;/li&gt;&lt;li&gt;testKerberosOverAsymmetric: An asymmetric binding is used, where a Kerberos token is required as a SignedSupportingToken.&lt;/li&gt;&lt;/ul&gt;The WS-SecurityPolicy expression used for a KerberosToken is:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;sp:KerberosToken sp:IncludeToken=".../Once"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssGssKerberosV5ApReqToken11/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;lt;/sp:KerberosToken&amp;gt;&lt;/blockquote&gt;This means that a GSS V5 AP-REQ Token is required "once", in other words the initial invocation between the client and service endpoint must contain a token of this type encoded as a BinarySecurityToken in the security header of the request.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.2) Kerberos LoginModule configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Both the CXF client and service endpoint use JAAS to authenticate to the KDC. The JAAS &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/kerberos.jaas?view=markup"&gt;file&lt;/a&gt; used as part of the system test is passed to the tests via the System property "java.security.auth.login.config". The client (alice) uses the following login module: &lt;br /&gt;&lt;blockquote&gt;alice {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.sun.security.auth.module.Krb5LoginModule required&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; refreshKrb5Config=true useKeyTab=true keyTab="/etc/alice.keytab"&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; principal="alice";&lt;br /&gt;};&lt;/blockquote&gt;and the service endpoint (bob) uses:&lt;br /&gt;&lt;blockquote&gt;bob {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.sun.security.auth.module.Krb5LoginModule required&lt;br /&gt;&amp;nbsp; &amp;nbsp; refreshKrb5Config=true useKeyTab=true storeKey=true&lt;br /&gt;&amp;nbsp; &amp;nbsp; keyTab="/etc/bob.keytab" principal="bob/service.ws.apache.org";&lt;br /&gt;};&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/blockquote&gt;&lt;b&gt;2.3) Service endpoint configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The service &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/kerberos/server/server.xml?view=markup"&gt;endpoints&lt;/a&gt; are spring-loaded. Each endpoint definition contains the JAX-WS property "ws-security.bst.validator" which is defined in &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?view=markup"&gt;SecurityConstants&lt;/a&gt;. WSS4J uses &lt;a href="http://coheigea.blogspot.com/2011/06/custom-token-validation-in-apache-cxf.html"&gt;Validator&lt;/a&gt; implementations to perform validation on received security tokens. This particular property means that BinarySecurityTokens are to be validated by the given reference, e.g.:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;jaxws:endpoint ...&amp;gt; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.bst.validator" value-ref="kerberosValidator"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:endpoint&amp;gt; &lt;/blockquote&gt;"kerberosValidator" is defined as: &lt;br /&gt;&lt;blockquote&gt;&amp;lt;bean id="kerberosValidator"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="org.apache.ws.security.validate.KerberosTokenValidator"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="contextName" value="bob"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="serviceName" value="bob@service.ws.apache.org"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;/blockquote&gt;The &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/KerberosTokenValidator.java?view=markup"&gt;KerberosTokenValidator&lt;/a&gt; class ships with Apache WSS4J. It requires a "contextName" property, which corresponds to the JAAS context name, as well as an optional "serviceName" property. Combined with the JAAS properties file, this is all that is required for the service endpoint to validate a received Kerberos Token.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.4 Client configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Finally, the client must contact a KDC and obtain a Kerberos Token, once it sees that the service endpoint has a security policy that requires a KerberosToken. The client configuration is available &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/kerberos/client/client.xml?view=markup"&gt;here&lt;/a&gt;. A sample configuration for the Kerberos Test case is as follows:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;jaxws:client name="{...}DoubleItKerberosTransportPort" &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; createdFromAPI="true"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.kerberos.client"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean class="org.apache.cxf.ws.security.kerberos.KerberosClient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg ref="cxf"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="contextName" value="alice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="serviceName" value="bob@service.ws.apache.org"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/entry&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:client&amp;gt;&lt;/blockquote&gt;The JAX-WS property "ws-security.kerberos.client" (again, defined in SecurityConstants) corresponds to a &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/kerberos/KerberosClient.java?view=markup"&gt;KerberosClient&lt;/a&gt; object. Similar to the KerberosTokenValidator on the receiving side, this is configured with a JAAS context Name and service Name.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-4094033355869823248?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/4094033355869823248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/using-kerberos-with-web-services-part-i.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4094033355869823248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4094033355869823248'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/using-kerberos-with-web-services-part-i.html' title='Using Kerberos with Web Services - part I'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6565587402320130849</id><published>2011-10-07T04:10:00.000-07:00</published><updated>2011-11-09T04:16:00.040-08:00</updated><title type='text'>Improving decryption performance in Apache Santuario 1.5</title><content type='html'>&lt;a href="http://veithen.blogspot.com/"&gt;Andreas Veithen&lt;/a&gt; alerted me some months back to a performance problem in Apache Santuario when decrypting messages. The issue emerged when some profiling was done on Dennis Sosnoski's &lt;a href="http://www.ibm.com/developerworks/apps/download/index.jsp?contentid=407176&amp;amp;filename=j-jws6.zip&amp;amp;method=http&amp;amp;locale=worldwide"&gt;test-code&lt;/a&gt; for measuring WS-Security performance across different web services stacks (see the original article &lt;a href="http://www.ibm.com/developerworks/java/library/j-jws6/index.html"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;The test scenario involves deploying an Apache CXF 2.4.2 endpoint in Tomcat and repeatedly testing the "signencr" invocation defined in the article (WS-Security signing of body and headers, with timestamp and encryption of body) using a CXF client. Two types of test-runs were executed, 1000 "large" messages at 0.2 density in one run, and 10000 "small" messages at 0.05 density in another. When doing some profiling using a &lt;a href="http://code.google.com/p/oktech-profiler/"&gt;sampling profiler&lt;/a&gt; on the client, it emerged that the time it took to deserialize a decrypted XML String into a DOM element was taking around 20% of the total execution time for all WS-Security processing!&lt;br /&gt;&lt;br /&gt;The way the default deserializing algorithm works in Apache Santuario 1.4.x is to parse the decrypted XML String into a new Document object, which is then imported into the existing Document. As Apache Xerces defers the creation of Node objects, the import operation triggers the full expansion of the DOM tree.&lt;br /&gt;&lt;br /&gt;There are a number of alternatives to using the DocumentBuilder/importNode approach used in Santuario 1.4.x. The first approach is to use a Transformer object to transform the Source (XML String) into a placeholder Node belonging to the existing Document. This approach avoids having to explicitly import the nodes back to the existing Document. The second approach, is to use the streaming API available in the JDK 1.6 (not an option for Santuario 1.5 which must compile against the JDK 1.5).&lt;br /&gt;&lt;br /&gt;Here are some (ad-hoc) test results. The first results show the total time for each test-run using both algorithms:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Large Messages:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Document Serializer: 119.46s&lt;/li&gt;&lt;li&gt;Transform Serializer: 115.68s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Small Messages:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Document Serializer: 222.32s&lt;/li&gt;&lt;li&gt;Transform Serializer: 216.76s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;The next results show the time spent in the Serializer.deserialize() operation as a percentage of the total WS-Security processing time:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Large Messages:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Document Serializer: 19.92%&lt;/li&gt;&lt;li&gt;Transform Serializer: 18.04%&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Small Messages:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Document Serializer: 24.54%&lt;/li&gt;&lt;li&gt; Transform Serializer: 18.36%&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;The &lt;a href="https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/Serializer.java"&gt;Serializer&lt;/a&gt; interface is now public, and a different implementation can be set on XMLCipher. Two implementations are provided in the code, &lt;a href="https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/DocumentSerializer.java"&gt;DocumentSerializer&lt;/a&gt; (the default algorithm) and &lt;a href="https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/TransformSerializer.java"&gt;TransformSerializer&lt;/a&gt;. If anyone is interested in running experiments of their own, the StreamSerializer algorithm is available &lt;a href="https://docs.google.com/leaf?id=0B5V34LIZViDgY2QzMDFlN2MtZjA0MS00MTc4LTliMjItNjU5Y2U1ZDMzNWM2&amp;amp;hl=en_US"&gt;here&lt;/a&gt;. The TransformSerializer implementation is not the default as it requires Xalan to work properly, and as this library is optional in Santuario 1.5.&lt;br /&gt;&lt;br /&gt;Do you have any suggestions on how this could be improved further? Clearly, the time it takes to deserialize a decrypted XML String into a DOM node still takes far longer than it should. A fully StAX approach for XML Security would surely offer much improved performance - this is under development and planned for next year.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6565587402320130849?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6565587402320130849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/improving-decryption-performance-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6565587402320130849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6565587402320130849'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/improving-decryption-performance-in.html' title='Improving decryption performance in Apache Santuario 1.5'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7331143927810183405</id><published>2011-10-04T05:39:00.000-07:00</published><updated>2011-10-04T05:39:29.463-07:00</updated><title type='text'>Apache WSS4J 1.6.3 released</title><content type='html'>Apache WSS4J 1.6.3 has been released. It can be downloaded &lt;a href="http://ws.apache.org/wss4j/download.html"&gt;here&lt;/a&gt; and the issues fixed are listed in the WSS4J &lt;a href="https://issues.apache.org/jira/browse/WSS/fixforversion/12317595"&gt;JIRA&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Probably the most significant part of this release is that WSS4J now fully supports the &lt;a href="http://docs.oasis-open.org/wss/v1.1/wss-v1.1-spec-os-KerberosTokenProfile.pdf"&gt;Kerberos Token Profile&lt;/a&gt; 1.1. In the previous release, support was added to retrieve a Kerberos token from a KDC, and insert it into the security header of a request, and then validate it accordingly on the receiving side. In WSS4J 1.6.3, support has been added to use the secret key associated with the Kerberos token to sign and encrypt the request, and to verify and decrypt on the receiving side. I am planning on writing a series of blog posts soon about how to use Kerberos with WSS4J and CXF. The forthcoming Apache CXF 2.4.3 release will have full WS-SecurityPolicy support for working with Kerberos, based on the work done in WSS4J 1.6.3.&lt;br /&gt;&lt;br /&gt;In addition to the Kerberos work, WSS4J 1.6.3 features an upgraded Opensaml dependency, as well as several bug fixes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7331143927810183405?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7331143927810183405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-wss4j-163-released.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7331143927810183405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7331143927810183405'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/10/apache-wss4j-163-released.html' title='Apache WSS4J 1.6.3 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6699014563822521955</id><published>2011-09-23T07:31:00.000-07:00</published><updated>2011-09-29T01:51:12.225-07:00</updated><title type='text'>Talend donates Security Token Service (STS) to Apache CXF</title><content type='html'>I am pleased to announce that &lt;a href="http://www.talend.com/index.php"&gt;Talend&lt;/a&gt; has &lt;a href="https://issues.apache.org/jira/browse/CXF-3811"&gt;donated&lt;/a&gt; a Security Token Service (STS) &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/services/sts/"&gt;implementation&lt;/a&gt; to Apache CXF, which will be part of the forthcoming 2.5 release. Since the 2.4.0 release, CXF ships with an STS framework (in the ws-security module), as well as a simple implementation of the framework in the examples. The STS that Talend has donated to the community is a sophisticated implementation of the STS framework that builds on top of CXF's existing mature security functionality.&lt;br /&gt;&lt;br /&gt;In future blog posts I will document the features of the STS and how to configure it, as well as walk through some system tests. Here are some of the features and standards that the new STS supports:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;WS-Trust 1.3/1.4&lt;/li&gt;&lt;li&gt; WS-SecurityPolicy1.3&lt;/li&gt;&lt;li&gt;Authentication Mechanisms for a RST:UsernameToken, SAML token (1.1/2.0), KerberosToken, X.509 Token.&lt;/li&gt;&lt;li&gt;Security Binding supported: Symmetric,Asymmetric, Transport&amp;nbsp;&lt;/li&gt;&lt;li&gt;Supports WS-Trust Issue/Validate and Cancel binding&amp;nbsp;&lt;/li&gt;&lt;li&gt;Can issue the following tokens:SAML 1.1/2.0Holder-Of-Key/Bearer, SecurityContextTokens, Custom Tokens.&lt;/li&gt;&lt;li&gt;Issued token can be encrypted&amp;nbsp;&lt;/li&gt;&lt;li&gt;Validate binding supports issuing a new token (token transformation).&lt;/li&gt;&lt;li&gt;Custom Validators can be implemented&amp;nbsp;&lt;/li&gt;&lt;li&gt;Creation of SAML tokens can be customized.&lt;/li&gt;&lt;li&gt;Advanced RST elements:KeyType (Public, Symmetric, Bearer), Entropy (Symmetric, Public) , OnBehalfOf, ActAs, Claims, SecondaryParameters&lt;/li&gt;&lt;li&gt;Pluggable claims handling and management&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6699014563822521955?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6699014563822521955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/09/talend-donate-security-token-service.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6699014563822521955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6699014563822521955'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/09/talend-donate-security-token-service.html' title='Talend donates Security Token Service (STS) to Apache CXF'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6023048718361346562</id><published>2011-09-19T03:01:00.000-07:00</published><updated>2011-09-19T03:01:22.030-07:00</updated><title type='text'>Specifying custom AlgorithmSuite policies in Apache CXF 2.4.3</title><content type='html'>When specifying a security binding via &lt;a href="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200802"&gt;WS-SecurityPolicy&lt;/a&gt;, it is possible to define the algorithm suite via the "sp:AlgorithmSuite" policy. WS-SecurityPolicy defines a number of standard AlgorithmSuite policies, which control various security properties like the maximum and minimum Symmetric and Asymmetric key lengths, the encryption/signature/digest algorithms to use, etc. An example policy is given below. For this policy, the minimum symmetric key length is 256 bits, and the encryption algorithm is AES256:&lt;br /&gt;&lt;br /&gt;&amp;lt;sp:AlgorithmSuite&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:Basic256 /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;lt;/sp:AlgorithmSuite&amp;gt;&lt;br /&gt;&lt;br /&gt;There are certain scenarios where a user might want to use a non-standard AlgorithmSuite. For example, the minimum Asymmetric Key Length for all standard AlgorithmSuites is 1024 bits. This requires that the JDK has unrestricted security policies installed. If it is not possible to install unresticted security policies, a user might decide that using 512 bits RSA keys is sufficient (this is not recommended).&lt;br /&gt;&lt;br /&gt;Apache CXF 2.4.3 provides &lt;a href="https://issues.apache.org/jira/browse/CXF-3705"&gt;support&lt;/a&gt; for specifying custom algorithm suites. A new &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/custom/AlgorithmSuiteLoader.java?view=markup"&gt;interface&lt;/a&gt; is defined to create an AlgorithmSuite object given a policy, with a default &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/custom/DefaultAlgorithmSuiteLoader.java?view=markup"&gt;implementation&lt;/a&gt; that supports the standard AlgorithmSuite policies. It is possible to create a new implementation of the AlgorithmSuiteLoader interface, and install it as a bus extension. For an example, there is a CXF system test that allows 512 bit asymmetric keys, with custom &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/RestrictedAlgorithmSuiteLoader.java?view=markup"&gt;AlgorithmSuiteLoader&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/RestrictedAlgorithmSuite.java?view=markup"&gt;AlgorithmSuite&lt;/a&gt; implementations. The custom AlgorithmSuiteLoader implementation is &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/wssec11/client/client_restricted.xml?view=markup"&gt;spring-loaded&lt;/a&gt;, and registers itself as a bus extension.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6023048718361346562?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6023048718361346562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/09/specifying-custom-algorithmsuite.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6023048718361346562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6023048718361346562'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/09/specifying-custom-algorithmsuite.html' title='Specifying custom AlgorithmSuite policies in Apache CXF 2.4.3'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-3529205380889563110</id><published>2011-09-12T05:44:00.000-07:00</published><updated>2011-09-12T05:44:23.920-07:00</updated><title type='text'>SAML SecurityPolicy enforcement in CXF 2.4.2</title><content type='html'>Apache CXF 2.4.2 was released &lt;a href="http://cxf.apache.org/apache-cxf-242-release-notes.html"&gt;recently&lt;/a&gt;. In this blog post I want to delve into how CXF 2.4.2 enforces WS-SecurityPolicy expressions relating to SAML Assertions on the inbound side.&lt;br /&gt;&lt;br /&gt;There are two policy expressions relating to SAML Assertions, the &lt;a href="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/v1.3/cd/ws-securitypolicy-1.3-spec-cs-01.html#_Toc212617830"&gt;SamlToken&lt;/a&gt; and &lt;a href="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/v1.3/cd/ws-securitypolicy-1.3-spec-cs-01.html#_Toc212617824"&gt;IssuedToken&lt;/a&gt; policy assertions. On the outbound side, the SamlToken expression will trigger a CallbackHandler to obtain a SAML Assertion to insert into the outbound security header, and the IssuedToken expression will use the STSClient to obtain a SAML Assertion from a Security Token Service (STS).&lt;br /&gt;&lt;br /&gt;On the inbound side, any SAML Assertion received as part of the security header will be parsed initially by WSS4J. If the assertion is signed, then the signature is verified. If the confirmation method of the Subject of the Assertion is "holder-of-key", then WSS4J will parse the Subject KeyInfo and extract whatever credentials it can find, i.e. secret key or an X509Certificate. If no credential is found (or understood), then the default behaviour is to throw an exception. If the confirmation method is "holder-of-key", then the default behaviour (which is configurable) is to enforce that the Assertion is signed. Finally, WSS4J verifies trust in a certificate that was used to sign the assertion.&lt;br /&gt;&lt;br /&gt;After WSS4J is done with validating a received SAML Assertion, CXF does some additional validation according to the configured security policy. For more information on any of the following terms (holder-of-key, sender-vouches, etc.), please consult the SAML Token Profile 1.1 &lt;a href="http://docs.oasis-open.org/wss/v1.1/wss-v1.1-spec-os-SAMLTokenProfile.pdf"&gt;specification&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) SamlToken policy&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If a &lt;a href="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/v1.3/cd/ws-securitypolicy-1.3-spec-cs-01.html#_Toc212617830"&gt;SamlToken&lt;/a&gt; policy is used, the version of the received Assertion (1.1 or 2.0) is checked against the policy, e.g. if &amp;lt;sp:WssSamlV20Token11 /&amp;gt; is configured in the SAMLToken policy then the received Assertion must be a SAML 2.0 Assertion. Two checks are then done on the received Assertion, depending on what the subject confirmation method is.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Holder-of-key: If the subject confirmation method is "holder-of-key", there must be some proof-of-possession of the key associated with the subject of the assertion. CXF will enforce that either the key was used to sign some portion of the SOAP request, or alternatively the subject credential of the SAML Assertion must match a client certificate credential when 2-way TLS is used.&lt;/li&gt;&lt;li&gt;Sender-Vouches: If the subject confirmation method is "sender-vouches", then CXF will enforce that the SAML Assertion and SOAP Body are signed by the same signature. Alternatively, it will check that 2-way TLS is used.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;2) IssuedToken Policy&lt;/b&gt;&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;If an &lt;a href="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/v1.3/cd/ws-securitypolicy-1.3-spec-cs-01.html#_Toc212617824"&gt;IssuedToken&lt;/a&gt; policy is used, then the receiver is expecting to get a SAML Assertion that is issued by a third-party security service. If the subject confirmation method of the Assertion is "holder-of-key", then it does the same check as described above for a SamlToken policy. Additionally, if a "&amp;lt;sp:RequestSecurityTokenTemplate..../&amp;gt;" policy is configured, it will attempt to match the received Assertion against the RSTTemplate parameters:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;TokenType: If a TokenType parameter is specified in the template, it will match this against the version of the received Assertion. For example, if the TokenType is "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1", then the Assertion must be a SAML 1.1 Assertion.&lt;/li&gt;&lt;li&gt;KeyType: If a KeyType parameter is specified in the template which ends with "SymmetricKey", then the subject of the Assertion must contain a secret key. If the KeyType parameter ends with "PublicKey", then the Subject must contain a Certificate or PublicKey.&lt;/li&gt;&lt;/ul&gt;Here is an example of a RequestSecurityTokenTemplate:&lt;br /&gt;&lt;br /&gt;&amp;lt;sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile1.1#SAMLV1.1&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/t:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;t:KeyType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/t:KeyType&amp;gt;&lt;br /&gt;&amp;lt;/sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;&lt;br /&gt;Issuer or IssuerName policies are not yet enforced, this will probably be done in a future version of CXF.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-3529205380889563110?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/3529205380889563110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/09/saml-securitypolicy-enforcement-in-cxf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3529205380889563110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3529205380889563110'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/09/saml-securitypolicy-enforcement-in-cxf.html' title='SAML SecurityPolicy enforcement in CXF 2.4.2'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-5086728509652201595</id><published>2011-08-18T06:21:00.000-07:00</published><updated>2011-08-18T06:21:11.247-07:00</updated><title type='text'>Apache WSS4J 1.5.12 and 1.6.2 released</title><content type='html'>Apache WSS4J 1.5.12 and 1.6.2 have been &lt;a href="http://ws.apache.org/wss4j/download.html"&gt;released&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;WSS4J 1.5.12 is a bug-fix release, which fixes some problems relating to future-dated Timestamps, fixes a bug with deriving keys from UsernameTokens, and fixes a concurrency issue with EnvelopeIdResolver, amongst other things.&lt;br /&gt;&lt;br /&gt;WSS4J 1.6.2 contains some enhancements for SAML Token creation, fixes a bug with deriving keys from UsernameTokens, adds initial support for the Kerberos Token Profile 1.1, and fixes some problems relating to signature verification in certain containers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-5086728509652201595?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/5086728509652201595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/08/apache-wss4j-1512-and-162-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5086728509652201595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5086728509652201595'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/08/apache-wss4j-1512-and-162-released.html' title='Apache WSS4J 1.5.12 and 1.6.2 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6105420456878307484</id><published>2011-08-16T11:10:00.000-07:00</published><updated>2011-08-16T11:10:13.390-07:00</updated><title type='text'>SAML token creation in Apache WSS4J 1.6</title><content type='html'>&lt;a href="http://ws.apache.org/wss4j/"&gt;WSS4J&lt;/a&gt; 1.6 uses &lt;a href="https://wiki.shibboleth.net/confluence/display/OpenSAML/Home"&gt;Opensaml2&lt;/a&gt; to create and parse SAML Assertions. WSS4J ships with a library that wraps the Opensaml API to greatly simplify the process of creating a SAML Assertion. The user implements a &lt;a href="http://download.oracle.com/javase/6/docs/api/javax/security/auth/callback/CallbackHandler.html"&gt;CallbackHandler&lt;/a&gt; instance which must be able to handle a WSS4J &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/SAMLCallback.java?view=markup"&gt;SAMLCallback&lt;/a&gt; object. and set certain properties on this object. WSS4J then parses the properties that were set on the object and creates a SAML Assertion accordingly. In this blog post we will examine the process of creating a SAML Assertion by populating a SAMLCallback object in more detail.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Obtain a SAMLCallback object&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;First off, a SAMLCallback object must be obtained in the CallbackHandler implementation, e.g.:&lt;br /&gt;&lt;br /&gt;if (callbacks[i] instanceof SAMLCallback) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAMLCallback callback = (SAMLCallback) callbacks[i];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Set the SAML Version&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The first thing to do is to set the desired SAML Version of the Assertion you want to create on the SAMLCallback object, e.g.:&lt;br /&gt;&lt;br /&gt;callback.setSamlVersion(SAMLVersion.VERSION_11);&lt;br /&gt;&lt;br /&gt;This method takes an org.opensaml.common.SAMLVersion object. For normal purposes, it will be one of the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;SAMLVersion.VERSION_11&lt;/li&gt;&lt;li&gt;SAMLVersion.VERSION_20 &lt;/li&gt;&lt;/ul&gt;The default value in SAMLCallback is VERSION_11.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) Set the Issuer&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The next thing to do is to set the issuer (String) name of the token, e.g.:&lt;br /&gt;&lt;br /&gt;callback.setIssuer("sts");&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) Set the Subject &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The next thing to do is to set the Subject of the Assertion. WSS4J defines a &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/SubjectBean.java?view=markup"&gt;SubjectBean&lt;/a&gt; which encapsulates a SAML Subject. The Subject Name, NameQualifier, NameIDFormat and ConfirmationMethod Strings can be set on the SubjectBean instance. The NameIDFormat and ConfirmationMethod values that can be set are largely defined in the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/builder/SAML1Constants.java?view=markup"&gt;SAML1Constants&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/builder/SAML2Constants.java?view=markup"&gt;SAML2Constants&lt;/a&gt; classes. The default value for the SubjectBean NameIDFormat is SAML1Constants.NAMEID_FORMAT_UNSPECIFIED. Both constants classes contain the following values that can be used for the ConfirmationMethod value:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&amp;nbsp;SAML[1|2]Constants.CONF_BEARER&lt;/li&gt;&lt;li&gt;&amp;nbsp;SAML[1|2]Constants.CONF_HOLDER_KEY&lt;/li&gt;&lt;li&gt;&amp;nbsp;SAML[1|2]Constants.CONF_SENDER_VOUCHES&lt;/li&gt;&lt;/ul&gt;In addition to this, WSS4J defines a &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/KeyInfoBean.java?view=markup"&gt;KeyInfoBean&lt;/a&gt; that can be set on the SubjectBean, which represents a KeyInfo structure that will be embedded in a SAML Subject. There are a number of different ways to set the KeyInfo value:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A DOM element can be defined for a pre-existing KeyInfo element&lt;/li&gt;&lt;li&gt;A PublicKey object can be used&lt;/li&gt;&lt;li&gt;An X.509 Certificate can be used&lt;/li&gt;&lt;/ul&gt;For the latter two cases, the KeyInfoBean contains a CERT_IDENTIFIER enum which defines how the PublicKey or X.509 Certificate will be output. The following values can be configured:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;X509_CERT: An X509Certificate element will be output&lt;/li&gt;&lt;li&gt; X509_ISSUER_SERIAL: An X509 IssuerSerial element will be output&lt;/li&gt;&lt;li&gt;KEY_VALUE: A KeyValue element will be output&lt;/li&gt;&lt;/ul&gt;The default value in the KeyInfoBean is X509_CERT. Here is a sample that shows how to create a SubjectBean:&lt;br /&gt;&lt;br /&gt;SubjectBean subjectBean = new SubjectBean();&lt;br /&gt;subjectBean.setSubjectName("uid=joe");&lt;br /&gt;subjectBean.setSubjectNameQualifier("apache.org");&lt;br /&gt;subjectBean.setSubjectConfirmationMethod(&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; SAML1Constants.CONF_SENDER_VOUCHES&lt;br /&gt;);&lt;br /&gt;KeyInfoBean keyInfo = new KeyInfoBean();&lt;br /&gt;keyInfo.setCertificate(cert);&lt;br /&gt;subjectBean.setKeyInfo(keyInfo);&lt;br /&gt;&lt;br /&gt;Finally, it remains to store the SubjectBean instance in the SAMLCallback object. A SAML 2.0 Assertion contains a single Subject, and so for this case the SubjectBean instance can be set directly on the SAMLCallback, e.g.:&lt;br /&gt;&lt;br /&gt;callback.setSubject(subjectBean);&lt;br /&gt;&lt;br /&gt;For a SAML 1.1 Assertion, the Subject can be in a SubjectStatement (in which case it can be set directly on the SAMLCallback), or it can be embedded in one of the other statements which we will cover next.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5) Create and set a Statement&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;WSS4J contains a number of beans to create Statements for SAML Assertions, that can be set on a SAMLCallback object. They can be used in either SAML 1.1 or SAML 2.0 Assertions, with the caveat that SubjectBean instances are not used with statements in SAML 2.0.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;a) Attribute Statements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;WSS4J contains an &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/AttributeStatementBean.java?view=markup"&gt;AttributeStatementBean&lt;/a&gt; for creating Attribute statements. This contains a SubjectBean (for the SAML 1.1 case), and a list of &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/AttributeBean.java?view=markup"&gt;AttributeBean&lt;/a&gt; objects. An attribute simple name, qualified name, and name format Strings can be set on the AttributeBean, as well as a list of attribute value Strings. Here is an example of creating and adding an AttributeStatement to a SAMLCallback object:&lt;br /&gt;&lt;br /&gt;AttributeStatementBean attrBean = new AttributeStatementBean();&lt;br /&gt;attrBean.setSubject(subjectBean);&lt;br /&gt;AttributeBean attributeBean = new AttributeBean();&lt;br /&gt;attributeBean.setSimpleName("role");&lt;br /&gt;attributeBean.setAttributeValues(Collections.singletonList("user"));&lt;br /&gt;attrBean.setSamlAttributes(Collections.singletonList(attributeBean));&lt;br /&gt;callback.setAttributeStatementData(Collections.singletonList(attrBean));&lt;br /&gt;&lt;br /&gt;&lt;b&gt;b) Authentication Statements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;WSS4J contains an &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/AuthenticationStatementBean.java?view=markup"&gt;AuthenticationStatementBean&lt;/a&gt; for creating Authentication statements. For SAML 1.1 a SubjectBean instance can be set on this object. In addition to this, an authentication instant and authentication method can be set, as well as a SubjectLocalityBean object and a session index String. Various authentication method Strings are defined in the SAML1Constants and SAML2Constants given above. Here is an example:&lt;br /&gt;&lt;br /&gt;AuthenticationStatementBean authBean = new AuthenticationStatementBean();&lt;br /&gt;authBean.setSubject(subjectBean);&lt;br /&gt;SubjectLocalityBean subjectLocality = new SubjectLocalityBean();&lt;br /&gt;subjectLocality.setIpAddress(subjectLocalityIpAddress);&lt;br /&gt;subjectLocality.setDnsAddress(subjectLocalityDnsAddress);&lt;br /&gt;authBean.setSubjectLocality(subjectLocality);&lt;br /&gt;authBean.setAuthenticationMethod("Password");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; callback.setAuthenticationStatementData(Collections.singletonList(authBean));&lt;br /&gt;&lt;br /&gt;&lt;b&gt;c) Authorization Decision Statements&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;WSS4J contains an &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/AuthDecisionStatementBean.java?view=markup"&gt;AuthDecisionStatementBean&lt;/a&gt; for creating Authorization Decision Statements. For SAML 1.1 a SubjectBean instance can be set on this object. A Decision enum can be set (PERMIT, INDETERMINATE, DENY), as well as a resource String, evidence Object, and a list of &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/ActionBean.java?view=markup"&gt;ActionBeans&lt;/a&gt;, which in turn contain an action namespace and action contents. Here is an example:&lt;br /&gt;&lt;br /&gt;AuthDecisionStatementBean authzBean = new AuthDecisionStatementBean();&lt;br /&gt;authzBean.setSubject(subjectBean);&lt;br /&gt;ActionBean actionBean = new ActionBean();&lt;br /&gt;actionBean.setContents("Read");&lt;br /&gt;authzBean.setActions(Collections.singletonList(actionBean));&lt;br /&gt;authzBean.setResource("endpoint");&lt;br /&gt;authzBean.setDecision(AuthDecisionStatementBean.Decision.PERMIT);&lt;br /&gt;authzBean.setResource(resource);&amp;nbsp; callback.setAuthDecisionStatementData(Collections.singletonList(authzBean));&lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;6) Create a Conditions object&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Finally, a &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_2/src/main/java/org/apache/ws/security/saml/ext/bean/ConditionsBean.java?view=markup"&gt;ConditionsBean&lt;/a&gt; object can be used to specify a set of Conditions on the SAML Assertion. This is optional, as by default a Conditions element will be generated with a NotBefore value of the present instant and a NotOnOrAfter value corresponding to 5 minutes into the future. This can be changed by creating a ConditionsBean and specifying either "notBefore" and "notAfter" dates, or else a token period in minutes in which the token is valid. It is also possible to specify an audience restriction URI on the ConditionsBean object. Here is an example:&lt;br /&gt;&lt;br /&gt;ConditionsBean conditions = new ConditionsBean();&lt;br /&gt;conditions.setTokenPeriodMinutes(10);&lt;br /&gt;conditions.setAudienceURI("http://ws.apache.org/wss4j");&lt;br /&gt;callback.setConditions(conditionsBean);&lt;br /&gt;&lt;br /&gt;For some examples of CallbackHandlers used to create SAML Assertions, check out the following CallbackHandlers used in the WSS4J unit tests - &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_0/src/test/java/org/apache/ws/security/common/SAML1AuthnHOKHandler.java?view=markup"&gt;SAML1AuthnHOKHandler&lt;/a&gt;, &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_0/src/test/java/org/apache/ws/security/common/SAML1CallbackHandler.java?view=markup"&gt;SAML1CallbackHandler&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_0/src/test/java/org/apache/ws/security/common/SAML2CallbackHandler.java?view=markup"&gt;SAML2CallbackHandler.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6105420456878307484?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6105420456878307484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/08/saml-token-creation-in-apache-wss4j-16.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6105420456878307484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6105420456878307484'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/08/saml-token-creation-in-apache-wss4j-16.html' title='SAML token creation in Apache WSS4J 1.6'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-5931510585593678023</id><published>2011-08-15T08:43:00.000-07:00</published><updated>2011-08-15T08:43:53.816-07:00</updated><title type='text'>WS-Trust 1.4 support in CXF</title><content type='html'>Apache CXF has had support for sending a WS-Trust 1.4 ActAs element as part of a RequestSecurityToken call to a Security Token Service (STS) since the 2.2.10 release. To quote from the WS-Trust 1.4 &lt;a href="http://docs.oasis-open.org/ws-sx/ws-trust/v1.4/ws-trust.html"&gt;specification&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;&lt;b&gt;&lt;span class="Italic"&gt;/wst:RequestSecurityToken/wst:ActAs&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class="Italic"&gt;&amp;nbsp;&lt;/span&gt;  &lt;br /&gt;&lt;div class="Definition"&gt;This OTPIONAL (sic) element indicates that the requested token is expected to contain information about the identity represented by the content of this element and the token requestor intends to use the returned token to act as this identity. The identity that the requestor wants to act-as is specified by placing a security token or &amp;lt;wsse:SecurityTokenReference&amp;gt; element within the &amp;lt;wst:ActAs&amp;gt; element.&lt;/div&gt;&lt;/blockquote&gt;The object to be placed in an ActAs element can be set by the &lt;a href="https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java"&gt;SecurityConstants&lt;/a&gt; tag "STS_TOKEN_ACT_AS" on the Message properties. Prior to Apache CXF 2.4.1 the ActAs object could either be an XML String or else a DOM Element. See the following CXF wiki &lt;a href="http://cxf.apache.org/docs/ws-trust.html"&gt;page&lt;/a&gt; for more information.&lt;br /&gt;&lt;br /&gt;Several enhancements were made in CXF 2.4.1 as part of this &lt;a href="https://issues.apache.org/jira/browse/CXF-3565"&gt;JIRA&lt;/a&gt;. First of all, support was added for OnBehalfOf. To quote from the spec again:&lt;br /&gt;&lt;blockquote&gt;&lt;div class="DefinedTerm"&gt;&lt;b&gt;&lt;span class="Italic"&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;/wst:RequestSecurityToken/wst:OnBehalfOf&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="DefinedTerm"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Definition"&gt;This OPTIONAL element indicates that the requestor is making the request on behalf of another.&amp;nbsp; The identity on whose behalf the request is being made is specified by placing a security token, &lt;span class="CodeEmbedded"&gt;&amp;lt;wsse:SecurityTokenReference&amp;gt;&lt;/span&gt; element, or &lt;span class="CodeEmbedded"&gt;&amp;lt;wsa:EndpointReference&amp;gt;&lt;/span&gt; element within the &lt;span class="CodeEmbedded"&gt;&amp;lt;wst:OnBehalfOf&amp;gt;&lt;/span&gt; element. The requestor MAY provide proof of possession of the key associated with the OnBehalfOf identity by including a signature in the RST security header generated using the OnBehalfOf token that signs the primary signature of the RST (i.e. endorsing supporting token concept from WS-SecurityPolicy). Additional signed supporting tokens describing the OnBehalfOf context MAY also be included within the RST security header.&lt;/div&gt;&lt;/blockquote&gt;The object to be placed in an OnBehalfOf element can be set by the &lt;a href="https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java"&gt;SecurityConstants&lt;/a&gt; tag "STS_TOKEN_ON_BEHALF_OF" on the Message properties. Similar to ActAs, this object can be an XML String or a DOM Element. In addition to this, the object for both ActAs and OnBehalfOf can now be a &lt;a href="http://download.oracle.com/javase/6/docs/api/javax/security/auth/callback/CallbackHandler.html"&gt;CallbackHandler&lt;/a&gt; instance. The CallbackHandler implementation must be able to process a &lt;a href="https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/delegation/DelegationCallback.java"&gt;DelegationCallback&lt;/a&gt; object, which has access to the current CXF Message, and returns a DOM Element to the STSClient for insertion into either ActAs or OnBehalfOf.&lt;br /&gt;&lt;br /&gt;Two sample CallbackHandler implementations are shipped with CXF 2.4.1 that can be used for either OnBehalfOf or ActAs. The &lt;a href="https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/delegation/ReceivedTokenCallbackHandler.java"&gt;ReceivedTokenCallbackHandler&lt;/a&gt; obtains the previously received message from the current message property of the DelegationCallback object, and extracts a token that has been received in that message (SAML Token/UsernameToken/BinarySecurityToken). This token is then used as the delegation token. This CallbackHandler implementation is useful as part of an WS-Trust intermediary scenario. Secondly, the &lt;a href="https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/delegation/WSSUsernameCallbackHandler.java"&gt;WSSUsernameCallbackHandler&lt;/a&gt; obtains a username via the jax-ws property "ws-security.username" (SecurityConstants.USERNAME), and creates a wsse:UsernameToken (with no password) to be used as the delegation token.&lt;br /&gt;&lt;pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-5931510585593678023?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/5931510585593678023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/08/ws-trust-14-support-in-cxf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5931510585593678023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5931510585593678023'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/08/ws-trust-14-support-in-cxf.html' title='WS-Trust 1.4 support in CXF'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7888234576425247301</id><published>2011-06-28T06:37:00.000-07:00</published><updated>2011-06-28T06:37:07.337-07:00</updated><title type='text'>Custom token validation in Apache CXF 2.4</title><content type='html'>A previous blog post has &lt;a href="http://coheigea.blogspot.com/2011/04/wss4j-16-introducing-validators.html"&gt;covered &lt;/a&gt;validators in Apache WSS4J 1.6, why they were introduced, what default implementations ship with WSS4J, etc. It ends with a paragraph on how to use a custom Validator implementation with Apache CXF 2.4. This post expands further on this topic.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Use-cases for custom Token Validation&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Let's consider first of all the use-cases for specifying a custom Validator implementation in CXF. When a security header is being processed by WSS4J, it delegates each security token to a &lt;a href="http://ws.apache.org/wss4j/apidocs/org/apache/ws/security/processor/Processor.html"&gt;Processor&lt;/a&gt; implementation, depending on the QName of the token. In WSS4J 1.6, Processors do not do any validation of extracted credentials from a token, they merely process it, make sure it meets basic requirements, etc. Validation is delegated to a &lt;a href="http://ws.apache.org/wss4j/apidocs/org/apache/ws/security/validate/Validator.html"&gt;Validator&lt;/a&gt; interface which is associated with that Processor implementation.&lt;br /&gt;&lt;br /&gt;However, there are many possible use-cases where a user may wish to replace or remove or extend the default validation behaviour associated with a particular security token. Some examples include:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Validating a UsernameToken, where the CallbackHandler implementation does not have access to the password.&lt;/li&gt;&lt;li&gt;Validating a BinarySecurityToken of some custom type.&lt;/li&gt;&lt;li&gt;Validating the attributes of a received SAML Assertion&lt;/li&gt;&lt;li&gt;Validating a Timestamp in a more tolerant manner than the default. &lt;/li&gt;&lt;li&gt;Dispatching a received security token to a third-party security service for validation/authentication.&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;2) Configuring custom Validators in CXF&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;The CXF &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?view=markup"&gt;SecurityConstants&lt;/a&gt; class (&lt;a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/ws/security/SecurityConstants.html"&gt;javadoc&lt;/a&gt;) defines some configuration items to override the default validators used to validate a received security token. The values associated with each configuration option must correspond to an implementation of the Validator interface. The configuration tags are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;"ws-security.ut.validator" - Override UsernameToken validation.&lt;/li&gt;&lt;li&gt;"ws-security.saml1.validator" - Override SAML1 token validation.&lt;/li&gt;&lt;li&gt;"ws-security.saml2.validator" - Override SAML2 token validation.&lt;/li&gt;&lt;li&gt;"ws-security.timestamp.validator" - Override Timestamp validation.&lt;/li&gt;&lt;li&gt;"ws-security.signature.validator" - Override trust verification on a signature&lt;/li&gt;&lt;li&gt;"ws-security.bst.validator" - Override BinarySecurityToken validation.&lt;/li&gt;&lt;/ol&gt;To disable the validation of a particular token, specify the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/NoOpValidator.java?view=markup"&gt;NoOpValidator&lt;/a&gt; as the value of the configuration tag corresponding to that token.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) Using Validators with WS-Trust&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To see the power and flexibility of the approach of separating processing from validation, consider the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSTokenValidator.java?view=markup"&gt;STSTokenValidator&lt;/a&gt; that ships with CXF 2.4. This validator implementation has the ability to dispatch a received BinarySecurityToken, UsernameToken, or SAML Assertion to an STS (Security Token Service) for validation via WS-Trust. On invocation, it delegates the credential to another validator (&lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSSamlAssertionValidator.java?view=markup"&gt;STSSamlAssertionValidator&lt;/a&gt;). This validator essentially catches an exception caused by a signature validation failure of the SAML Assertion and sets a flag. Only if signature validation is unsuccessful does the STSTokenValidator dispatch the token to the STS for validation.&lt;br /&gt;&lt;br /&gt;An example of how to configure the STSTokenValidator to validate a SAML1 Assertion against an STS in spring is as follows:&lt;br /&gt;&lt;br /&gt;&amp;lt;jaxws:endpoint ...&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.saml1.validator"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean class="org.apache.cxf.ws.security.trust.STSTokenValidator"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/entry&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.sts.client"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean class="org.apache.cxf.ws.security.trust.STSClient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg ref="cxf"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="wsdlLocation" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="serviceName" value=".../&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="endpointName" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/entry&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;lt;/jaxws:endpoint&amp;gt;&lt;br /&gt;&lt;br /&gt;The STSTokenValidator also has the ability to obtain a transformed token from the STS and store it in the credential, where it is available as part of the WSSecurityEngineResult under the TAG_TRANSFORMED_TOKEN tag.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7888234576425247301?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7888234576425247301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/06/custom-token-validation-in-apache-cxf.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7888234576425247301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7888234576425247301'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/06/custom-token-validation-in-apache-cxf.html' title='Custom token validation in Apache CXF 2.4'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-1921205163566933664</id><published>2011-06-10T14:05:00.000-07:00</published><updated>2011-06-10T14:05:43.119-07:00</updated><title type='text'>WS-SecurityPolicy/SAML sample in Talend Service Factory 2.4.0</title><content type='html'>In this post I will walk through the WS-SecurityPolicy sample that ships with Talend Service Factory 2.4.0. This sample shows how to secure a web service provider using both a UsernameToken and a SAML Assertion. For this post I will concentrate exclusively on the SAML case.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Download the artifacts&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Go &lt;a href="http://www.talend.com/download.php#SF"&gt;here&lt;/a&gt; and download Talend Service Factory 2.4.0. When this is done, go &lt;a href="http://www.talend.com/resources/documentation.php#SF"&gt;here&lt;/a&gt;  and download the Talend Service Factory 2.4.0 examples (registration  required). Extract the examples into the Talend Service Factory (TSF)  install directory ($TSF_HOME). Finally, this sample requires that unlimited strength security policies be installed in the JDK.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Build and run the sample&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Go  to $TSF_HOME/examples/jaxws-ws-secpol and start with the README.txt. Run  "mvn eclipse:eclipse" to generate eclipse projects, and "mvn install"  to build and install the various modules. There are two options to run the sample.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.1) Run the sample using maven&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To start the service go to the service folder, and run "mvn exec:java". To run the test then go to the client folder and also run "mvn exec:java".&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.2) Run the sample in Karaf&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To deploy the service and run the client in an OSGi environment, we can take advantage of the Karaf distribution that ships with TSF. Go to $TSF_HOME/container/bin and run the "karaf" binary. Install the three bundles in Karaf with:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;install mvn:com.talend.sf.examples.jaxws-ws-secpol/ws-secpol-common/1.0&lt;/li&gt;&lt;li&gt;install mvn:com.talend.sf.examples.jaxws-ws-secpol/ws-secpol-server/1.0&lt;/li&gt;&lt;li&gt;install mvn:com.talend.sf.examples.jaxws-ws-secpol/ws-secpol-client/1.0&lt;/li&gt;&lt;/ul&gt;Each of these commands will print out a bundle id. Run the sample by invoking "start &amp;lt;id&amp;gt;" for each of the three bundle ids in turn.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) &lt;/b&gt;&lt;b&gt;The Service Provider&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.1) The Security Policy&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The Service endpoint is secured via the following security policy fragment, which is defined in the WSDL ("ws-secpol-wsdl/greeter.wsdl" in the common folder):&lt;br /&gt;&lt;br /&gt;&amp;lt;wsp:All&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;sp:AsymmetricBinding xmlns:sp=".../ws-securitypolicy/200702"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:InitiatorToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:X509Token sp:IncludeToken=".../AlwaysToRecipient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:RequireThumbprintReference /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssX509V3Token10 /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:X509Token&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:InitiatorToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:RecipientToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;sp:X509Token sp:IncludeToken=".../Never"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:RequireThumbprintReference /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssX509V3Token10 /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:X509Token&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:RecipientToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/sp:AsymmetricBinding&amp;gt;&lt;br /&gt;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp; &amp;lt;sp:SignedSupportingTokens&amp;nbsp;xmlns:sp=".../ws-securitypolicy/200702"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:SamlToken&amp;nbsp;sp:IncludeToken=".../AlwaysToRecipient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssSamlV20Token11/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:SamlToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/sp:SignedSupportingTokens&amp;gt;&lt;br /&gt;&amp;lt;/wsp:All&amp;gt;&lt;br /&gt;&lt;br /&gt;This Security Policy defines that the Asymmetric Binding is to be used  in communication with the service provider, i.e. that the client must sign the  request using its private key, and include the corresponding X509  Certificate in the security header of the request, and encrypt the  request using the public key of the service provider. Authentication is performed on  the basis of trust verification of the client's certificate, as the  client illustrates proof-of-possession by signing some part of the  request.&lt;br /&gt;&lt;br /&gt;In addition to the Asymmetric Binding, the policy requires that a SAML 2.0 Assertion must be included in the service request, and it must be signed by the signature defined by the Asymmetric Binding policy. The (policy-driven) ability to add a SAML Assertion to a SOAP Request is new to Apache CXF 2.4.&lt;br /&gt;&lt;br /&gt;Finally, the WSDL defines input and output policies (not included here), which specify that the SOAP Body must be signed and encrypted, and that all of the addressing headers must be signed if present. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.2) The configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The standalone (maven-driven) case is configured entirely in code. The various security configuration items are added as properties to the JAX-WS Endpoint object. The same security configuration items are also used for the case of deploying the service provider in Karaf, except that it is all driven through spring, e.g.:&lt;br /&gt;&lt;br /&gt;&amp;lt;jaxws:server id="SAMLGreeter"&amp;nbsp;xmlns:ns1="..."&lt;br /&gt;&amp;nbsp; endpointName="ns1:SAMLGreeterPort"&lt;br /&gt;&amp;nbsp; serviceClass="demo.secure_greeter.server.GreeterImpl"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.callback-handler" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.encryption.properties" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.signature.properties" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.saml2.validator" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:server&amp;gt;&lt;br /&gt;&lt;br /&gt;Four security-related configuration options are used for the service provider. "ws-security.callback-handler" points to a CallbackHandler implementation that is used to supply a password for extracting a private key from a keystore to decrypt the request and sign the response. "ws-security.encryption.properties" refers to a properties file which contains configuration options for loading the keystore used for encryption. Similarly, "ws-security.signature.properties" refers to a properties file for signature creation (and decryption).&lt;br /&gt;&lt;br /&gt;"ws-security.saml2.validator" is a configuration tag new to CXF 2.4, and refers to an instance of the WSS4J &lt;a href="http://ws.apache.org/wss4j/apidocs/org/apache/ws/security/validate/Validator.html"&gt;Validator&lt;/a&gt; interface. The Validator interface is used in WSS4J to validate received security tokens. In this case, we are extending the default SAML2 Token Validation with a custom Validator. This Validator does some additional verification on the received token, namely checking who the issuer is, checking that the confirmation method is "sender-vouches", and checking that the Assertion contains an AttributeStatement, with an Attribute "attribute-role" containing a value "authenticated-client".&lt;br /&gt;&lt;br /&gt;All of these configuration tags are defined in the &lt;a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/ws/security/SecurityConstants.html"&gt;SecurityConstants&lt;/a&gt; class in CXF.&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) The client&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When the client wants to invoke on the service provider, it parses the  security policy described above in the WSDL. As with the service provider, the client standalone case is configured entirely in code. For the case of deploying the client in Karaf, it is configured in spring as follows:&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;jaxws:client id="samlgreeter" wsdlLocation="..." serviceClass="..."&lt;br /&gt;&amp;nbsp; xmlns:ns1="" serviceName="ns1:SecureGreeterService"&lt;br /&gt;&amp;nbsp; endpointName="ns1:SAMLGreeterPort"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.signature.username" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.encryption.username" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.callback-handler"&amp;gt;&amp;lt;bean class="..."/&amp;gt;&amp;lt;/entry&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.signature.properties" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.encryption.properties" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.saml-callback-handler" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:client&amp;gt;&lt;br /&gt;&lt;br /&gt;"ws-security.callback-handler", "ws-security.signature.properties" and "ws-security.encryption.properties" have been covered in the section on configuring the service provider. "ws-security.signature.username" refers to the keystore alias of the private key to use to sign the request, and "ws-security.encryption.username" refers to the keystore alias to use to encrypt the request.&lt;br /&gt;&lt;br /&gt;"ws-security.saml-callback-handler" is a configuration tag new to CXF 2.4, and refers to a CallbackHandler which will supply WSS4J with the information to create a SAML Assertion. This sample ships with a CallbackHandler that creates a simple SAML 2.0 Assertion with a subject confirmation method of "sender-vouches". It adds an Attribute to the Assertion that conveys to the Web Service Provider that the client has authenticated an external user in some way (not shown as part of this sample), and has assigned the attribute role of "authenticated-client" to the external user. The assertion that will be generated from this CallbackHandler instance will be signed by the client, as per the policy definition ("SignedSupportingTokens").&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5) The Client Request&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The security header of the client request contains a BinarySecurityToken which contains the certificate to use to verify the signature. It also contains a Timestamp, an EncryptedKey which is used to encrypt the SOAP Body, a SAML2 Assertion, and a Signature which signs the Timestamp, Assertion and encrypted SOAP Body. The Assertion looks like this:&lt;br /&gt;&lt;br /&gt;&amp;lt;saml2:Assertion xmlns:saml2="..." xmlns:xsi="..." ID="..." IssueInstant="..."&lt;br /&gt;&amp;nbsp; Version="2.0" xsi:type="saml2:AssertionType"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;saml2:Issuer&amp;gt;...&amp;lt;/saml2:Issuer&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;saml2:Subject&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:NameID Format=...:unspecified"&amp;gt;uid=auth_client&amp;lt;/saml2:NameID&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:SubjectConfirmation Method="...:sender-vouches"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:SubjectConfirmationData/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:SubjectConfirmation&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;/saml2:Subject&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;saml2:Conditions NotBefore="..." NotOnOrAfter="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;saml2:AttributeStatement&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:Attribute FriendlyName="attribute-role" NameFormat="..."&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:AttributeValue xsi:type="xs:string"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authenticated-client&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:AttributeValue&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:Attribute&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;/saml2:AttributeStatement&amp;gt;&lt;br /&gt;&amp;lt;/saml2:Assertion&amp;gt;&lt;br /&gt;&lt;br /&gt;The service provider processes the received security header as follows:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;It checks that the Timestamp is valid&lt;/li&gt;&lt;li&gt;It uses its private key to decrypt the EncryptedKey, and then uses the decrypted key to decrypt the SOAP Body.&lt;/li&gt;&lt;li&gt;It verifies that the Assertion is valid, and passes the Assertion to the custom Validator defined above to validate the contents of the Assertion.&lt;/li&gt;&lt;li&gt;It verifies that the certificate defined in the BinarySecurityToken can validate the signature, verifies trust in the certificate, and checks that each of the References of the signature produce the correct digest.&lt;/li&gt;&lt;/ol&gt;At this point security processing is complete, and the service provider constructs a secured response to the client.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-1921205163566933664?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/1921205163566933664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/06/ws-securitypolicysaml-sample-in-talend.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1921205163566933664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1921205163566933664'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/06/ws-securitypolicysaml-sample-in-talend.html' title='WS-SecurityPolicy/SAML sample in Talend Service Factory 2.4.0'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-4390277251940964219</id><published>2011-06-08T06:11:00.000-07:00</published><updated>2011-06-08T06:11:46.448-07:00</updated><title type='text'>WSS4J 1.6.1 released</title><content type='html'>Apache WSS4J 1.6.1 has been released. The distribution can be downloaded &lt;a href="http://ws.apache.org/wss4j/download.html"&gt;here&lt;/a&gt;, and the list of issues that have been fixed is &lt;a href="https://issues.apache.org/jira/browse/WSS/fixforversion/12316163"&gt;here.&lt;/a&gt; There are a number of bug fixes to the new functionality introduced in the 1.6.0 release, including some fixes to the SAML Assertion creation code, and a fix to get WSS4J 1.6 working with the IBM JDK. A noteworthy new feature is support for CRLs, as documented by a previous blog &lt;a href="http://coheigea.blogspot.com/2011/05/crl-support-in-wss4j-161.html"&gt;post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In other news, my &lt;a href="http://www.talend.com/index.php"&gt;employer&lt;/a&gt; has published a short &lt;a href="http://www.surveymonkey.com/s/ApacheLearning"&gt;questionnaire&lt;/a&gt; to find out what topics users of open-source integration software are interested in learning about. So for example if you are interested in hearing more from me on enabling security in Apache CXF, navigate to the CXF part of the &lt;a href="http://www.surveymonkey.com/s/ApacheLearning"&gt;survey&lt;/a&gt; and select the appropriate checkbox for "WS-Security in Apache CXF".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-4390277251940964219?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/4390277251940964219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/06/wss4j-161-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4390277251940964219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4390277251940964219'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/06/wss4j-161-released.html' title='WSS4J 1.6.1 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-5899668917202158008</id><published>2011-05-30T07:12:00.000-07:00</published><updated>2011-05-31T03:12:02.676-07:00</updated><title type='text'>CRL support in WSS4J 1.6.1</title><content type='html'>Support for Certificate Revocation Lists (CRLs) has been a long sought feature in WSS4J, and will arrive in the imminent release of WSS4J 1.6.1. This will ensure that the certificate used to validate a signature is not revoked by the issuing Certificate Authority.&lt;br /&gt;&lt;br /&gt;Support for CRLs is covered by the task &lt;a href="https://issues.apache.org/jira/browse/WSS-278"&gt;WSS-278&lt;/a&gt;. The default behaviour is that certificate revocation is &lt;i&gt;not&lt;/i&gt; enabled for backwards compatibility reasons. Two parameters must be configured to enable certificate revocation. The first is that the &lt;a href="http://ws.apache.org/wss4j/apidocs/org/apache/ws/security/handler/WSHandlerConstants.html"&gt;WSHandlerConstants&lt;/a&gt; property "enableRevocation" must be set to "true", if WSS4J is being used in the context of WSHandler. If the handler architecture is not being used, then a new method has been added to the &lt;a href="http://ws.apache.org/wss4j/apidocs/org/apache/ws/security/components/crypto/Crypto.html"&gt;Crypto&lt;/a&gt; interface for signature trust validation which explicitly enables certificate revocation:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; public boolean verifyTrust(X509Certificate[] certs, boolean enableRevocation) throws WSSecurityException;&lt;/li&gt;&lt;/ul&gt;The previous verifyTrust(certs) method has been deprecated. Please bear in mind that any custom Crypto implementation must be updated with the new method, or else you will face a compilation error on upgrading to WSS4J 1.6.1.&lt;br /&gt;&lt;br /&gt;The second is that the &lt;a href="http://ws.apache.org/wss4j/apidocs/org/apache/ws/security/components/crypto/Crypto.html"&gt;Crypto&lt;/a&gt; instance that is used must be supplied with CRL information. This can be done in a number of different ways. The default Crypto instance that ships with WSS4J (Merlin), has a new configuration property:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.x509crl.file: The location of an (X509) CRL file to be loaded via CertificateFactory.generateCRL(...).&lt;/li&gt;&lt;/ul&gt;Merlin also has two new accessor methods to set/get a CertStore object to be used for CRL checking (i.e. setCRLCertStore(CertStore crlCertStore)), if you wish to supply CRL information programatically to the Crypto instance.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update&lt;/b&gt;: You can see a test for this feature &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureCRLTest.java?view=markup"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-5899668917202158008?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/5899668917202158008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/05/crl-support-in-wss4j-161.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5899668917202158008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5899668917202158008'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/05/crl-support-in-wss4j-161.html' title='CRL support in WSS4J 1.6.1'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-3340531973622238591</id><published>2011-05-27T06:53:00.000-07:00</published><updated>2011-05-27T11:34:05.591-07:00</updated><title type='text'>Apache XML Security for Java 1.4.5 released</title><content type='html'>Apache XML Security for Java 1.4.5 has been &lt;a href="http://thread.gmane.org/gmane.text.xml.security.devel/7413"&gt;released&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;The Apache Santuario team are pleased to announce the release of&lt;br /&gt;version 1.4.5 of the Apache XML Security for Java library. This&lt;br /&gt;release fixes a thread safety issue in the ResourceResolver, and a&lt;br /&gt;regression in signature generation for the Canonical XML 1.1&lt;br /&gt;algorithm, as well as a number of other bug fixes.&lt;br /&gt;&lt;br /&gt;Please see the release notes for more information:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://issues.apache.org/jira/browse/SANTUARIO/fixforversion/12315957" target="_blank"&gt;https://issues.apache.org/&lt;wbr&gt;&lt;/wbr&gt;jira/browse/SANTUARIO/&lt;wbr&gt;&lt;/wbr&gt;fixforversion/12315957&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can download the library here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://santuario.apache.org/download.html" target="_blank"&gt;http://santuario.apache.org/&lt;wbr&gt;&lt;/wbr&gt;download.html&lt;/a&gt; &lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-3340531973622238591?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/3340531973622238591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/05/apache-xml-security-for-java-145.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3340531973622238591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3340531973622238591'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/05/apache-xml-security-for-java-145.html' title='Apache XML Security for Java 1.4.5 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-1382507264242952471</id><published>2011-05-18T10:36:00.000-07:00</published><updated>2011-05-18T10:36:58.489-07:00</updated><title type='text'>Talend ESB Standard Edition released</title><content type='html'>Last week the Talend ESB Standard Edition was &lt;a href="http://www.talend.com/press/Talend-Introduces-Industry-s-First-Unified-Platform-for-Data-Services-with-New-ESB-Offering.php"&gt;released&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;A core component of the unified platform for  data services, Talend ESB  includes messaging, Web services, mediation and  adapters in an open and  standards-based offering used to integrate distributed  systems across  functional, enterprise and/or geographic boundaries. Powered by leading Apache open source integration  projects Apache CXF,  Apache Camel and Apache ActiveMQ, Talend ESB is a  versatile and  flexible ESB that allows organizations to address any integration   challenge, from simple departmental projects to complex, heterogeneous  IT  environments.&lt;/blockquote&gt;Of particular interest to readers of this blog might be the Security Token Service (STS) framework which ships as part of Talend ESB. More on this in a future blog post.&lt;br /&gt;&lt;br /&gt;To download Talend ESB Standard Edition go &lt;a href="http://www.talend.com/download_form.php?cont=esb&amp;amp;src=ResourcePage"&gt;here&lt;/a&gt;. For more information, see the datasheet &lt;a href="http://www.talend.com/datasheets/DS-Talend-ESB-SE-EN.pdf"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In other Talend-related news, Talend is now a &lt;a href="http://www.businesswire.com/news/home/20110512005200/en/Talend-Sponsor-Apache-Software-Foundation"&gt;sponsor&lt;/a&gt; of the Apache Software Foundation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-1382507264242952471?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/1382507264242952471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/05/talend-esb-standard-edition-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1382507264242952471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1382507264242952471'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/05/talend-esb-standard-edition-released.html' title='Talend ESB Standard Edition released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-5700888984713250260</id><published>2011-05-11T09:18:00.000-07:00</published><updated>2011-05-11T09:18:29.484-07:00</updated><title type='text'>WS-Trust sample in Talend Service Factory 2.4.0</title><content type='html'>In this post I will walk through the WS-Trust sample that ships with Talend Service Factory 2.4.0.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Download the artifacts&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Go &lt;a href="http://www.talend.com/download.php#SF"&gt;here&lt;/a&gt; and download Talend Service Factory 2.4.0. When this is done, go &lt;a href="http://www.talend.com/resources/documentation.php#SF"&gt;here&lt;/a&gt; and download the Talend Service Factory 2.4.0 examples (registration required). Extract the examples into the Talend Service Factory (TSF) install directory ($TSF_HOME).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Build and run the sample&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Go to $TSF_HOME/examples/jaxws-ws-trust and start with the README.txt. Run "mvn eclipse:eclipse" to generate eclipse projects, and "mvn install" to build and install the various modules. &lt;br /&gt;&lt;br /&gt;Both the CXF service provider and Metro STS used in this sample are deployed in Tomcat. To see how to configure Maven to install/uninstall these artifacts in Tomcat follow the instructions &lt;a href="http://www.jroller.com/gmazza/entry/web_service_tutorial#maventomcat"&gt;here&lt;/a&gt;. Finally, you need to make sure that the path to the keystores is correct for the Metro STS - follow the instructions in the README.txt for this.&lt;br /&gt;&lt;br /&gt;Start Tomcat, and from the sts-war folder run "mvn install tomcat:deploy". Run the same command from the service-war folder to deploy the CXF service provider in Tomcat. &lt;br /&gt;&lt;br /&gt;Finally to run the test, go to the client folder and run "mvn install exec:exec". You also have the option of running the client in Karaf (follow the instructions in the README.txt).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) The sample&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Three service invocations take place as part of this sample. For simplicity, I'll just concentrate on the third one, which shows how a SAML2 Assertion is used in a WS-Trust scenario.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.1) The Service Provider&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We'll start with the Service Provider, as the client will use the security policies defined in the WSDL of the Service Provider to access the STS. The Service is spring-loaded via the following configuration:&lt;br /&gt;&lt;br /&gt;&amp;lt;jaxws:endpoint id="doubleitsaml2"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implementor="service.DoubleItPortTypeImpl"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address="/doubleitsaml2" &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endpointName="DoubleItPortSAML2"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wsdlLocation="WEB-INF/wsdl/DoubleIt.wsdl"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.callback-handler" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.signature.properties" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.is-bsp-compliant" value="false"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:endpoint&amp;gt; &lt;br /&gt;&lt;br /&gt;Three properties are required for the endpoint. The CallbackHandler implementation is required to provider the password used to access the private key in the Keystore, which is in turn configured in the "ws-security.signature.properties" file. The "ws-security.is-bsp-compliant" configuration turns off Basic Security Profile 1.1 compliance enforcement. This is required as the Metro STS generates a non BSP-compliant SAML Assertion (try removing this line, redeploying the service provider in tomcat and see what happens when the test is re-run).&lt;br /&gt;&lt;br /&gt;The WSDL (DoubleIt.wsdl) contains the security policies for the service provider. It requires that the input and output SOAP Body elements must be signed and encrypted, and that all of the addressing headers must be signed in both directions. It also contains the following policy snippet:&lt;br /&gt;&lt;br /&gt;&amp;lt;sp:SymmetricBinding&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:ProtectionToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:IssuedToken  sp:IncludeToken="...AlwaysToRecipient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:TokenType&amp;gt;...#SAMLV2.0&amp;lt;/t:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:KeyType&amp;gt;.../SymmetricKey&amp;lt;/t:KeyType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:KeySize&amp;gt;256&amp;lt;/t:KeySize&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:RequestSecurityTokenTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:Issuer&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsaw:Address&amp;gt;http://.../DoubleItSTSServiceUT&amp;lt;/wsaw:Address&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsaw:Metadata&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsaw:Metadata&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:Issuer&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:IssuedToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:ProtectionToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;lt;/sp:SymmetricBinding&amp;gt;&lt;br /&gt;&lt;br /&gt;This SecurityPolicy snippet defines that the communication with the service provider is secured via the SymmetricBinding, i.e. that it is secured via a secret key. The ProtectionToken policy describes how the secret key in turn is conveyed to the service provider in a secure way. In this example, it defines an IssuedToken policy, which is always sent to the recipient (service provider). Once the client sees this policy, it will know that it must contact a Security Token Service (STS) via the WS-Trust protocol to obtain a (issued) token that will convey the symmetric key to the service provider.&lt;br /&gt;&lt;br /&gt;The IssuedToken policy has a RequestSecurityTokenTemplate policy, which the client will copy verbatim when contacting the STS for a security token. It describes the token type that is required (a SAML2 Assertion), the KeyType conveyed in the Assertion (Symmetric Key), and the size of the symmetric key (256 bits). It also contains an Issuer policy which describes how the STS may be contacted via a wsa EndpointReferenceType.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.2) The Security Token Service (STS)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The STS used in this sample is the &lt;a href="http://metro.java.net/"&gt;Metro&lt;/a&gt; STS. The port is secured with the following security policy binding:&lt;br /&gt;&lt;br /&gt;&amp;lt;sp:AsymmetricBinding&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;sp:InitiatorToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;sp:X509Token sp:IncludeToken=".../AlwaysToRecipient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssX509V3Token10 /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:X509Token&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:InitiatorToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:RecipientToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:X509Token sp:IncludeToken=".../Never"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssX509V3Token10 /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:RequireIssuerSerialReference /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:X509Token&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:RecipientToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;lt;/sp:AsymmetricBinding&amp;gt;&lt;br /&gt;&lt;br /&gt;This Security Policy defines that the Asymmetric Binding is to be used in communication with the STS, i.e. that the client must sign the request using its private key, and include the corresponding X509 Certificate in the security header of the request, and encrypt the request using the public key of the STS. Authentication is performed on the basis of trust verification of the client's certificate, as the client illustrates proof-of-possession by signing some part of the request.&lt;br /&gt;&lt;br /&gt;The WSDL of the STS also contains a "STSConfiguration" policy fragment, which defines that the issued key is encrypted, and lists the service provider endpoints, including the corresponding public keys.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.3) The client&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When the client wants to invoke on the service provider, it parses the security policy described above in the WSDL, and sees that it must first obtain an IssuedToken from a STS before it can construct the service request. The client is configured in spring as follows:&lt;br /&gt;&lt;br /&gt;&amp;lt;jaxws:client name="{...}DoubleItPortSAML2" createdFromAPI="true"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.sts.client"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean class="org.apache.cxf.ws.security.trust.STSClient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg ref="cxf"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="wsdlLocation" value="DoubleItSTSService.wsdl"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="serviceName" value="{...}DoubleItSTSService"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="endpointName" value="{...}IDoubleItSTS..Port"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="properties"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;map&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.signature.username" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.callback-handler" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.signature.properties" value="..."/&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.encryption.properties" value="..."/&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.encryption.username" value="..."/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/map&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/entry&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;br /&gt;&amp;lt;/jaxws:client&amp;gt;&lt;br /&gt;&lt;br /&gt;The STSClient bean contains the configuration required to contact the STS. The client parses the WSDL of the STS, and uses the supplied configuration parameters to construct a request that is secured by the Asymmetric Binding, as discussed above. This request is done via the WS-Trust protocol.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.4) The STS request&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In the SOAP Body of the request is the following information (decrypted):&lt;br /&gt;&lt;br /&gt;&amp;lt;wst:RequestSecurityToken&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;wst:SecondaryParameters&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:TokenType&amp;gt;...#SAMLV2.0&amp;lt;/t:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:KeyType&amp;gt;.../SymmetricKey&amp;lt;/t:KeyType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:KeySize&amp;gt;256&amp;lt;/t:KeySize&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/wst:SecondaryParameters&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;wst:RequestType&amp;gt;.../Issue&amp;lt;/wst:RequestType&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;wsp:AppliesTo&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsa:EndpointReference&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; ... &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsa:EndpointReference&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/wsp:AppliesTo&amp;gt;&lt;br /&gt;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp; &amp;lt;wst:Entropy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wst:BinarySecret Type=".../Nonce"&amp;gt;...&amp;lt;/wst:BinarySecret&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/wst:Entropy&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;wst:ComputedKeyAlgorithm&amp;gt;.../CK/PSHA1&amp;lt;/wst:ComputedKeyAlgorithm&amp;gt;&amp;lt;/wst:RequestSecurityToken&amp;gt;&lt;br /&gt;&lt;br /&gt;The SecondaryParameters element is copied verbatim from the RequestSecurityTokenTemplate defined in the policy of the service provider. The RequestType element defines an "Issue" URI. AppliesTo refers to the address of the service provider. Entropy contains some client-generated entropy (which the STS will combine with its own Entropy to form a symmetric key), using the ComputedKeyAlgorithm URI.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.5) The STS response&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The response from the STS contains the following (decrypted) SOAP Body. It contains the token type of the requested token, the token itself, different ways of referring to the requested token, some entropy that the client can use to recreate the symmetric key, the lifetime of the requested token, etc:&lt;br /&gt;&lt;br /&gt;&amp;lt;trust:RequestSecurityTokenResponseCollection&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;trust:RequestSecurityTokenResponse&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:TokenType&amp;gt;...#SAMLV2.0&amp;lt;/trust:TokenType&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:RequestedSecurityToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:Assertion&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:Assertion&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/trust:RequestedSecurityToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:RequestedAttachedReference&amp;gt;...&amp;lt;/trust:RequestedAttachedReference&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:RequestedUnattachedReference&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/trust:RequestedUnattachedReference&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:AppliesTo...&amp;gt;...&amp;lt;/wsp:AppliesTo&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:RequestedProofToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:ComputedKey&amp;gt;.../CK/PSHA1&amp;lt;/trust:ComputedKey&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/trust:RequestedProofToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:Entropy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:BinarySecret Type=".../Nonce"&amp;gt;...&amp;lt;/trust:BinarySecret&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/trust:Entropy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:Lifetime&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsu:Created...&amp;gt;...&amp;lt;/wsu:Created&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsu:Expires...&amp;gt;...&amp;lt;/wsu:Expires&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/trust:Lifetime&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;trust:KeySize&amp;gt;256&amp;lt;/trust:KeySize&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/trust:RequestSecurityTokenResponse&amp;gt;&lt;br /&gt;&amp;lt;/trust:RequestSecurityTokenResponseCollection&amp;gt;&lt;br /&gt;&lt;br /&gt;The requested security token that is returned above is reproduced here. Note that the SubjectConfirmation Method is "holder-of-key", meaning that the client must illustrate proof of possession of the key contained in the EncryptedKey element of the Assertion. The EncryptedKey element is encrypted using the service provider's public key.&lt;br /&gt;&lt;br /&gt;&amp;lt;saml2:Assertion ID="..." IssueInstant="..." Version="2.0"&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;saml2:Issuer&amp;gt;DoubleItSTSIssuer&amp;lt;/saml2:Issuer&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;ds:Signature&amp;gt;...&amp;lt;/ds:Signature&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;saml2:Subject&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:NameID NameQualifier="..."&amp;gt;...&amp;lt;/saml2:NameID&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:SubjectConfirmation Method="...:cm:holder-of-key"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:SubjectConfirmationData&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ... &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xenc:EncryptedKey&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ... &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xenc:EncryptedKey&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ... &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:SubjectConfirmationData&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:SubjectConfirmation&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;/saml2:Subject&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;saml2:Conditions NotBefore="..." NotOnOrAfter="..."&amp;gt;&amp;lt;/saml2:Conditions&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;saml2:AttributeStatement&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:Attribute...&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:AttributeValue&amp;gt;authenticated&amp;lt;/saml2:AttributeValue&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:Attribute&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;/saml2:AttributeStatement&amp;gt;&lt;br /&gt;&amp;lt;/saml2:Assertion&amp;gt; &lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.5) The Service Provider request&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Once the client receives the Issued Token from the STS, it recreates the symmetric key needed to communicate with the service provider, by combining the entropy received from the STS with its own entropy to form the session key. The (decrypted) SAML2 Assertion is inserted into the security header "as is". The symmetric key is referenced in the request via the following structure:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&amp;lt;ds:KeyInfo Id="..."&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;wsse:SecurityTokenReference&amp;nbsp; wsse11:TokenType="...#SAMLV2.0" &amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsse:KeyIdentifier ValueType="...#SAMLID"&amp;gt;...&amp;lt;/wsse:KeyIdentifier&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/wsse:SecurityTokenReference&amp;gt;&lt;br /&gt;&amp;lt;/ds:KeyInfo&amp;gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;The Service Provider verifies the signature of the STS on the SAML Assertion, and then decrypts the EncryptedKey fragment using its private key, to obtain the symmetric key used to decrypt/verify the client request. As the confirmation method is "holder-of-key", the Service Provider ensures that the same key was used to sign some portion of the request, thus proving that the client is in possession of the key.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-5700888984713250260?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/5700888984713250260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/05/ws-trust-sample-in-talend-service.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5700888984713250260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5700888984713250260'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/05/ws-trust-sample-in-talend-service.html' title='WS-Trust sample in Talend Service Factory 2.4.0'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6177217306155432219</id><published>2011-04-29T07:36:00.000-07:00</published><updated>2011-04-29T07:36:47.899-07:00</updated><title type='text'>Talend Service Factory 2.4.0 released</title><content type='html'>&lt;a href="http://www.talend.com/products-application-integration/talend-service-factory-community-edition.php"&gt;Talend Service Factory&lt;/a&gt; 2.4.0 has been &lt;a href="http://www.talend.com/download.php#SF"&gt;released&lt;/a&gt;. It's based on Apache CXF 2.4.0, and so contains all of the security features in WSS4J 1.6.0, as well as the extensive support for SAML Assertions in CXF 2.4.0, that I have been blogging about for the last while.&lt;br /&gt;&lt;br /&gt;In addition to this, some examples are available for &lt;a href="http://www.talend.com/resources/documentation.php#SF"&gt;download&lt;/a&gt;, which illustrate how to get these (security) features working in an OSGi container. A lot of work has gone into making sure that security libraries such as Apache Santuario, Apache WSS4J and Opensaml can be used in an OSGi environment, so I recommend checking the examples out to see how it can be done. &lt;br /&gt;&lt;br /&gt;See Glen's &lt;a href="http://www.jroller.com/gmazza/entry/tsf_ws_security_samples"&gt;blog &lt;/a&gt;for more information on the security examples. Also, see Sergey's &lt;a href="http://sberyozkin.blogspot.com/2011/04/transform-feature-demonstrated-in.html"&gt;blog&lt;/a&gt; for a discussion on some other examples based around transforming XML.&lt;br /&gt;&lt;a href="http://sberyozkin.blogspot.com/2011/04/transform-feature-demonstrated-in.html"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6177217306155432219?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6177217306155432219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/04/talend-service-factory-240-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6177217306155432219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6177217306155432219'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/04/talend-service-factory-240-released.html' title='Talend Service Factory 2.4.0 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-5754327822906390059</id><published>2011-04-21T04:28:00.000-07:00</published><updated>2011-05-06T07:02:02.024-07:00</updated><title type='text'>SAML support in CXF 2.4.0</title><content type='html'>The recent Apache CXF 2.4.0 &lt;a href="http://coheigea.blogspot.com/2011/04/cxf-240-released.html"&gt;release&lt;/a&gt; contains support for creating, securing, processing and validating SAML Assertions according to the WS-Security 1.1 SAML Token &lt;a href="http://www.oasis-open.org/committees/download.php/16768/wss-v1.1-spec-os-SAMLTokenProfile.pdf"&gt;Profile&lt;/a&gt;. As there is no documentation available as yet on this new feature, in this blog post I will go through a SAML system test in CXF 2.4.0 in detail. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Running the Test&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To run the SAML system test you can do the following:&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;svn co https://svn.apache.org/repos/asf/cxf/tags/cxf-2.4.0/systests/ws-security&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;cd ws-security&lt;br /&gt;mvn compile &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;mvn test -Dtest=SamlTokenTest&lt;/div&gt;&lt;br /&gt;&lt;b&gt;2) The Client&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.1) The Client code&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You can view the source of the tests &lt;a href="http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.0/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java?view=markup"&gt;here&lt;/a&gt;. There are a number of tests involving creating SAML 1.1 and 2.0 assertions, and sending them to a service provider over various security bindings (Transport/Symmetric/Asymmetric). To simplify things, we will focus on the fourth test named "testSaml2OverAsymmetric". Minus some negative tests, the basic test client invocation code is as simple as:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;SpringBusFactory bf = new SpringBusFactory();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;URL busFile = SamlTokenTest.class.getResource("client/client.xml");&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Bus bus = bf.createBus(busFile.toString());&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;SpringBusFactory.setDefaultBus(bus);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;SpringBusFactory.setThreadDefaultBus(bus);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;DoubleItService service = new DoubleItService();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;DoubleItPortType saml2Port = service.getDoubleItSaml2AsymmetricPort();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;((BindingProvider)saml2Port).getRequestContext().put(&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;"ws-security.saml-callback-handler", new SamlCallbackHandler()&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;BigInteger result = saml2Port.doubleIt(BigInteger.valueOf(25));&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;assert result.equals(BigInteger.valueOf(50));&lt;/div&gt;&lt;br /&gt;&lt;b&gt;2.2) The WSDL&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The service is described in the WSDL &lt;a href="http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.0/systests/ws-security/src/test/resources/wsdl_systest_wssec/saml/DoubleItSaml.wsdl?view=markup"&gt;here&lt;/a&gt;. Take a look at the WS-SecurityPolicy called "DoubleItSaml2AsymmetricPolicy", which defines the security requirements for the "DoubleItSaml2AsymmetricPort". It defines an Asymmetric Binding, where the InitiatorToken (which defines the credential used to sign the request) is always sent to the recipient, and the RecipientToken (which defines the credential used to encrypt the request) is never sent to the recipient. Both Initiator and Recipient tokens are defined as X509 tokens. The input and output policies in the WSDL enforce that the SOAP Body must be signed using the Initiator credential, and encrypted using the Recipient credential.&lt;br /&gt;&lt;br /&gt;In addition to specifying an asymmetric binding, the policy also defines a SignedSupportingToken, which contains a SAML (2.0) Token which is always sent to the recipient. In order to successfully invoke on the service, the client must include a SAML 2.0 token in the security header of the request. This policy looks like:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;lt;sp:SignedSupportingTokens&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:SamlToken sp:IncludeToken="...AlwaysToRecipient"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sp:WssSamlV20Token11/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sp:SamlToken&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsp:Policy&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;lt;/sp:SignedSupportingTokens&amp;gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;2.3) The Client configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.0/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/client/client.xml?view=markup"&gt;client.xml&lt;/a&gt; referenced in the code block above contains a jaxws:client configuration for the DoubleItSaml2AsymmetricPort. It sets the following relevant jaxws:properties:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;ws-security.encryption.properties - The Crypto properties file which describes where to find the service provider's public key.&lt;/li&gt;&lt;li&gt;ws-security.encryption.username -&amp;nbsp;  The alias to use to obtain the  service provider's public key from the keystore reference in the Crypto  properties file above. &lt;/li&gt;&lt;li&gt;ws-security.callback-handler - A CallbackHandler object which is expected to supply the password used to access the private key for signature creation, or decryption.&lt;/li&gt;&lt;li&gt;ws-security.signature.properties - The Crypto properties file which describes where to find the client's public/private key.&lt;/li&gt;&lt;li&gt;ws-security.signature.username - The alias to use to obtain the client's private key from the keystore reference in the Crypto properties file above. &lt;/li&gt;&lt;/ol&gt;&lt;b&gt;2.3) Creating a SAML token&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;CXF 2.4.0 defines a new jaxws:property ("ws-security-saml-callback-handler") which specifies a CallbackHandler instance used to create SAML Assertions. This object is added to the outbound request context above dynamically, however it could also have been configured in the spring bean along with the other ws-security parameters. The CallbackHandler object used in this test can be seen &lt;a href="http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.0/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/client/SamlCallbackHandler.java?view=markup"&gt;here&lt;/a&gt;. The CallbackHandler implementation is expected to obtain a &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/tags/1_6_0/src/main/java/org/apache/ws/security/saml/ext/SAMLCallback.java?view=markup"&gt;SAMLCallback&lt;/a&gt; object, and to set the appropriate values on this object, e.g. SAML version, Subject, issuer, Authentication/Authorization/Attribute Statements, etc. In the example provided in this test, it creates a SAML 2.0 assertion (by default), sets a mock issuer, subject and attribute statement, and sets a subject confirmation method of sender-vouches. Some code in WSS4J then constructs a SAML Assertion by processing this SAMLCallback object. It's easy to construct a SAML Assertion in this way, as the following (edited) code shows:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;SAMLCallback callback = (SAMLCallback) callbacks[i];&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;callback.setSamlVersion(SAMLVersion.VERSION_20);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;callback.setIssuer("sts");&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;String subjectName = "uid=sts-client,o=mock-sts.com";&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;String subjectQualifier = "www.mock-sts.com";&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;SubjectBean subjectBean = new SubjectBean(subjectName, subjectQualifier, SAML2Constants.CONF_SENDER_VOUCHES);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;callback.setSubject(subjectBean);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;AttributeStatementBean attrBean = new AttributeStatementBean();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;attrBean.setSubject(subjectBean);&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;AttributeBean attributeBean = new AttributeBean();&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;attributeBean.setSimpleName("subject-role");&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;attributeBean.setAttributeValues(Collections.singletonList("system-user"));&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;attrBean.setSamlAttributes(Collections.singletonList(attributeBean));&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;callback.setAttributeStatementData(Collections.singletonList(attrBean));&lt;/div&gt;&lt;br /&gt;&lt;b&gt;2.4) The service request&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The service request has a security header that contains the following elements:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;A BinarySecurityToken which consists of the X509Certificate of the client.&lt;/li&gt;&lt;li&gt;A Timestamp.&lt;/li&gt;&lt;li&gt;An EncryptedKey which consists of a symmetric key encrypted with the public key of the service provider, which is used to encrypt the SOAP Body.&lt;/li&gt;&lt;li&gt;A SAML2 Assertion.&lt;/li&gt;&lt;li&gt;A SecurityTokenReference to the SAML Assertion.&lt;/li&gt;&lt;li&gt;A signature which signs the Timestamp, the SAML Assertion (via the SecurityTokenReference) and the (decrypted) SOAP body. The signing credential is the BinarySecurityToken element described above.&lt;/li&gt;&lt;/ol&gt;The SAML 2.0 assertion looks like (edited):&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;lt;saml2:Assertion ... Version="2.0"&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:Issuer&amp;gt;sts&amp;lt;/saml2:Issuer&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:Subject&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:NameID ...&amp;gt;uid=sts-client,o=mocksts.com&amp;lt;/saml2:NameID&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:SubjectConfirmation Method="...:sender-vouches"&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:SubjectConfirmation&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:Subject&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:Conditions NotBefore="..." NotOnOrAfter="..."/&amp;gt; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:AttributeStatement&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saml2:Attribute FriendlyName="subject-role" ...&amp;gt; &lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;saml2:AttributeValue...&amp;gt;system-user&amp;lt;/saml2:AttributeValue&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:Attribute&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/saml2:AttributeStatement&amp;gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;lt;/saml2:Assertion&amp;gt;&lt;/div&gt;&lt;br /&gt;One thing to note is that as the SAML Assertion has a subject confirmation method of "sender-vouches", the client will automatically add the quality-of-service requirement that the signature which covers the SOAP Body will also cover the SAML Assertion. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) The Server&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.1) The Server code&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The SEI implementation is &lt;a href="http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.0/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/server/DoubleItImpl.java?view=markup"&gt;here&lt;/a&gt;, and the Server code itself is &lt;a href="http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.0/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/server/Server.java?view=markup"&gt;here&lt;/a&gt;.&amp;nbsp; The configuration is entirely driven through the WSDL and spring configuration, and so the code is as trivial as (edited):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;URL busFile = Server.class.getResource("server.xml");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Bus busLocal = new SpringBusFactory().createBus(busFile);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;BusFactory.setDefaultBus(busLocal);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;setBus(busLocal);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;new Server();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3.2) The Server configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The server.xml configuration file referenced above can be seen &lt;a href="http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.0/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/server/server.xml?view=markup"&gt;here&lt;/a&gt;. The jaxws:Endpoint configuration for this port should be self-explanatory (edited):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;lt;jaxws:endpoint &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="Saml2TokenOverAsymmetric"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address="http://localhost:9001/DoubleItSaml2Asymmetric" &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; serviceName="s:DoubleItService"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endpointName="s:DoubleItSaml2AsymmetricPort"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:s="http://WSSec/saml"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implementor="org.apache.cxf.systest.ws.saml.server.DoubleItImpl"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wsdlLocation="wsdl_systest_wssec/saml/DoubleItSaml.wsdl"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.username" value="bob"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.callback-handler" &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="....KeystorePasswordCallback"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.signature.properties" &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="...bob.properties"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.encryption.properties" &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="...alice.properties"/&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key="ws-security.encryption.username" value="alice"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;lt;/jaxws:endpoint&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The server will process the request as per the security policy in the WSDL, checking that there is a signature in the security header, that covers the SOAP Body and SAML Assertion, that the SOAP Body is Encrypted, that a Timestamp is present and valid, and that the SAML Assertion is present, and is the correct version, etc. Authentication is done on the basis of trust verification of the client's X509Certificate, which was used to verify the signature element.&lt;br /&gt;&lt;br /&gt;The SAML Assertion is ignored beyond this point for this system test. It is saved in the security processing results, so that a custom interceptor can do some additional validation or processing on it. In a future blog post, I will describe how to validate the Assertion that has been received in some custom manner.&lt;br /&gt;&lt;pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-5754327822906390059?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/5754327822906390059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/04/saml-support-in-cxf-240.html#comment-form' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5754327822906390059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5754327822906390059'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/04/saml-support-in-cxf-240.html' title='SAML support in CXF 2.4.0'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-8316677224565009850</id><published>2011-04-20T07:27:00.000-07:00</published><updated>2011-04-20T07:27:58.415-07:00</updated><title type='text'>CXF 2.4.0 released</title><content type='html'>Apache CXF 2.4.0 has been &lt;a href="http://mail-archives.apache.org/mod_mbox/cxf-users/201104.mbox/%3C201104181017.07780.dkulp@apache.org%3E"&gt;released&lt;/a&gt;. CXF 2.4.0 contains a number of new and improved features in the security space. From the release statement:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;WS-Security improvements including support for SAML2 tokens, improved &lt;br /&gt;validation of security tokens, better performance, increased WS-I Basic &lt;br /&gt;Security Profile compliance, and much more.&lt;/pre&gt;&lt;/blockquote&gt;If those new features seem familiar, it's because most of the new functionality is driven by WSS4J 1.6.0, which I've blogged extensively about over the last few months. Probably the most significant new security functionality in CXF 2.4.0 is greatly enhanced support for SAML Assertions. CXF 2.4.0 supports the ability to create, secure, process and validate SAML Assertions in accordance with the WS-Security 1.1 SAML Token Profile. I intend to blog in more detail how to use these new features in CXF 2.4.0 over the next while.&lt;br /&gt;&lt;br /&gt;See Dan Kulp's blog for more in-depth &lt;a href="http://www.dankulp.com/blog/?p=295"&gt;thoughts&lt;/a&gt; on the new release.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-8316677224565009850?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/8316677224565009850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/04/cxf-240-released.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8316677224565009850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8316677224565009850'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/04/cxf-240-released.html' title='CXF 2.4.0 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-9135335319356868886</id><published>2011-04-15T04:28:00.000-07:00</published><updated>2011-04-15T04:29:02.961-07:00</updated><title type='text'>WSS4J 1.6.0 released</title><content type='html'>WSS4J 1.6.0 has been &lt;a href="http://markmail.org/message/rm475sz3noj3oszl"&gt;released&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;The Apache Web Services team is pleased to announce the release of WSS4J 1.6.0. WSS4J 1.6.0 features support for SAML2 assertions, JSR-105 support, better spec compliance, performance work, support for trust-stores and a lot more besides. It is not API-compatible with the 1.5.x series of releases. &lt;/blockquote&gt;&lt;blockquote&gt;For more information on the new features and changes in WSS4J 1.6.0 go to: &lt;/blockquote&gt;&lt;blockquote&gt;&lt;a class="exlink mklink" href="http://ws.apache.org/wss4j/wss4j16.html" rel="nofollow"&gt;http://ws.apache.org/wss4j/wss4j16.html&lt;/a&gt; &lt;/blockquote&gt;&lt;blockquote&gt;To download WSS4J 1.6.0 go to: &lt;/blockquote&gt;&lt;blockquote&gt;&lt;a class="exlink mklink" href="http://ws.apache.org/wss4j/download.html" rel="nofollow"&gt;http://ws.apache.org/wss4j/download.html&lt;/a&gt;&lt;/blockquote&gt;&lt;blockquote&gt;-- The Apache Web Services Team  &lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-9135335319356868886?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/9135335319356868886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/04/wss4j-160-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/9135335319356868886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/9135335319356868886'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/04/wss4j-160-released.html' title='WSS4J 1.6.0 released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-5973919012400979082</id><published>2011-04-05T05:18:00.000-07:00</published><updated>2011-04-05T05:21:11.619-07:00</updated><title type='text'>[WSS4J 1.6] Introducing Validators</title><content type='html'>WSS4J 1.6 introduces the concept of a Validator, for validating credentials that have been processed by a Processor instance. This task was covered by the JIRA &lt;a href="https://issues.apache.org/jira/browse/WSS-266"&gt;WSS-266&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;An inbound security header is processed by WSS4J by iterating  through each child element of the header, and by calling the appropriate Processor implementation to deal with each element. In WSS4J 1.5.x, some processors perform validation on the received token (e.g. UsernameTokens), whereas others store the processing results for later verification by third-party WS-Handler implementations (e.g. Timestamp verification, Certificate trust verification). There are some problems with this approach:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It is not consistent, some processors perform validation, others do not.&lt;/li&gt;&lt;li&gt;There is a potential security hole, in that it is assumed third-party code will know to validate the credentials that the WSS4J processors do not validate.&lt;/li&gt;&lt;li&gt;WSS4J will  continue to process the rest of the security header even if the  Timestamp is invalid, or the certificate non-trusted, which could lead  to denial-of-service attacks. &lt;/li&gt;&lt;li&gt;There is no separation of concerns between processing the token and validating the token. If you want to change how the token is validated, you must replace the processor instance.&lt;/li&gt;&lt;/ul&gt;WSS4J 1.6 has moved Timestamp verification and certificate trust validation back into the processing of the security header, thus solving the first three points above. The fourth point is met by the new concept of Validators, as well as some changes to the way Processors and CallbackHandler implementations are used in WSS4J 1.6.&lt;br /&gt;&lt;br /&gt;In WSS4J 1.5.x, CallbackHandler implementations are used in different ways by different processors, sometimes they are expected to verify a password (as for processing UsernameTokens), and other times they are expected to supply a password (as for decryption). In WSS4J 1.6, CallbackHandler implementations are only expected to supply a password (if it exists) to the processors. The Processor implementations do not perform any validation of the security token, instead they package up the processed token, along with any (password) information extracted from the CallbackHandler, and hand it off to a Validator implementation for Validation.&lt;br /&gt;&lt;br /&gt;The Processor implementations get the specific Validator implementation to use via the RequestData parameter, which in turn asks a WSSConfig object for the Validator implementation. If the Validator is null, then no Validation is performed on the received token. The Processor then stores the received token as normal. WSS4J 1.6 comes with several default Validators, which are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;NoOpValidator: Does no processing of the credential&lt;/li&gt;&lt;li&gt;TimestampValidator: Validates a Timestamp&lt;/li&gt;&lt;li&gt;UsernameTokenValidator: Validates a UsernameToken&lt;/li&gt;&lt;li&gt;SignatureTrustValidator: Verifies trust in a signature&lt;/li&gt;&lt;li&gt;SamlAssertionValidator: Checks some HOK requirements on a SAML Assertion, and verifies trust on the (enveloped) signature.&lt;/li&gt;&lt;/ul&gt;There are some additional WSSecurityEngineResult constants that pertain to the Validator implementations:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; TAG_VALIDATED_TOKEN: Indicates that the token corresponding to this result has been validated by a Validator implementation. Some of the processors do not have a default Validator implementation.&lt;/li&gt;&lt;li&gt;TAG_TRANSFORMED_TOKEN: A Validator implementation may transform a credential (into a SAML Assertion) as a result of Validation. This tag holds a reference to an AssertionWrapper instance, that represents a transformed version of the validated credential.&lt;/li&gt;&lt;/ul&gt;To validate an inbound UsernameToken in some custom way, simply  associate the NoOpValidator with the UsernameToken QName in the  WSSConfig of the RequestData object used to supply context information  to the processors. After WSS4J has finished processing the security  header, then extract the WSSecurityEngineResult instance corresponding to  the WSConstants.UT action, and perform some custom validation on the  token.&lt;br /&gt;&lt;br /&gt;An example of how to add a custom Validator implementation is the &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSTokenValidator.java?view=markup"&gt;STSTokenValidator&lt;/a&gt; in CXF 2.4.0. The STSTokenValidator tries to validate a received SAML Assertion locally, and if that fails, it dispatches it to a Security Token Service (STS) via the WS-Trust interface for validation. It also supports validating a UsernameToken and BinarySecurityToken in the same manner. The &lt;a href="http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?view=markup"&gt;SecurityConstants&lt;/a&gt; class defines some configuration tags for specifying a custom validator for inbound SAML1, SAML2, UsernameToken, BinarySecurityToken, Signature and Timestamps. The STSTokenValidator can be configured by associating it with the appropriate configuration tag.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-5973919012400979082?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/5973919012400979082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/04/wss4j-16-introducing-validators.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5973919012400979082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5973919012400979082'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/04/wss4j-16-introducing-validators.html' title='[WSS4J 1.6] Introducing Validators'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-1579986626029567569</id><published>2011-03-13T08:02:00.000-07:00</published><updated>2011-03-13T08:02:12.624-07:00</updated><title type='text'>[WSS4J 1.6] SAML property changes</title><content type='html'>A previous blog &lt;a href="http://coheigea.blogspot.com/2011/02/support-for-saml2-assertions-in-wss4j.html"&gt;entry&lt;/a&gt; described how WSS4J 1.6 will have support for creating, parsing, signing, verifying, etc. SAML 2 assertions. WSS4J 1.5.x had limited support for creating and signing SAML 1.1 assertions via the default SAMLIssuer implementation, combined with a properties file. These configuration values consisted of:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.saml.issuerClass - The SAML Issuer implementation (defaults to "org.apache.ws.security.saml.SAMLIssuerImpl").&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.cryptoProp.file - The crypto properties file corresponding to the issuer crypto instance, if the assertion is to be signed.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.key.name - The KeyStore alias for the issuer key.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.key.password - The KeyStore password for the issuer key.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer - The issuer name&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.sendKeyValue - Whether to send the key value or the X509Certificate. Defaults to: "false".&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.subjectNameId.name - The Subject DN.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.subjectNameId.qualifier - The Subject qualifier.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.authenticationMethod - The authentication method (e.g. "password").&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.confirmationMethod - The confirmation method, either "senderVouches" or "keyHolder".&lt;/li&gt;&lt;/ul&gt;The configuration tags for WSS4J 1.5.x completely controlled the  creation and signing of a SAML 1.1 Assertion, and hence produced only a  very limited set of possible assertions.&amp;nbsp; WSS4J 1.6 takes a different approach, where the configuration tags correspond to the configuration of the issuer, i.e. whether to sign the assertion or not, the issuer name, crypto instance, etc. All instructions about how to create the SAML Assertion itself, are left to a CallbackHandler implementation.&lt;br /&gt;&lt;br /&gt;The following configuration tags in WSS4J 1.6 are exactly the same as in WSS4J 1.5.x:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.saml.issuerClass - The SAML Issuer implementation  (defaults to "org.apache.ws.security.saml.SAMLIssuerImpl").&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.cryptoProp.file - The crypto  properties file corresponding to the issuer crypto instance, if the  assertion is to be signed.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.key.name - The KeyStore alias for the issuer key.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.key.password - The KeyStore password for the issuer key.&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer - The issuer name&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.sendKeyValue - Whether to send the key value or the X509Certificate. Defaults to: "false". &lt;/li&gt;&lt;/ul&gt;The following configuration tags are new to WSS4J 1.6:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.saml.issuer.signAssertion - Whether the SAMLIssuer implementation will sign the assertion or not. Defaults to: "false".&lt;/li&gt;&lt;li&gt;org.apache.ws.security.saml.callback - The name of the SAML CallbackHandler implementation used to populate the SAML Assertion. &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-1579986626029567569?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/1579986626029567569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-saml-property-changes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1579986626029567569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1579986626029567569'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-saml-property-changes.html' title='[WSS4J 1.6] SAML property changes'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6721747080439245007</id><published>2011-03-08T05:44:00.000-08:00</published><updated>2011-03-08T05:44:56.122-08:00</updated><title type='text'>[WSS4J 1.6] Basic Security Profile 1.1 compliance</title><content type='html'>The Basic Security Profile (BSP) 1.1 &lt;a href="http://www.ws-i.org/Profiles/BasicSecurityProfile-1.1.html"&gt;specification&lt;/a&gt; provides an industry-standard way of making sure that different WS-Security stacks can communicate with each other, by clarifying and narrowing the scope of the various WS-Security standards. WSS4J 1.5.x does not implement the BSP in any meaningful way. The &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/WSSConfig.java?view=markup"&gt;WSSConfig&lt;/a&gt; class supports a "isWsiBSPCompliant" method (default is false), which will enable the generation of an InclusivePrefix list for signature generation, something that is mandated by the BSP spec.&lt;br /&gt;&lt;br /&gt;WSS4J 1.6 provides &lt;a href="https://issues.apache.org/jira/browse/WSS-256"&gt;support&lt;/a&gt; for the BSP 1.1 specification, in so far as it pertains to the core WS-Security specifications that WSS4J supports. The enforcing of BSP compliance for inbound messages is controlled by the WSSConfig class, as per WSS4J 1.5.x. An important change is that BSP compliance is now turned &lt;b&gt;on &lt;/b&gt;by default. In addition, a new &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/handler/WSHandlerConstants.java?view=markup"&gt;WSHandlerConstants&lt;/a&gt; configuration parameter has been added so that BSP compliance can be controlled via a WSHandler implementation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6721747080439245007?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6721747080439245007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-basic-security-profile-11.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6721747080439245007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6721747080439245007'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-basic-security-profile-11.html' title='[WSS4J 1.6] Basic Security Profile 1.1 compliance'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-6078385175392687906</id><published>2011-03-07T09:30:00.000-08:00</published><updated>2011-03-07T09:30:18.557-08:00</updated><title type='text'>[WSS4J 1.6] JSR-105 support</title><content type='html'>The soon-to-be released WSS4J 1.6 has been ported to use the &lt;a href="http://jcp.org/en/jsr/detail?id=105"&gt;JSR 105&lt;/a&gt;  API for XML Digital Signature. Previously, WSS4J 1.5.x used the custom API of the Apache &lt;a href="http://santuario.apache.org/"&gt;Santuario&lt;/a&gt; XML Security for Java library to create and process XML Digital Signatures.&lt;br /&gt;&lt;br /&gt;WSS4J 1.6 has a minimum requirement of JDK 1.5 (note that WSS4J 1.5.x supports JDK 1.4). As JDK 1.5 does not contain an implementation of JSR 105, this means that XML Digital Signature is done via the JSR 105 implementation of Apache Santuario. However, when JDK 1.6+ is used, WSS4J 1.6 uses the JDK implementation of JSR 105 for signature creation and verification. You can override this by endorsing the Santuario jar.&lt;br /&gt;&lt;br /&gt;The Apache Santuario XML Security jar is still required for the JDK 1.6 case, as there are compile-time dependencies in WSS4J for encryption/decryption, as well as for some algorithm parsing, and resource resolver stuff. One downside to the Santuario jar, is its dependence on Xalan for a small subset of operations. This dependency will be &lt;a href="https://issues.apache.org/jira/browse/SANTUARIO-252"&gt;removed&lt;/a&gt; for the 1.5 release of that library (in a few months).&lt;br /&gt;&lt;br /&gt;It is worth noting some changes to the main &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecSignature.java?view=markup"&gt;class&lt;/a&gt; used in WSS4J for signature creation as a result of the JSR-105 port. In WSS4J 1.5.x, after the signature certs and list of references to sign had been configured, the "computeSignature" method was called to compute the signature. The DOM element corresponding to the signature was independent of the pre-existing security header, and could be extracted later and inserted into the security header.&lt;br /&gt;&lt;br /&gt;In WSS4J 1.6, you must tell "computeSignature" where to insert the signature element. A boolean "prepend" argument allows you to configure whether to prepend the generated Signature element to the security header, or whether to append it. If prepend is true, then an optional siblingElement argument can be used to prepend the signature element before this sibling element. Once computeSignature has been called, you have no control over where the signature element is inserted into the security header.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-6078385175392687906?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/6078385175392687906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-jsr-105-support.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6078385175392687906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/6078385175392687906'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-jsr-105-support.html' title='[WSS4J 1.6] JSR-105 support'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-861471723565450330</id><published>2011-03-01T03:28:00.000-08:00</published><updated>2011-03-01T03:30:29.041-08:00</updated><title type='text'>[WSS4J 1.6] Beta release</title><content type='html'>Following the &lt;a href="http://mail-archives.apache.org/mod_mbox/ws-users/201102.mbox/%3CAANLkTinox17xef-GnxDTPE0j_GRAKwXwHiOzVyuPMG_q@mail.gmail.com%3E"&gt;announcement&lt;/a&gt; of an (unofficial) alpha release of WSS4J 1.6 a few weeks back, I'm pleased to &lt;a href="http://mail-archives.apache.org/mod_mbox/ws-users/201102.mbox/%3CAANLkTi=kiHCPMR9GyNQJioT95y-PMA9D3piBhSV9Przx@mail.gmail.com%3E"&gt;announce&lt;/a&gt; that a beta release of WSS4J 1.6 has been created:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;I have created an "unofficial" WSS4J 1.6-beta release. Please download&lt;br /&gt;and play around with it etc. As it is a beta release, it is *not*&lt;br /&gt;suitable for production in any way, and the APIs are subject to&lt;br /&gt;change. The distribution is available here:&lt;br /&gt;&lt;br /&gt;http://people.apache.org/~coheigea/stage/wss4j/1.6.0-beta/dist/&lt;br /&gt;&lt;br /&gt;and the Maven artifacts are available here:&lt;br /&gt;&lt;br /&gt;http://people.apache.org/~coheigea/stage/wss4j/1.6.0-beta/maven/&lt;br /&gt;&lt;br /&gt;Only three JIRAs are currently open against 1.6.0:&lt;br /&gt;&lt;br /&gt;https://issues.apache.org/jira/browse/WSS-268&lt;br /&gt;https://issues.apache.org/jira/browse/WSS-257&lt;br /&gt;https://issues.apache.org/jira/browse/WSS-256&lt;br /&gt;&lt;br /&gt;WSS-268 involves getting Opensaml2 into Maven central, WSS-257 is&lt;br /&gt;partially complete, and WSS-256 is mostly complete. I plan on creating&lt;br /&gt;a Release Candidate in about a week, and calling a vote in about 2&lt;br /&gt;weeks.&lt;br /&gt;&amp;nbsp;&lt;/pre&gt;&lt;/blockquote&gt;CXF trunk has already been upgraded to use a WSS4J 1.6-SNAPSHOT dependency.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-861471723565450330?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/861471723565450330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-beta-release.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/861471723565450330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/861471723565450330'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/03/wss4j-16-beta-release.html' title='[WSS4J 1.6] Beta release'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-883449789018913963</id><published>2011-02-28T07:56:00.000-08:00</published><updated>2011-02-28T07:56:02.403-08:00</updated><title type='text'>Talend Integration Factory released</title><content type='html'>Following in the footsteps of the first Talend Service Factory release &lt;a href="http://coheigea.blogspot.com/2010/12/talend-service-factory-ce-released.html"&gt;last year&lt;/a&gt;, the first release of the Talend Integration Factory has been &lt;a href="http://www.talend.com/press/Talend-Integration-Factory-is-a-Major-Step-Forward-in-Democratizing-ESB-Market.php"&gt;announced&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;Talend Integration Factory, based on Apache Camel, uses well  known  Enterprise Integration Patterns to make message-based system integration   easier to implement, yet more powerful and scalable. &lt;/blockquote&gt;For an in-depth analysis of what the Talend Integration Factory offers, see Christian Schneider's blog entry &lt;a href="http://www.liquid-reality.de/display/liquid/2011/02/16/Talend+Integration+Factory+powered+by+Apache+Camel+is+released"&gt;here&lt;/a&gt;. For some other comments on this release, see &lt;a href="http://www.dankulp.com/blog/?p=289"&gt;here&lt;/a&gt; and &lt;a href="http://sberyozkin.blogspot.com/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-883449789018913963?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/883449789018913963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/02/talend-integration-factory-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/883449789018913963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/883449789018913963'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/02/talend-integration-factory-released.html' title='Talend Integration Factory released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-9057343846438825407</id><published>2011-02-23T08:53:00.000-08:00</published><updated>2011-02-23T08:56:41.382-08:00</updated><title type='text'>[WSS4J 1.6] Changes to the Crypto interface</title><content type='html'>WSS4J uses the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Crypto.java?view=markup"&gt;Crypto&lt;/a&gt; interface to provide a pluggable way of retrieving and converting certificates, verifying trust on certificates etc. A previous blog &lt;a href="http://coheigea.blogspot.com/2011/02/wss4j-16-change-to-publickey-validation.html"&gt;post&lt;/a&gt; described how verifying trust on PublicKeys was also moved into the Crypto interface for WSS4J 1.6.&lt;br /&gt;&lt;br /&gt;WSS4J 1.5.x shipped with a Crypto implementation based around a KeyStore, which was configured via a properties file. A previous blog &lt;a href="http://coheigea.blogspot.com/2011/01/wss4j-16-crypto-property-change.html"&gt;post&lt;/a&gt; describes some changes that were made to the property config names, as well as describing the separation between a keystore and a truststore. The code was also modified as part of this work so that the Crypto instance can be instantiated as normal, and not just via a properties file.&lt;br /&gt;&lt;br /&gt;A big issue with the Crypto interface is that it was too closely tied in to the Java KeyStore objects which back the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Merlin.java?view=markup"&gt;Merlin&lt;/a&gt; implementation. This makes it difficult to subclass the interface, for example to write a Crypto implementation that just stores an array of X509Certificates for signature verification, or to write a client to obtain the X509Certificates from a remote store (e.g. XKMS).&lt;br /&gt;&lt;br /&gt;The fix for &lt;a href="http://issues.apache.org/jira/browse/WSS-269"&gt;WSS-269&lt;/a&gt; attempts to address these shortcomings. All of the KeyStore specific method names and arguments have been abstracted. All of the methods which locate X509Certificates have been consolidated into a single method, which takes an argument a new class which supplies the data (e.g. a SHA1 thumbprint of the certificate) used to retrieve the certificates. The abstract functionality (i.e. KeyStore independent) has been moved into the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/CryptoBase.java?view=markup"&gt;CryptoBase&lt;/a&gt; class, so implementation can just subclass this to avoid having to re-implement all of the generic methods in the Crypto interface.&lt;br /&gt;&lt;br /&gt;WSS4J now ships with another Crypto implementation. &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/CertificateStore.java?view=markup"&gt;CertificateStore&lt;/a&gt; holds an array of X509Certificates that can be used out of the box, for signature verification, or encryption. The PrivateKey methods are not implemented, so it cannot be used for decryption, or signature creation. However, CertificateStore could easily be subclassed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-9057343846438825407?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/9057343846438825407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/02/wss4j-16-changes-to-crypto-interface.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/9057343846438825407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/9057343846438825407'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/02/wss4j-16-changes-to-crypto-interface.html' title='[WSS4J 1.6] Changes to the Crypto interface'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-4979016418113011659</id><published>2011-02-21T04:27:00.000-08:00</published><updated>2011-02-21T04:27:25.264-08:00</updated><title type='text'>[WSS4J 1.6] Change to PublicKey validation</title><content type='html'>This entry describes a relatively minor change to how trust validation is performed on PublicKeys in WSS4J 1.6. &lt;br /&gt;&lt;br /&gt;When the KeyInfo element of a Signature does not have a SecurityTokenReference child, WSS4J tries to extract a PublicKey via a KeyValue child. In WSS4J 1.5.x, it then constructed a PublicKeyCallback instance, passing it the PublicKey object, and invoked the CallbackHandler. It then called a "isVerified" method on the Callback to check to see whether the CallbackHandler had verified the PublicKey or not. The CallbackHandler implementation needed to call the "verifyTrust" method on the PublicKeyCallback, passing in a KeyStore object. This method iterates through each Certificate in the KeyStore, and checks to see whether the PublicKeys match.&lt;br /&gt;&lt;br /&gt;There are a number of problems with this approach:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It is inconsistent with how Certificate validation is done (i.e. via a Crypto object).&lt;/li&gt;&lt;li&gt;It relies on the CallbackHandler implementation calling "verifyTrust" on the Callback object, thus putting the onus on the end-user to write the CallbackHandler implementation properly.&lt;/li&gt;&lt;/ul&gt;As part of the fix for &lt;a href="http://issues.apache.org/jira/browse/WSS-266"&gt;WSS-266&lt;/a&gt;, the PublicKeyCallback class was removed from WSS4J. Instead, the "verifyTrust" method was moved to the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Crypto.java?p2=%2Fwebservices%2Fwss4j%2Ftrunk%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fws%2Fsecurity%2Fcomponents%2Fcrypto%2FCrypto.java&amp;amp;p1=%2Fwebservices%2Fwss4j%2Ftrunk%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fws%2Fsecurity%2Fcomponents%2Fcrypto%2FCrypto.java&amp;amp;r1=1062763&amp;amp;r2=1062762&amp;amp;view=diff&amp;amp;pathrev=1062763"&gt;Crypto interface&lt;/a&gt;, whether the argument is now a PublicKey object, rather than a KeyStore. In this way, validation is done in the same way as for Certificates, and the end-user has no need to consider the special-case of verifying public keys in the CallbackHandler, it is taken care of internally by WSS4J.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-4979016418113011659?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/4979016418113011659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/02/wss4j-16-change-to-publickey-validation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4979016418113011659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4979016418113011659'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/02/wss4j-16-change-to-publickey-validation.html' title='[WSS4J 1.6] Change to PublicKey validation'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7599635657178774152</id><published>2011-02-18T08:16:00.000-08:00</published><updated>2011-02-18T08:19:54.017-08:00</updated><title type='text'>[WSS4J 1.6] Specifying elements to sign or encrypt</title><content type='html'>The signature and encryption creation code in WSS4J uses the WSEncryptionPart class to find DOM elements to sign and encrypt. There are a number of minor changes to how elements are located from a WSEncryptionPart in WSS4J 1.6:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;WSEncryptionPart now stores an optional DOM element, which will be used as the element to sign/encrypt if it is non-null. &lt;/li&gt;&lt;li&gt;Failing this, it finds the SOAP body and compares the wsu:Id with the stored Id, or if there is no stored Id in WSEncryptionPart, it checks the stored localname/namespace.&lt;/li&gt;&lt;li&gt;Failing this, if the stored Id in WSEncryptionPart is not null, it tries to find the first element in the SOAP envelope that has a matching wsu:Id.&lt;/li&gt;&lt;li&gt;If the stored Id is null, it tries to find *all* DOM Elements that match the stored localname/namespace. &lt;/li&gt;&lt;/ol&gt;WSEncryptionPart is intended to refer to a single Element for encryption/signature. However, as a localname/namespace is not necessarily unique, point 4 will return all matching Elements. An important implication of the order of the steps given above, is that client code should set the DOM element on the WSEncryptionPart if it is accessible, and if not, it should set the wsu:Id. Otherwise, a localname/namespace (which is not referring to the SOAP Body) will result in a traversal of the DOM tree. &lt;br /&gt;&lt;br /&gt;The DOM element(s) that is(are) found are stored for retrieval, so that we don't need to traverse the SOAP envelope multiple times, when e.g. doing an STR Transform, or for element location in the XML Security code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7599635657178774152?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7599635657178774152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/02/wss4j-16-specifying-elements-to-sign-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7599635657178774152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7599635657178774152'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/02/wss4j-16-specifying-elements-to-sign-or.html' title='[WSS4J 1.6] Specifying elements to sign or encrypt'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-4604754406237353836</id><published>2011-02-08T05:22:00.000-08:00</published><updated>2011-02-08T05:22:54.350-08:00</updated><title type='text'>WSPasswordCallback changes in WSS4J 1.6</title><content type='html'>Following the previous &lt;a href="http://coheigea.blogspot.com/2011/02/usernametoken-processing-changes-in.html"&gt;post&lt;/a&gt; on Username Token processing changes in WSS4J 1.6, this post gives some additional details on related changes that have been made to the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSPasswordCallback.java?view=markup"&gt;WSPasswordCallback&lt;/a&gt; class in WSS4J.&lt;br /&gt;&lt;br /&gt;WSPasswordCallback defines a set of integers which correspond to usage instructions for the CallbackHandler. In WSS4J 1.5.x they were often used in an inconsistent or ad hoc manner, leading to confusion for users. The following integers have been deprecated in WSS4J 1.6 and are no longer used internally by WSS4J:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;WSPasswordCallback.KEY_NAME&lt;/li&gt;&lt;li&gt;WSPasswordCallback.USERNAME_TOKEN_UNKNOWN&lt;/li&gt;&lt;li&gt;WSPasswordCallback.ENCRYPTED_KEY_TOKEN &lt;/li&gt;&lt;/ul&gt;In WSS4J 1.6, the following WSPasswordCallback identifiers are used:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;WSPasswordCallback.DECRYPT - DECRYPT usage is used when the calling code needs a password to get the private key of this identifier (alias) from a keystore. This is only used for the inbound case of decrypting a session (symmetric) key, and not for the case of getting a private key to sign the message. The CallbackHandler must set the password via the setPassword(String) method.&lt;/li&gt;&lt;li&gt;WSPasswordCallback.USERNAME_TOKEN - USERNAME_TOKEN usage is used to obtain a password for either creating a Username Token, or for validating it. It is also used for the case of deriving a key from a Username Token. The CallbackHandler must set the password via the setPassword(String) method.&lt;/li&gt;&lt;li&gt;WSPasswordCallback.SIGNATURE - SIGNATURE usage is used on the outbound side only, to get a password to get the private key of this identifier (alias) from a keystore. The CallbackHandler must set the password via the setPassword(String) method.&lt;/li&gt;&lt;li&gt;WSPasswordCallback.SECURITY_CONTEXT_TOKEN - SECURITY_CONTEXT_TOKEN usage is for the case of when we want the CallbackHandler to supply the key associated with a SecurityContextToken. The CallbackHandler must set the key via the setKey(byte[]) method.&lt;/li&gt;&lt;li&gt;WSPasswordCallback.CUSTOM_TOKEN - CUSTOM_TOKEN usage is used for the case that we want the CallbackHandler to supply a token as a DOM Element. For example, this is used for the case of a reference to a SAML Assertion or Security Context Token that is not in the message. The CallbackHandler must set the token via the setCustomToken(Element) method.&lt;/li&gt;&lt;li&gt;WSPasswordCallback.SECRET_KEY - SECRET_KEY usage is used for the case that we want to obtain a secret key for encryption or signature on the outbound side, or for decryption or verification on the inbound side. The CallbackHandler must set the key via the setKey(byte[]) method.&lt;/li&gt;&lt;/ul&gt;The DECRYPT, SIGNATURE and SECURITY_CONTEXT_TOKEN identifiers are used more or less the same as they were used in WSS4J 1.5.x. The CUSTOM_TOKEN identifier is also used in a similar way, apart from the fact that some of the processors incorrectly used it to obtain a secret key. The changes to USERNAME_TOKEN were covered in a previous blog post. &lt;br /&gt;&lt;br /&gt;SECRET_KEY is a new identifier for finding secret keys. It replaces the occasionally incorrect use of CUSTOM_TOKEN, as well as KEY_NAME and ENCRYPTED_KEY_TOKEN.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-4604754406237353836?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/4604754406237353836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/02/wspasswordcallback-changes-in-wss4j-16.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4604754406237353836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4604754406237353836'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/02/wspasswordcallback-changes-in-wss4j-16.html' title='WSPasswordCallback changes in WSS4J 1.6'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-5897908290626322691</id><published>2011-02-04T06:09:00.000-08:00</published><updated>2011-02-07T08:34:27.831-08:00</updated><title type='text'>UsernameToken processing changes in WSS4J 1.6</title><content type='html'>The forthcoming WSS4J 1.6 release contains some significant changes relating to how wsse UsernameTokens are processed. In WSS4J 1.5.x, the following processing rules applied:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;For a digest password, the CallbackHandler implementation was given the username and an identifier of WSPasswordCallback.USERNAME_TOKEN. It was then expected to set the password on the callback, and the processor did the comparison.&lt;/li&gt;&lt;li&gt;For a plaintext password, the CallbackHandler implementation was given the username, password, and an identifier of WSPasswordCallback.USERNAME_TOKEN_UNKNOWN, and was expected to do all validation of the plaintext password itself, throwing an exception if validation failed.&lt;/li&gt;&lt;li&gt;For a password of some unspecified non-standard type, WSS4J would throw an exception by default. However, if wssConfig.getHandleCustomPasswordTypes() returned true, then it would again dispatch the username, password, and an identifier of WSPasswordCallback.USERNAME_TOKEN_UNKNOWN to the CallbackHandler implementation for validation.&lt;/li&gt;&lt;li&gt;For the case of a UsernameToken with no password element, it would again dispatch the username, password, and an identifier of  WSPasswordCallback.USERNAME_TOKEN_UNKNOWN to the CallbackHandler implementation for validation.&lt;/li&gt;&lt;/ul&gt;The reason that the processor does not validate the plaintext password, as per the digest case, is to accommodate dispatching the username/password to (for example) a directory store for authentication. The custom password type is treated as a separate case namely for WCF interoperability (see &lt;a href="http://issues.apache.org/jira/browse/WSS-199"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;There are &lt;strike&gt;a couple of&lt;/strike&gt; several obvious problems with this set-up: &lt;br /&gt;&lt;ul&gt;&lt;li&gt;The standard plaintext password case is treated exactly the same as a non-standard password type, or the case of no password at all, by sending the callback handler a type of WSPasswordCallback.USERNAME_TOKEN_UNKNOWN.&lt;/li&gt;&lt;li&gt;The treatment of passwords for both the standard digest and plaintext cases are inconsistent.&lt;/li&gt;&lt;li&gt;A potential security hole exists where the user may not be aware that the CallbackHandler implementation *must* throw an exception on WSPasswordCallback.USERNAME_TOKEN_UNKNOWN when the password is not recognised.&lt;/li&gt;&lt;li&gt;The CallbackHandler interface is being used in a non-standard way - it is only meant to supply a password, not do the validation.&lt;/li&gt;&lt;li&gt;UsernameTokens with no password (i.e. used for key derivation) are stored using the same result (WSConstants.UT) as UsernameTokens that have been validated. This could lead to a security hole where a user assumes that because a UsernameToken has been processed, password validation has taken place. &lt;/li&gt;&lt;/ul&gt;WSS4J 1.6 fixes these issues, at the cost of breaking backwards compatibility in terms of the semantics of the CallbackHandler implementation. The UsernameTokenProcessor now does no validation of the password, beyond making sure it is well formed. A new Validator implementation (more on this at a later date) does the validation of the token. The default behaviour is as follows:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;For the digest case, the CallbackHandler is given the username, password type and an identifier of WSPasswordCallback.USERNAME_TOKEN. It must set the password on the callback, and the validator does the comparison. This is the same as the old behaviour.&lt;/li&gt;&lt;li&gt;The plaintext case has exactly the same behaviour as the digest case. The identifier is now WSPasswordCallback.USERNAME_TOKEN and not WSPasswordCallback.USERNAME_TOKEN_UNKNOWN, and the CallbackHandler does not do any authentication, but must set the password on the callback.&lt;/li&gt;&lt;li&gt;The custom password type case defaults to the same behaviour as the plaintext case, assuming wssConfig.getHandleCustomPasswordTypes() returns true.&lt;/li&gt;&lt;li&gt;For the case of a username token with no password element, the default behaviour is simply to ignore it, and to store it as a new result of type WSConstants.UT_NOPASSWORD.&lt;/li&gt;&lt;/ul&gt;So we now have the correct use of the CallbackHandler interface - it does no authentication, and is only used to retrieve password for validation. The plaintext and digest cases are treated the same way by default. There is no security hole in that the user does not need to throw exceptions in the CallbackHandler implementation for various cases. Also, the case of no password at all is not validated, but is stored as a separate type, for use by other processors to derive keys for decryption or signature verification.&lt;br /&gt;&lt;br /&gt;So what if you want to validate the plaintext password against a directory store, rather than have the CallbackHandler set the password? Instead of implementing this behaviour in your CallbackHandler implementation, you can simply @Override the verifyPlaintextPassword(UsernameToken usernameToken) method in the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/UsernameTokenValidator.java?view=markup"&gt;validator&lt;/a&gt; instead. By simply plugging in a validator on the UsernameTokenProcessor (such as the &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/NoOpValidator.java?view=markup"&gt;NoOpValidator&lt;/a&gt;), it is possible to do any kind of custom validation (or none at all) on the token. This is a much better solution than having to write a custom processor, and replace the existing UsernameTokenProcessor.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-5897908290626322691?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/5897908290626322691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/02/usernametoken-processing-changes-in.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5897908290626322691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/5897908290626322691'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/02/usernametoken-processing-changes-in.html' title='UsernameToken processing changes in WSS4J 1.6'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-7158432912562490517</id><published>2011-02-02T06:43:00.000-08:00</published><updated>2011-02-03T02:04:42.646-08:00</updated><title type='text'>Support for SAML2 assertions in WSS4J 1.6</title><content type='html'>Support for SAML2 assertions has finally arrived in WSS4J, via the forthcoming 1.6 release. This has been a long-standing feature request (see &lt;a href="http://issues.apache.org/jira/browse/WSS-146"&gt;here&lt;/a&gt;). WSS4J 1.5.x only supports SAML 1.1 assertions via the deprecated &lt;a href="https://spaces.internet2.edu/display/OpenSAML/OS1Status"&gt;Opensaml1&lt;/a&gt;, and it supports them in a very limited manner, namely:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It only supports the creation of Authentication statements.&lt;/li&gt;&lt;li&gt;Processing essentially involves saving the assertions, it did not support validating enveloped signatures, or trust on the signatures, etc.&lt;/li&gt;&lt;/ul&gt;Several patches were submitted to &lt;a href="http://issues.apache.org/jira/browse/WSS-146"&gt;WSS-146&lt;/a&gt; to upgrade WSS4J to use Opensaml2. I took a patch from Todd Michael Dunst as a starting point for the port, as his patch had the nice idea of using a CallbackHandler implementation to construct outbound SAML assertions. About a months work later (mainly in testing, refactoring, and porting the patch to trunk) the SAML2 port is more or less ready on trunk. SAML2 support in WSS4J 1.6 consists of:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Support for creating signed/unsigned SAML 1.1/2.0 assertions, containing authentication, authorization, attribute statements etc.&lt;/li&gt;&lt;li&gt; This extensibility is achieved by letting the user implement a CallbackHandler instance.&lt;/li&gt;&lt;li&gt;The SAMLTokenProcessor can now process any type of assertion, verify an enveloped signature on it, and verify trust on the signature. It also verifies some holder-of-key requirements, e.g. that the Subject contains a KeyInfo element, and that the assertion is signed and trusted etc.&lt;/li&gt;&lt;/ul&gt;WSS4J 1.6 contains an extensive set of tests for both creating and processing different type of assertions, you can browse them &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/"&gt;here&lt;/a&gt;. To illustrate the flexibility and simplicity of the CallbackHandler approach for constructing assertions, take a look at an abstract CallbackHandler &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/AbstractSAMLCallbackHandler.java?view=markup"&gt;here&lt;/a&gt;, as well as the concrete implementations (&lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/SAML1CallbackHandler.java?view=markup"&gt;SAML 1.1&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/SAML2CallbackHandler.java?view=markup"&gt;SAML 2&lt;/a&gt;). As you can see, a fairly small amount of code can create a large variety of assertions.&lt;br /&gt;&lt;br /&gt;Opensaml2 has a very large set of dependencies, but through some judicious pom exclusions, as well replacing the Opensaml DefaultBootstrap code to avoid loading velocity, the following dependencies are introduced in WSS4J via Opensaml (snippet from mvn dependency):&lt;br /&gt;&lt;blockquote&gt;+- org.opensaml:opensaml:jar:2.4.1:compile&lt;br /&gt;&amp;nbsp;|&amp;nbsp; \- org.opensaml:openws:jar:1.4.1:compile&lt;br /&gt;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \- org.opensaml:xmltooling:jar:1.3.1:compile&lt;br /&gt;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; +- org.slf4j:slf4j-api:jar:1.6.1:compile&lt;br /&gt;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \- joda-time:joda-time:jar:1.6.2:compile&lt;/blockquote&gt;The WSS4J 1.6 pom currently has a dependency on the Shibboleth &lt;a href="http://shibboleth.internet2.edu/downloads/maven2/"&gt;repo&lt;/a&gt;, where the Opensaml2 artifacts live. I plan on getting the Opensaml2 artifacts into Maven central in time for the 1.6 release - this is slightly complicated by the fact that some of the Opensaml2 dependencies are themselves not in Maven Central.&lt;br /&gt;&lt;br /&gt;One known &lt;a href="http://issues.apache.org/jira/browse/WSS-265"&gt;issue&lt;/a&gt; is that WSS4J cannot create an Assertion which has an EncryptedKey element in the Subject. This is due to a bug in Opensaml2 which has been &lt;a href="https://bugs.internet2.edu/jira/browse/JOWS-26"&gt;fixed&lt;/a&gt;, but not released yet.&lt;br /&gt;&lt;br /&gt;The Opensaml2 port has a large impact on existing code for *creating* assertions, however I suspect that very few people used that code. It has a minimal impact on existing code for processing assertions, with several caveats:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;WSS4J 1.5.x ignored (enveloped) signatures on SAML (1.1) assertions - this is no longer the case, so deployments which do not set the correct keystore/truststore config for dealing with signature verification will fail&lt;/li&gt;&lt;li&gt; The SAMLTokenProcessor no longer saves all tokens as an "WSConstants.ST_UNSIGNED" action. It saves tokens that do not have an enveloped signature as this action, and token which *do* have an enveloped signature are saved as a "WSConstants.ST_SIGNED" action.&lt;/li&gt;&lt;li&gt;The object that is saved as part of the action above has changed, from an Opensaml1 specific Assertion object, to an AssertionWrapper instance, which is a WSS4J specific object which encapsulates an Assertion, as well as some information corresponding to signature verification, etc.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-7158432912562490517?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/7158432912562490517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/02/support-for-saml2-assertions-in-wss4j.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7158432912562490517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/7158432912562490517'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/02/support-for-saml2-assertions-in-wss4j.html' title='Support for SAML2 assertions in WSS4J 1.6'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-1368688821522423657</id><published>2011-01-07T04:02:00.000-08:00</published><updated>2011-01-07T04:05:00.300-08:00</updated><title type='text'>[WSS4J 1.6] Action/Processor loading change</title><content type='html'>Following on from yesterday's post about changes to crypto property files in WSS4J 1.6, this post details some changes that have been made to how Actions and Processors are loaded in WSS4J. These changes do not affect the end user per se, apart from the case of adding custom Actions or Processors, but are probably important enough to take note of.&lt;br /&gt;&lt;br /&gt;In WSS4J 1.5.x, &lt;a href="http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java?revision=1055456&amp;amp;view=markup"&gt;WSSConfig&lt;/a&gt; stores a &amp;lt;QName, String&amp;gt; map of default Processors. On processing a security header, it tries to match the QName of the child elements with the Map keys, and then uses the corresponding Map value to load the Processor class and then create a new instance of it.&lt;br /&gt;&lt;br /&gt;The problem with this approach is that every time a message is received, each processor that is required gets class loaded again, which is highly inefficient. See this &lt;a href="https://issues.apache.org/jira/browse/WSS-232"&gt;JIRA &lt;/a&gt;for more details. The same problem also exists for Action classes that are also loaded by WSSConfig.&lt;br /&gt;&lt;br /&gt;The simple solution is to change the default Action/Processor maps in WSSConfig to store Class instances rather than Strings. Each time an Action/Processor object is required, it is simply created with &amp;lt;Class&amp;gt;.newInstance(). It is still possible to add custom Action/Processor objects to the custom Action/Processor maps. It is claimed in the JIRA above that:&lt;br /&gt;&lt;blockquote&gt;The patch brings a massive performance enhancement, at least in the  jetty-environment (I didn't test other application server) due to not  looking up the classes on every invocation. The CPU-time of the wss4j  library went from ~50% down to 2%. &lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-1368688821522423657?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/1368688821522423657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/01/wss4j-16-actionprocessor-loading-change.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1368688821522423657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/1368688821522423657'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/01/wss4j-16-actionprocessor-loading-change.html' title='[WSS4J 1.6] Action/Processor loading change'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-113713514680518483</id><published>2011-01-06T07:51:00.000-08:00</published><updated>2011-06-07T09:41:53.390-07:00</updated><title type='text'>[WSS4J 1.6]  Crypto property change</title><content type='html'>One of my goals for this blog is to document ongoing changes to the forthcoming WSS4J 1.6 release. This way I will be able to collate all of the entries into a single resource to put on the WSS4J &lt;a href="http://ws.apache.org/wss4j"&gt;website&lt;/a&gt;. I'm mainly going to focus on changes that affect the end-user, as the internal changes are too numerous to mention. Note that these blog posts are not intended to be definitive, as certain things may change before the release goes out.&lt;br /&gt;&lt;br /&gt;This entry focuses on some changes to the Crypto property files.&amp;nbsp; These files are used to load keys and certificates for various WS-Security operations, and are loaded by the &lt;a href="https://svn.apache.org/repos/asf/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/CryptoFactory.java"&gt;CryptoFactory&lt;/a&gt; class. CryptoFactory parses a single property in the file:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.crypto.provider - WSS4J specific provider used to create Crypto instances (default value is "org.apache.ws.security.components.crypto.Merlin").&lt;/li&gt;&lt;/ul&gt;WSS4J 1.6 will only ship with this provider, WSS4J 1.5.x ships with a (largely redundant) BouncyCastle provider as well. The rest of the crypto property file is parsed by &lt;a href="https://svn.apache.org/repos/asf/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/AbstractCrypto.java"&gt;AbstractCrypto&lt;/a&gt;. The old configuration tags that were available in WSS4J 1.5.x are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.file - location of keystore&lt;/li&gt;&lt;li&gt; org.apache.ws.security.crypto.merlin.keystore.provider - provider of keystore&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.password - password used to load keystore&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.type - type of keystore (defaults to java.security.KeyStore.getDefaultType())&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.load.cacerts - whether to load the CA certs in ${java.home}/lib/security/cacerts or not (default is true)&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.cacerts.password - the password to use to load the CA certs (default is "changeit")&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.cert.provider - the provider to use to load certificates &lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.alias - the default keystore alias to use, if none is specified&lt;/li&gt;&lt;/ul&gt;There are a number of issues with the old configuration values. The Java CA certs were loaded by default (for backwards compatiblity reasons), which slows things down if they're not needed. Secondly, there is no clean separation of the keystore used to obtain private/secret keys, and that used to verify trust on received credentials. Thirdly, some of the config tag names are inconsistent. The new crypto property tags for WSS4J 1.6 are as follows:&lt;br /&gt;&lt;br /&gt;Provider tags: &lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.provider - the provider used to load keystores (including the truststore)&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.cert.provider - the provider used to load certificates&lt;/li&gt;&lt;/ul&gt;These are identical to the 1.5.x provider tags.&lt;br /&gt;&lt;br /&gt;KeyStore tags:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.file - location of keystore&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.password - password used to load keystore&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.type - type of keystore (defaults to java.security.KeyStore.getDefaultType())&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.keystore.alias - the default keystore alias to use, if none is specified&lt;/li&gt;&lt;/ul&gt;Note that this is identical to the 1.5.x tags, apart from the location of the keystore file. This value falls back to the old value of "org.apache.ws.security.crypto.merlin.file" if it is not specified.&lt;br /&gt;&lt;br /&gt;Truststore Tags:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; org.apache.ws.security.crypto.merlin.load.cacerts  - whether to load the  CA certs in ${java.home}/lib/security/cacerts or  not (default is false)&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.truststore.file - location of truststore &lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.truststore.password - truststore password (default value is "changeit")&lt;/li&gt;&lt;li&gt;org.apache.ws.security.crypto.merlin.truststore.type - truststore type (defaults to java.security.KeyStore.getDefaultType())&lt;/li&gt;&lt;/ul&gt;Note that the Java CA certs are not now loaded by default. It is now possible to specify the keystore to be used as the truststore, as well as the password used to load the truststore, and the truststore type. It is not possible to both load a truststore and use the JDK CA Certs.&lt;br /&gt;&lt;br /&gt;&lt;strike&gt;One final note - when building a validation chain to validate a received credential, WSS4J uses both the truststore and the keystore. This is for backwards compatibility reasons, where the user does not specify a truststore using the new config. &lt;/strike&gt;The previous sentence applies to WSS4J 1.6.0, but does not apply from WSS4J 1.6.1 onwards. From WSS4J 1.6.1, WSS4J &lt;b&gt;only&lt;/b&gt; uses the truststore when building a validation chain if it is specified. If it is not specified, then it falls back to using the keystore. See this &lt;a href="https://issues.apache.org/jira/browse/WSS-287"&gt;issue&lt;/a&gt; for more details.&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-113713514680518483?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/113713514680518483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2011/01/wss4j-16-crypto-property-change.html#comment-form' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/113713514680518483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/113713514680518483'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2011/01/wss4j-16-crypto-property-change.html' title='[WSS4J 1.6]  Crypto property change'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-814798302297041979</id><published>2010-12-22T04:03:00.000-08:00</published><updated>2010-12-22T04:03:58.701-08:00</updated><title type='text'>CXF/Metro WS-Trust interop</title><content type='html'>&lt;a href="http://www.jroller.com/gmazza"&gt;Glen Mazza&lt;/a&gt;&amp;nbsp;has done some excellent &lt;a href="http://www.jroller.com/gmazza/entry/cxf_stsclient_with_metro_sts"&gt;work&lt;/a&gt; on creating and documenting an example of how to use CXF to obtain a SAML token from a Metro STS and use it to invoke on a Metro endpoint. Unfortunately, it didn't work for a number of reasons:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The Metro endpoint objected to the fact that the CXF client was using a wsse:Reference to the SAML Assertion instead of a wsse:KeyIdentifier. This was a bug in WSS4J, and was fixed as part of &lt;a href="https://issues.apache.org/jira/browse/WSS-238"&gt;WSS-238&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;The CXF client could not decrypt the response from the Metro endpoint. As part of the fix for &lt;a href="https://issues.apache.org/jira/browse/WSS-238"&gt;WSS-238&lt;/a&gt;, support was added for processing  an EncryptedKey that points to a SAML Assertion containing an  X509Certificate, and an EncryptedData token that points to a SAML Assertion containing an  EncryptedKey.&amp;nbsp;&lt;/li&gt;&lt;li&gt;The CXF client could not handle a reference to a SAML Assertion which was not in the SOAP request. This scenario occurred as the endpoint had the "AlwaysToRecipient" policy configured. This was fixed as part of&amp;nbsp;&lt;a href="https://issues.apache.org/jira/browse/WSS-260"&gt;WSS-260&lt;/a&gt;.&lt;/li&gt;&lt;/ol&gt;The good news is that using the latest WSS4J 1.5.11-SNAPSHOT the interop test-case works. This is an important initial milestone in the improving interoperability with third party WS-Trust implementations.&lt;br /&gt;&lt;br /&gt;This kind of interop testing is vital and we have a lot of work planned in this regard.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-814798302297041979?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/814798302297041979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2010/12/cxfmetro-ws-trust-interop.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/814798302297041979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/814798302297041979'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2010/12/cxfmetro-ws-trust-interop.html' title='CXF/Metro WS-Trust interop'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-8780133425403112470</id><published>2010-12-21T03:02:00.000-08:00</published><updated>2010-12-21T03:02:05.584-08:00</updated><title type='text'>New Santuario / XML Security releases</title><content type='html'>There have been two new releases in the last month or so in Santuario / XML Security.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://santuario.apache.org/Java/index.html"&gt;XML Security (Java) 1.4.4&lt;/a&gt; was released in November.  This release         contains some enhancements to the resolver API's. It also fixes         some longstanding issues with interned Strings, as well as a number         of bug fixes.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://santuario.apache.org/c/index.html"&gt;XML Security (C++) 1.6.0&lt;/a&gt; was released in December. This release         provides many bug fixes and a partial implementation of         XML Signature 1.1 features, including ECDSA signatures.&lt;br /&gt;&lt;br /&gt;You can download both releases&amp;nbsp;&lt;a href="http://santuario.apache.org/mirrors.cgi"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-8780133425403112470?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/8780133425403112470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2010/12/new-santuario-xml-security-releases.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8780133425403112470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/8780133425403112470'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2010/12/new-santuario-xml-security-releases.html' title='New Santuario / XML Security releases'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-4123022616589774570</id><published>2010-12-21T02:55:00.000-08:00</published><updated>2010-12-21T02:55:57.745-08:00</updated><title type='text'>Talend Service Factory CE released</title><content type='html'>The first release of the Talend Service Factory CE has been announced. For more information see &lt;a href="http://www.talend.com/products-application-integration/talend-service-factory-community-edition.php"&gt;here&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;Talend Service Factory Community Edition provides users  with an  easy-to-use solution for service enablement. Based on the leading   Apache projects for web services and OSGi, Talend Service Factory  provides a  fully certified and tested solution with support from the  same key Apache  developers that build the software. Service Factory  embodies the key benefits  of OSGi namely modular software development  and Service Lifecycle management.&lt;br /&gt;Talend Service Factory Community Edition is an open,  lightweight  and flexible architecture based on Apache CXF and Apache Karaf, and  is  provided as a single, pre-configured package that enables developers to   quickly build and deploy SOAP and REST Web Services, be it on Tomcat,  Jetty,  Equinox, Felix or your favorite JEE Web Server.&lt;/blockquote&gt;Check out the comments of &lt;a href="http://www.dankulp.com/blog/?p=285"&gt;Dan Kulp&lt;/a&gt;,&amp;nbsp;&lt;a href="http://sberyozkin.blogspot.com/2010/12/talend-service-factory-examples.html"&gt;Sergey Beryozkin&lt;/a&gt; and&amp;nbsp;&lt;a href="http://www.jroller.com/gmazza/entry/talend_esb_service_factory_2"&gt;Glen Mazza&lt;/a&gt; on this release. As Dan says, we have big plans for 2011, particularly some exciting things in the security area, so stay tuned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-4123022616589774570?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/4123022616589774570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2010/12/talend-service-factory-ce-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4123022616589774570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/4123022616589774570'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2010/12/talend-service-factory-ce-released.html' title='Talend Service Factory CE released'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7391783704166348052.post-3770635028931491143</id><published>2010-12-09T03:37:00.000-08:00</published><updated>2010-12-09T03:37:52.071-08:00</updated><title type='text'>First post...</title><content type='html'>I'm planning to use this blog to detail the security-related work I'm doing and planning to do on various open source projects.&lt;br /&gt;&lt;br /&gt;I am the lead-developer on the forthcoming &lt;a href="http://ws.apache.org/wss4j"&gt;WSS4J&lt;/a&gt; 1.6 release, which has a (very) tentative release date of the end of Q1 2011. WSS4J 1.5.x has successfully provided the Web Service Security layer that underpins several Web Services Stacks, such as &lt;a href="http://cxf.apache.org/"&gt;CXF&lt;/a&gt; and &lt;a href="http://axis.apache.org/"&gt;AXIS&lt;/a&gt;. However, WSS4J 1.5.x is showing its age, both in terms of functionality and performance, both problems which will be addressed in the forthcoming 1.6 release. Although WSS4J 1.6 will not be 100% backwards compatible with 1.5.x, a general goal for the release is to restrict the API changes to those that are strictly necessary. The WS-Security module in CXF has already been ported to use WSS4J 1.6-SNAPSHOT, you can see this code &lt;a href="http://svn.apache.org/viewvc/cxf/branches/wss4j-1.6-port/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The best way to keep track of what has already been done for WSS4J 1.6, and what remains to be done, is to take a look at the &lt;a href="https://issues.apache.org/jira/browse/WSS"&gt;JIRA&lt;/a&gt;. There are three main areas of improvement. Firstly, WSS4J has been ported to use the &lt;a href="http://jcp.org/en/jsr/detail?id=105"&gt;JSR 105&lt;/a&gt; API for XML Digital Signature. This task is more or less complete, although WSS4J retains some compile-time dependencies on XML Security for some of the trickier manipulations (such as Security Token Reference transforms), as well as for encryption/decryption. Secondly, WSS4J 1.6 will include the port to &lt;a href="https://spaces.internet2.edu/display/OpenSAML/Home/"&gt;Opensaml 2&lt;/a&gt;, thus giving WSS4J the ability to create, parse and manipulate SAML 2 assertions. Thirdly, a huge amount of work has gone into a general code-rewrite with a focus on performance. The JDK 1.4 requirement has been dropped as part of this work, along with the old Axis1 dependencies.&lt;br /&gt;&lt;br /&gt;As part of the JSR-105 port for WSS4J 1.6, it is possible to use the implementation in the JDK 1.6 with WSS4J to provide signature creation/verification functionality. However, WSS4J still relies on the &lt;a href="http://santuario.apache.org/"&gt;Santuario&lt;/a&gt; (aka XML Security) project for some of the more advanced signature functionality, as well as in other areas (outlined above). Santuario 1.4.4 was recently released, and a 1.5 release is scheduled for next year (possibly Q2). There is ongoing debate among the Santuario team as to what features 1.5 will provide. A main focus will definitely be a code rewrite to improve performance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7391783704166348052-3770635028931491143?l=coheigea.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coheigea.blogspot.com/feeds/3770635028931491143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://coheigea.blogspot.com/2010/12/first-post.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3770635028931491143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7391783704166348052/posts/default/3770635028931491143'/><link rel='alternate' type='text/html' href='http://coheigea.blogspot.com/2010/12/first-post.html' title='First post...'/><author><name>Colm O hEigeartaigh</name><uri>http://www.blogger.com/profile/10711987281965801793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_LGQTkDnt_Kk/TQC4o54SQ_I/AAAAAAAAAAQ/xipAQhnEfvc/S220/100_0206.JPG'/></author><thr:total>3</thr:total></entry></feed>
