Skip to Content »

Tech Life of Recht » Using ActAs with Metro

 Using ActAs with Metro

  • January 5th, 2010
  • 12:18 pm

Yesterday, I wrote about how to implement an STS with Metro. The reason for implementing an STS in the first place is that it enables identity delegation, something you probably want if you need to access a service on behalf of a specific user. The general flow is that the user authenticates, probably using SSO of some kind, and access a website. The site invokes a service on behalf of the user, and the service needs to be pretty sure that the user is actually sitting in the other end, even though there is no direct communication between the user and the service. The job of the STS is to be the one, everybody trusts, so that when the STS issues a token which says that the user is valid, then the service can trust that this is actually the case.

All of this can be done more or less automatically with Metro (at least when using a nightly build) by using this service policy:

CODE:
  1. <sp:AsymmetricBinding>
  2.   <wsp:Policy>
  3.    <sp:InitiatorToken>
  4.     <wsp:Policy>
  5.       <sp:IssuedToken>
  6.            <sp:IssuerName>urn:localsts</sp:IssuerName>
  7.            <sp:RequestSecurityTokenTemplate>
  8.             <t:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</t:TokenType>
  9.             <t:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey</t:KeyType>
  10.            </sp:RequestSecurityTokenTemplate>
  11.         <wsp:Policy>
  12.           <sp:RequireInternalReference />
  13.         </wsp:Policy>
  14.       </sp:IssuedToken>
  15.     </wsp:Policy>
  16.    </sp:InitiatorToken>
  17.    <sp:RecipientToken>
  18.     <wsp:Policy>
  19.      <sp:X509Token>
  20.       <wsp:Policy>
  21.        <sp:RequireKeyIdentifierReference />
  22.        <sp:WssX509V3Token11 />
  23.       </wsp:Policy>
  24.      </sp:X509Token>
  25.     </wsp:Policy>
  26.    </sp:RecipientToken>
  27.     <sp:ProtectTokens/>
  28.     <sp:IncludeTimestamp/>
  29.     <sp:OnlySignEntireHeadersAndBody />
  30.   </wsp:Policy>
  31.  </sp:AsymmetricBinding>

Here, we express that the service requires an issued token of type SAML 2.0. Issued token means that the token has been created by an STS. In this case, we specify that the STS identified by urn:localsts must issue a token of type SAML 2.0. The exact location of the STS needs to be configured in the client.

Unfortunately, WS-SecurityPolicy does not make it possible to express the requirements for the WS-Trust Issue request. When using identity delegation, two sets of credentials should be passed to the STS: The client credentials, for example an X509Token or a UsernameToken, and the user credentials. The client credentials are provided using standard WS-Security mechanisms, and the user credentials are included in the Issue request using the ActAs element.

As shown in the STS example, the STS policy file takes care of the client credentials by specifying the appropriate tokens. The user credentials token cannot, however, be expressed in the policy, so it needs to be agreed upon out of band. This also means that you have to provide it manually to the client.

Luckily, it's pretty easy to add an ActAs token to the client. Normally, the client is generated using wsimport. In this example, the service is called ProviderService:

CODE:
  1. DefaultSTSIssuedTokenConfiguration config = new DefaultSTSIssuedTokenConfiguration();
  2. config.setSTSInfo("http://docs.oasis-open.org/ws-sx/ws-trust/200512",
  3.     "http://localhost:8080/sts/sts",
  4.     "http://localhost:8080/sts/sts?wsdl",
  5.     "SecurityTokenService",
  6.     "ISecurityTokenService_Port",
  7.     "http://tempuri.org/");
  8. config.getOtherOptions().put(STSIssuedTokenConfiguration.ACT_AS, createToken());
  9.  
  10. STSIssuedTokenFeature feature = new STSIssuedTokenFeature(config);
  11. ProviderService service = new ProviderService();
  12. Provider port = service.getProviderPort(feature);
  13. EchoResponse result = port.echo(new Echo());

Here, we create a new configuration object, set the endpoint information for the STS, and add an ActAs token. The contents of the ACT_AS attribute should be an instance of com.sun.xml.ws.security.Token, for example a com.sun.xml.wss.saml.Assertion. Normally, you don't generate the token yourself. Instead, you get it as part of the initial authentication response - for example, if you're using SAML 2.0 web SSO, one of the attributes received might be the ActAs token that should be passed to the STS when invoking services.

9 People had this to say...

[...] This post was mentioned on Twitter by sorenp, Joakim Recht. Joakim Recht said: a little about using ActAs in #metro: http://bit.ly/7OMnLI #wsdeathstarwillruletheworld #wstrust [...]

Gravatar
  • GEENA28
  • January 15th, 2010
  • 2:09 pm

The newspapers give the facts thence some people suppose that it is much better to buy an essay or choose custom papers.

Gravatar

writing jobs will help you get extra money in you spare time

Gravatar

as shown in the STS example, the STS policy file takes care of the client credentials by specifying the appropriate tokens.

Gravatar

custom papers will help you in learning and save your time

Gravatar

People that were looking for some information related to papers for money at the writing service will read your nice writing referring to this good topic. Other way, that’s possible to use the help of the custom writing service.

Gravatar

Which way can you complete your superb tought related to this topic I wonder? The dissertation writing service will employ writers like you for the format thesis doing. Hence you have got a great chance to enter to the team of masters.

Gravatar

as shown in the STS example, the STS policy file takes care of the client credentials by specifying the appropriate tokens.

Gravatar
  • essay
  • August 12th, 2010
  • 6:19 pm

if you have any problems with education,buy essay,it will help in learning and save your time

Want your say?

* Required fields. Your e-mail address will not be published on this site

You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>