Marshalling RequestSecurityToken

Gina Choi gchoi at sdl.com
Mon Mar 19 16:22:55 GMT 2012


Hi Brent,

>Well, that's not really correct either.  It "works", but is not how the
>library is intended to be used.  You should always obtain builders,
>marshallers and unmarshallers from the factories that are exposed by the
>Configuration singleton.  See this page in the wiki for the builder
>examples:

>https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUsrManJavaCreat
eFromScratch

Does the following code fit to your original design?


		// Get the builder factory
		XMLObjectBuilderFactory builderFactory =
Configuration.getBuilderFactory();
		
		//Build RequestSecurityToken
		RequestSecurityTokenBuilder rstBuilder =
(RequestSecurityTokenBuilder)
builderFactory.getBuilder(RequestSecurityToken.ELEMENT_NAME);
		RequestSecurityToken rst=  rstBuilder.buildObject();
		
		//Build AppliesTo and add it to RST
		AppliesToBuilder appliesToBuilder = (AppliesToBuilder)
builderFactory.getBuilder(AppliesTo.ELEMENT_NAME);
		AppliesTo appliesTo = appliesToBuilder.buildObject();
		rst.getUnknownXMLObjects().add(appliesTo);


>The SOAP support in OpenSAML is very low-level.  You just build an
>Envelope object, then create a Body and add it to the Envelope; and
>inside the Body you put your payload (e.g. the RST).  If you need
>headers (as you almost certainly will with any of this WS-* stuff), then
>you create a Header and add it to the Envelope, and then add the various
>header objects as children of the Header.  This is illustrated by the
>SOAP client example in the wiki that I previously sent:

>https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUserManJavaSOAP
ClientExample

I need to build Header similar to the following example. User name and
password is used to get RequestSecurityToken, but I am looking for solutions
to get RequestSecurityTokenrResponse in exchange of existing assertion token
that I have. Suppose, that I want to build following Header, which package of
the OpenSAML should I use to build Header elements?


		Header header = envelope.getHeader();



  <s:Header>
    <a:Action
s:mustUnderstand="1">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Iss
ue
    </a:Action>
    <a:To
s:mustUnderstand="1">https://yourcompany.com/adfs/services/trust/13/UsernameM
ixed</a:To>
    <o:Security s:mustUnderstand="1" mlns:o="...">
      <o:UsernameToken u:Id="uuid-6a13a244-dac6-42c1-84c5-cbb345b0c4c4-1">
        <o:Username>Leandro Boffi</o:Username>
        <o:Password Type="...">P at ssw0rd!</o:Password>
      </o:UsernameToken>
    </o:Security>
  </s:Header>

Thanks.

Gina
------------------------------

Message: 2
Date: Fri, 16 Mar 2012 13:05:50 -0400
From: Brent Putman <putmanb at georgetown.edu>
Subject: Re: Marshalling RequestSecurityToken
To: dev at shibboleth.net
Message-ID: <4F6372EE.1000906 at georgetown.edu>
Content-Type: text/plain; charset=ISO-8859-1



On 3/16/12 11:00 AM, Gina Choi wrote:
> I used following code to build RequestSecurityToken(Please let me know if I
> am in wrong direction). In same way, I was able to find corresponding
> builders for each element inside RequestSecurityToken.
>
> 	//Build RequestSecurityToken
> 	RequestSecurityTokenBuilder rstBuilder = new
> RequestSecurityTokenBuilder();


Well, that's not really correct either.  It "works", but is not how the
library is intended to be used.  You should always obtain builders,
marshallers and unmarshallers from the factories that are exposed by the
Configuration singleton.  See this page in the wiki for the builder
examples:

https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUsrManJavaCreate
FromScratch




> 	
>
> I guess next step is that I need to put this RST inside SOAP envelope, but
I
> haven't deal with SOAP much before. Any ideas?


The SOAP support in OpenSAML is very low-level.  You just build an
Envelope object, then create a Body and add it to the Envelope; and
inside the Body you put your payload (e.g. the RST).  If you need
headers (as you almost certainly will with any of this WS-* stuff), then
you create a Header and add it to the Envelope, and then add the various
header objects as children of the Header.  This is illustrated by the
SOAP client example in the wiki that I previously sent:

https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUserManJavaSOAPC
lientExample



More information about the dev mailing list