cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > WS-Trust
Date Sat, 10 Jul 2010 15:53:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/WS-Trust">WS-Trust</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~mazzag">Glen
Mazza</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Added and clarified need for createdFromAPI attribute<br />
    </div>
        <br/>
                         <h4>Changes (3)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code:xml} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">&lt;jaxws:client
name=&quot;{http://cxf.apache.org/}MyService&quot;&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">&lt;jaxws:client
name=&quot;{http://cxf.apache.org/}MyService&quot; createdFromAPI=&quot;true&quot;&gt;
<br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;jaxws:properties&gt;
<br>        &lt;entry key=&quot;ws-security.sts.client&quot;&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Remember
the jaxws:client createdFromAPI attribute is set to true if you created the client programmatically
via the CXF API&#39;s--i.e., Endpoint.publish() or Service.getPort(). <br> <br></td></tr>
            <tr><td class="diff-unchanged" >This also works for &quot;code
first&quot; cases as you can do: <br>{code:java} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>WS-Trust support in CXF builds upon the <a href="/confluence/display/CXF20DOC/WS-SecurityPolicy"
title="WS-SecurityPolicy">WS&#45;SecurityPolicy</a> implementation to handle
the IssuedToken policy assertions that could be found in the WS-SecurityPolicy fragment. 
</p>

<p><b>Note:</b> Because the WS-IssuedToken support builds on the WS-SecurityPolicy
support, this is currently only available to "wsdl first" projects.</p>


<p>WS-Trust extends the WS-Security specification to allow issuing, renewing, and validation
of security tokens.  A lot of what WS-Trust does centers around the use of a "Security Token
Service", or STS.   The STS is contacted to obtain security tokens that are used to create
messages to talk to the services.    The primary use of the STS is to acquire SAML tokens
used to talk to the service.   Why is this interesting?</p>

<p>When using "straight" WS-Security, the client and server need to have keys exchanged
in advance.   If the client and server are both in the same security domain, that isn't usually
a problem, but for larger, complex applications spanning multiple domains, that can be a burden.
 Also, if multiple services require the same security credentials, updating all the services
when those credentials change can by a major operation.   </p>

<p>WS-Trust solves this by using security tokens that are obtained from a trusted Security
Token Service.   A client authenticates itself with the STS based on policies and requirements
defined by the STS.   The STS then provides a security token (example: a SAML token) that
the client then uses to talk to the target service.  The service can validate that token to
make sure it really came from the trusted STS.  </p>


<p>When the WS-SecurityPolicy runtime in CXF encounters an IssuedToken assertion in
the policy, the runtime requries an instance of  org.apache.cxf.ws.security.trust.STSClient
to talk to the STS to obtain the required token.    Since the STSClient is a WS-SecurityPolicy
client, it will need configuration items to be able to create it's secure SOAP messages to
talk to the STS.  </p>

<p>There are several ways to configure the STSClient:</p>

<p><b>Direct configuration of an STS bean in the properties:</b><br/>
In this scenario, a STSClient object is created directly as a property of the client object.
  The wsdlLocation, service/endpoint names, etc... are all configured in line for that client.
  </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;jaxws:client name=<span class="code-quote">"{http://cxf.apache.org/}MyService"</span>
createdFromAPI=<span class="code-quote">"true"</span>&gt;</span>
    <span class="code-tag">&lt;jaxws:properties&gt;</span>
        <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.sts.client"</span>&gt;</span>
            <span class="code-tag"><span class="code-comment">&lt;!-- direct
STSClient config and creation --&gt;</span></span>
            <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.ws.security.trust.STSClient"</span>&gt;</span>
                <span class="code-tag">&lt;constructor-arg ref=<span class="code-quote">"cxf"</span>/&gt;</span>
                <span class="code-tag">&lt;property name=<span class="code-quote">"wsdlLocation"</span>
value=<span class="code-quote">"target/wsdl/trust.wsdl"</span>/&gt;</span>
                <span class="code-tag">&lt;property name=<span class="code-quote">"serviceName"</span>
value=<span class="code-quote">"{http://cxf.apache.org/securitytokenservice}SecurityTokenService"</span>/&gt;</span>
                <span class="code-tag">&lt;property name=<span class="code-quote">"endpointName"</span>
value=<span class="code-quote">"{http://cxf.apache.org/securitytokenservice}SecurityTokenEndpoint"</span>/&gt;</span>
                <span class="code-tag">&lt;property name=<span class="code-quote">"properties"</span>&gt;</span>
                    <span class="code-tag">&lt;map&gt;</span>
                        <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.username"</span>
value=<span class="code-quote">"joe"</span>/&gt;</span>
                        <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.callback-handler"</span>
value=<span class="code-quote">"interop.client.KeystorePasswordCallback"</span>/&gt;</span>
                        <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.signature.properties"</span>
value=<span class="code-quote">"etc/alice.properties"</span>/&gt;</span>

                        <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.encryption.properties"</span>
value=<span class="code-quote">"etc/bob.properties"</span>/&gt;</span>
		    			
                    <span class="code-tag">&lt;/map&gt;</span>
                <span class="code-tag">&lt;/property&gt;</span>
            <span class="code-tag">&lt;/bean&gt;</span>            
        <span class="code-tag">&lt;/entry&gt;</span> 
    <span class="code-tag">&lt;/jaxws:properties&gt;</span>
<span class="code-tag">&lt;/jaxws:client&gt;</span>
</pre>
</div></div>

<p>Remember the jaxws:client createdFromAPI attribute is set to true if you created
the client programmatically via the CXF API's--i.e., Endpoint.publish() or Service.getPort().</p>

<p>This also works for "code first" cases as you can do:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
STSClient sts = <span class="code-keyword">new</span> STSClient(...);
sts.setXXXX(....)
.....
((BindingProvider)port).getRequestContext().put(<span class="code-quote">"ws-security.sts.client"</span>,
sts);
</pre>
</div></div>

<p><b>Indirect configuration based on endpoint name:</b><br/>
If the runtime does not find a STSClient bean configured directly on the client, it checks
the configuration for a STSClient bean with the name of the endpoint appended with ".sts-client".
  For example, if the endpoint name for your client is "{<a href="http://cxf.apache.org/"
class="external-link" rel="nofollow">http://cxf.apache.org/</a>}TestEndpoint", then
it can be configured as:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;bean name=<span class="code-quote">"{http://cxf.apache.org/}TestEndpoint.sts-client"</span>

    class=<span class="code-quote">"org.apache.cxf.ws.security.trust.STSClient"</span>
abstract=<span class="code-quote">"true"</span>&gt;
    <span class="code-tag">&lt;property name=<span class="code-quote">"wsdlLocation"</span>
value=<span class="code-quote">"WSDL/wsdl/trust.wsdl"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"serviceName"</span>
value=<span class="code-quote">"{http://cxf.apache.org/securitytokenservice}SecurityTokenService"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"endpointName"</span>
value=<span class="code-quote">"{http://cxf.apache.org/securitytokenservice}SecurityTokenEndpoint"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"properties"</span>&gt;</span>
        <span class="code-tag">&lt;map&gt;</span>
            <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.signature.properties"</span>
value=<span class="code-quote">"etc/alice.properties"</span>/&gt;</span>

            <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.encryption.properties"</span>
value=<span class="code-quote">"etc/bob.properties"</span>/&gt;</span>

            <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.sts.token.properties"</span>
value=<span class="code-quote">"etc/bob.properties"</span>/&gt;</span>
 
            <span class="code-tag">&lt;entry key=<span class="code-quote">"ws-security.callback-handler"</span>
value=<span class="code-quote">"interop.client.KeystorePasswordCallback"</span>/&gt;</span>
        <span class="code-tag">&lt;/map&gt;</span>
    <span class="code-tag">&lt;/property&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p><b>Default configuration:</b><br/>
If an STSClient is not found from the above methods, it then tries to find one configured
like the indirect, but with the name "default.sts-client".   This can be used to configure
sts-clients for multiple services.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/WS-Trust">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=112641&revisedVersion=7&originalVersion=6">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/WS-Trust?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message