Author: buildbot
Date: Wed Dec 2 11:47:47 2015
New Revision: 974280
Log:
Production update by buildbot for cxf
Modified:
websites/production/cxf/content/cache/docs.pageCache
websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html
Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html
==============================================================================
--- websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html (original)
+++ websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html Wed Dec
2 11:47:47 2015
@@ -118,30 +118,32 @@ Apache CXF -- JAXRS OAuth2 Assertions
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><h1
id="JAXRSOAuth2Assertions-JAXRS:OAuth2Assertions">JAXRS: OAuth2
Assertions</h1><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1449053223153 {padding: 0px;}
-div.rbtoc1449053223153 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1449053223153 li {margin-left: 0px;padding-left: 0px;}
-
-/*]]>*/</style></p><div class="toc-macro rbtoc1449053223153">
-<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-JAXRS:OAuth2Assertions">JAXRS: OAuth2
Assertions</a></li><li><a shape="rect"
href="#JAXRSOAuth2Assertions-Introduction">Introduction</a></li><li><a
shape="rect" href="#JAXRSOAuth2Assertions-Mavendependencies">Maven
dependencies</a></li><li><a shape="rect"
href="#JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</a>
-<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-AccessTokenGrant">Access Token Grant</a>
+div.rbtoc1449056823368 {padding: 0px;}
+div.rbtoc1449056823368 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1449056823368 li {margin-left: 0px;padding-left: 0px;}
+
+/*]]>*/</style></p><div class="toc-macro rbtoc1449056823368">
+<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-JAXRS:OAuth2Assertions">JAXRS: OAuth2
Assertions</a></li><li><a shape="rect"
href="#JAXRSOAuth2Assertions-Introduction">Introduction</a></li><li><a
shape="rect" href="#JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</a>
+<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-Mavendependencies">Maven
dependencies</a></li><li><a shape="rect"
href="#JAXRSOAuth2Assertions-AccessTokenGrant">Access Token Grant</a>
<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-Clientcode">Client code</a></li><li><a
shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService">Access Token
Service</a></li></ul>
</li><li><a shape="rect"
href="#JAXRSOAuth2Assertions-AuthenticationToken">Authentication Token</a>
<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-ClientCode">Client Code</a></li><li><a
shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.1">Access Token
Service</a></li></ul>
</li><li><a shape="rect"
href="#JAXRSOAuth2Assertions-ClientActingonBehalfofItself">Client Acting on
Behalf of Itself</a></li></ul>
</li><li><a shape="rect" href="#JAXRSOAuth2Assertions-JWTBearer">JWT Bearer</a>
-<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</a>
-<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-ClientCode.1">Client Code</a></li><li><a
shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.2">Access Token
Service</a></li></ul>
+<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-AccessTokenGrant.1">Access Token Grant</a>
+<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-Clientcode.1">Client code</a></li><li><a
shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.2">Access Token
Service</a></li></ul>
+</li><li><a shape="rect"
href="#JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</a>
+<ul class="toc-indentation"><li><a shape="rect"
href="#JAXRSOAuth2Assertions-ClientCode.1">Client Code</a></li><li><a
shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.3">Access Token
Service</a></li></ul>
</li></ul>
</li></ul>
-</div><h1 id="JAXRSOAuth2Assertions-Introduction">Introduction</h1><p><a
shape="rect" class="external-link"
href="http://tools.ietf.org/html/draft-ietf-oauth-v2" rel="nofollow">OAuth
2.0</a> supports different types of access token grants. <a shape="rect"
class="external-link"
href="http://tools.ietf.org/html/draft-ietf-oauth-assertions-10"
rel="nofollow">OAuth2 Assertions</a> draft "provides a framework for the use of
assertions with OAuth 2.0" and <a shape="rect" class="external-link"
href="http://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-15"
rel="nofollow">SAML2 Bearer Assertion Profiles for OAuth2</a> draft
specifically provides for the use of SAML2 Bearer assertions.</p><p>These
assertions can be used as token grants, but also, if needed, for getting 3rd
party clients authenticated. Note the clients can use assertions as grants but
use for example Basic authentication mechanism, or use say an authorization
code grant and the assertion to authenticate, and finally, they
can use assertions as a grant and as an authentication token.</p><p>Currently
CXF supports SAML2 Bearer assertions as grants and authentication
tokens.</p><p>See the <a shape="rect" href="jax-rs-oauth2.html">JAX-RS
OAuth2</a> page for information about OAuth 2.0 support in CXF. Please also
check the <a shape="rect" href="jax-rs-saml.html">JAX-RS SAML</a> page for more
information about SAML support.</p><h1
id="JAXRSOAuth2Assertions-Mavendependencies">Maven dependencies</h1><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div><h1 id="JAXRSOAuth2Assertions-Introduction">Introduction</h1><p><a
shape="rect" class="external-link" href="https://tools.ietf.org/html/rfc6749"
rel="nofollow">OAuth 2.0</a> supports different types of access token grants.
The <a shape="rect" class="external-link"
href="http://tools.ietf.org/html/rfc7521" rel="nofollow">OAuth2 Assertions</a>
spec "provides a framework for the use of assertions with OAuth 2.0 in the form
of a new client authentication mechanism and a new authorization grant type".
More specifically, the <a shape="rect" class="external-link"
href="https://tools.ietf.org/html/rfc7522" rel="nofollow">SAML2 Bearer
Assertion Profiles for OAuth2</a> spec provides for the use of SAML2 Bearer
assertions, and the <a shape="rect" class="external-link"
href="http://tools.ietf.org/html/rfc7523" rel="nofollow">JSON Web Token (JWT)
Profile for OAuth 2.0 Client Authentication and Authorization Grants</a> spec
providers for the use of JWT Bearer tokens.</p><p>These assertions
can be used as token grants, but also, if needed, for getting 3rd party
clients authenticated. Note the clients can use assertions as grants but use
for example Basic authentication mechanism, or use say an authorization code
grant and the assertion to authenticate, and finally, they can use assertions
as a grant and as an authentication token.</p><p>Currently CXF supports both
SAML2 Bearer and JWT Bearer assertions as grants and authentication
tokens.</p><p>See the <a shape="rect" href="jax-rs-oauth2.html">JAX-RS
OAuth2</a> page for information about OAuth 2.0 support in CXF. Please also
check the <a shape="rect" href="jax-rs-saml.html">JAX-RS SAML</a> page for more
information about SAML support.</p><p> </p><h1
id="JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</h1><h2
id="JAXRSOAuth2Assertions-Mavendependencies">Maven dependencies</h2><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-security-oauth2-saml</artifactId>
- <version>2.7.4</version>
+ <version>${cxf.version}</version>
</dependency>
</pre>
-</div></div><h1 id="JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</h1><h2
id="JAXRSOAuth2Assertions-AccessTokenGrant">Access Token Grant</h2><p><a
shape="rect" class="external-link"
href="http://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-15#section-2.1"
rel="nofollow">This section</a> explains how SAML2 Bearer assertions can be
used as token grants. The value of grant_type parameter is
"urn:ietf:params:oauth:grant-type:saml2-bearer".</p><p>It is really just
another grant type, but whose actual value is a SAML assertion. The
specification provides an <a shape="rect" class="external-link"
href="http://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-15#section-4"
rel="nofollow">example</a> of how such an assertion may look like.</p><p>The
additional restriction is that the assertions have to be encoded using
Base64Url encoding. <br clear="none"> Here is how a request may look
like:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent
pdl">
+</div></div><h2 id="JAXRSOAuth2Assertions-AccessTokenGrant">Access Token
Grant</h2><p><a shape="rect" class="external-link"
href="http://tools.ietf.org/html/rfc7522#section-2.1" rel="nofollow">This
section</a> explains how SAML2 Bearer assertions can be used as token grants.
The value of grant_type parameter is
"urn:ietf:params:oauth:grant-type:saml2-bearer".</p><p>It is really just
another grant type, but whose actual value is a SAML assertion. The
specification provides an <a shape="rect" class="external-link"
href="http://tools.ietf.org/html/rfc7522#section-4" rel="nofollow">example</a>
of how such an assertion may look like.</p><p>The additional restriction is
that the assertions have to be encoded using Base64Url encoding. <br
clear="none"> Here is how a request may look like:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">POST /token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
@@ -178,7 +180,7 @@ ClientAccessToken at = OAuthClientUtils.
grant,
false);
</pre>
-</div></div><p>The code above prepares an info for a new SAML assertion be
self-signed, loading a Crypto instance with crypto <a shape="rect"
class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/alice.properties">properties</a>,
and uses SAMLUtils to create and sign the assertion (using Crypto, plus user
alias and password). Saml2BearerGrant will get the assertion Base64Url-encoded
- unless the assertion has already been encoded with CXF Base64UrlUtility or
came encoded from IP - in this case Saml2BearerGrant constructor accepting an
'encoded' property will have to be used, with the value set to
"true".</p><p>This is nearly as simple as using other token grants, the step 2
will often me omitted in more involved cases as it will be the job of Identity
Providers to issue OAuth2 SAML2 Bearer assertions. Step 2 needs to be done when
testing or when getting client acting <a shape="rect" class="
external-link"
href="http://tools.ietf.org/html/draft-ietf-oauth-assertions-10#section-6.2"
rel="nofollow">on behalf of itself</a> for example.</p><p>Instead of using
SelfSignInfo utility one can create an empty CXF Message and set required
properties on it and passing it to SAMLUtils - see the example on how to use
SAML Bearer assertions for the authentication below.</p><p>When doing step 2,
the main effort is to do with getting a SAML assertion populated - use a SAML
callback handler like <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/SamlCallbackHandler.java">this
one</a>, it is actually quite easy to build the assertion.</p><h3
id="JAXRSOAuth2Assertions-AccessTokenService">Access Token Service</h3><p>Here
is how one may configure Access Token Service:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>The code above prepares an info for a new SAML assertion be
self-signed, loading a Crypto instance with crypto <a shape="rect"
class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/alice.properties">properties</a>,
and uses SAMLUtils to create and sign the assertion (using Crypto, plus user
alias and password). Saml2BearerGrant will get the assertion Base64Url-encoded
- unless the assertion has already been encoded with CXF Base64UrlUtility or
came encoded from IP - in this case Saml2BearerGrant constructor accepting an
'encoded' property will have to be used, with the value set to
"true".</p><p>This is nearly as simple as using other token grants, the step 2
will often me omitted in more involved cases as it will be the job of Identity
Providers to issue OAuth2 SAML2 Bearer assertions. Step 2 needs to be done when
testing or when getting client acting <a shape="rect" class="
external-link" href="http://tools.ietf.org/html/rfc7521#section-6.2"
rel="nofollow">on behalf of itself</a> for example.</p><p>Instead of using
SelfSignInfo utility one can create an empty CXF Message and set required
properties on it and passing it to SAMLUtils - see the example on how to use
SAML Bearer assertions for the authentication below.</p><p>When doing step 2,
the main effort is to do with getting a SAML assertion populated - use a SAML
callback handler like <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/SamlCallbackHandler.java">this
one</a>, it is actually quite easy to build the assertion.</p><h3
id="JAXRSOAuth2Assertions-AccessTokenService">Access Token Service</h3><p>Here
is how one may configure Access Token Service:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><bean id="dataProvider"
class="org.apache.cxf.systest.jaxrs.security.oauth2.OAuthDataProviderImpl"/>
<bean id="samlGrantHandler"
class="org.apache.cxf.rs.security.oauth2.grants.saml.Saml2BearerGrantHandler">
<property name="dataProvider" ref="dataProvider"/>
@@ -309,7 +311,7 @@ ClientAccessToken at = OAuthClientUtils.
</jaxrs:server>
</pre>
-</div></div><h2 id="JAXRSOAuth2Assertions-ClientActingonBehalfofItself">Client
Acting on Behalf of Itself</h2><p>In the <a shape="rect" class="external-link"
href="http://tools.ietf.org/html/draft-ietf-oauth-assertions-10#section-6.2"
rel="nofollow">Client Acting on Behalf of Itself</a> use either
org.apache.cxf.rs.security.oauth2.grants.saml.Saml2BearerClientCredentialsGrant
:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><h2 id="JAXRSOAuth2Assertions-ClientActingonBehalfofItself">Client
Acting on Behalf of Itself</h2><p>In the <a shape="rect" class="external-link"
href="http://tools.ietf.org/html/rfc7521#section-6.2" rel="nofollow">Client
Acting on Behalf of Itself</a> use either
org.apache.cxf.rs.security.oauth2.grants.saml.Saml2BearerClientCredentialsGrant
:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.rs.security.common.CryptoLoader;
import org.apache.cxf.rs.security.oauth2.client.OAuthClientUtils;
@@ -361,7 +363,46 @@ AccessTokenGrant accessTokenGrant = new
ClientAccessToken at = OAuthClientUtils.getAccessToken(wc, accessTokenGrant);
</pre>
-</div></div><p> </p><h1 id="JAXRSOAuth2Assertions-JWTBearer">JWT
Bearer</h1><p> </p><h2
id="JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</h2><p>As
noted in the introduction, JWT Bearer tokens may also act as client
authentication credentials, when requesting an access token, irrespectively of
the actual grant type. For example:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p> </p><h1 id="JAXRSOAuth2Assertions-JWTBearer">JWT
Bearer</h1><h2 id="JAXRSOAuth2Assertions-AccessTokenGrant.1">Access Token
Grant</h2><p><a shape="rect" class="external-link"
href="http://tools.ietf.org/html/rfc7523#section-2.1" rel="nofollow">This
section</a> explains how JWT Bearer tokens can be used as token grants. The
value of grant_type parameter is "urn:ietf:params:oauth:grant-
type:jwt-bearer".</p><p>It is really just another grant type, but whose actual
value is a JWT Token. The specification provides an <a shape="rect"
class="external-link" href="http://tools.ietf.org/html/rfc7523#section-4"
rel="nofollow">example</a> of how such an assertion may look like.</p><p>Here
is how a request may look like:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">POST /token HTTP/1.1
+Content-Type: application/x-www-form-urlencoded
+
+grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&
+assertion=X.Y.Z
+</pre>
+</div></div><h3 id="JAXRSOAuth2Assertions-Clientcode.1">Client code</h3><p>The
following example shows how to use JWT Bearer token as a grant with CXF OAuth2
client code: TODO</p><h3 id="JAXRSOAuth2Assertions-AccessTokenService.2">Access
Token Service</h3><p>Here is how one may configure the Access Token
Service:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><bean id="dataProvider"
class="org.apache.cxf.systest.jaxrs.security.oauth2.OAuthDataProviderImpl"/>
+<bean id="jwtGrantHandler"
class="org.apache.cxf.rs.security.oauth2.grants.jwt.JwtBearerGrantHandler">
+ <property name="dataProvider" ref="dataProvider"/>
+</bean>
+<bean id="oauthJson"
class="org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProvider"/>
+
+<bean id="serviceBean"
class="org.apache.cxf.rs.security.oauth2.services.AccessTokenService">
+ <property name="dataProvider" ref="dataProvider"/>
+ <property name="grantHandlers">
+ <list>
+ <ref bean="jwtGrantHandler"/>
+ </list>
+ </property>
+</bean>
+
+<jaxrs:server
address="https://localhost:${testutil.ports.jaxrs-oauth2}/oauth2">
+ <jaxrs:serviceBeans>
+ <ref bean="serviceBean"/>
+ </jaxrs:serviceBeans>
+ <jaxrs:providers>
+ <ref bean="oauthJson"/>
+ </jaxrs:providers>
+ <jaxrs:properties>
+ <entry key="rs.security.keystore.type" value="jks" />
+ <entry key="rs.security.keystore.alias" value="myclientkey"/>
+ <entry key="rs.security.keystore.password" value="cspass"/>
+ <entry key="rs.security.keystore.file" value="clientstore.jks" />
+ <entry key="rs.security.signature.algorithm" value="RS256" />
+ </jaxrs:properties>
+</jaxrs:server>
+</pre>
+</div></div><h2
id="JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</h2><p>As
noted in the introduction, JWT Bearer tokens may also act as client
authentication credentials, when requesting an access token, irrespectively of
the actual grant type. For example:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">POST /token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
@@ -370,7 +411,7 @@ grant_type=authorization_code
&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
&client_assertion=X.Y.Z
</pre>
-</div></div><p>Note "client_assertion_type" with a value
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer" indicates that the
type of assertion used as an authentication token is
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer", while the
"client_assertion" parameter carries the actual value of the token.</p><h3
id="JAXRSOAuth2Assertions-ClientCode.1">Client Code</h3><p>The following
example shows how to use JWT Bearer tokens as an authentication token:
TODO</p><p> </p><h3 id="JAXRSOAuth2Assertions-AccessTokenService.2">Access
Token Service</h3><p>Here is how one may configure Access Token
Service:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>Note "client_assertion_type" with a value
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer" indicates that the
type of assertion used as an authentication token is
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer", while the
"client_assertion" parameter carries the actual value of the token.</p><h3
id="JAXRSOAuth2Assertions-ClientCode.1">Client Code</h3><p>The following
example shows how to use JWT Bearer tokens as an authentication token:
TODO</p><p> </p><h3 id="JAXRSOAuth2Assertions-AccessTokenService.3">Access
Token Service</h3><p>Here is how one may configure Access Token
Service:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><bean id="dataProvider"
class="org.apache.cxf.systest.jaxrs.security.oauth2.OAuthDataProviderImpl"/>
<bean id="oauthJson"
class="org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProvider"/>
<bean id="jwtAuthHandler"
class="org.apache.cxf.rs.security.oauth2.grants.jwt.JwtBearerAuthHandler"/>