Skip to Content.
Sympa Menu

mace-opensaml-users - Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml.

Subject: OpenSAML user discussion

List archive

Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml.


Chronological Thread 
  • From: "Michael Lausch" <>
  • To:
  • Subject: Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml.
  • Date: Wed, 1 Oct 2008 15:16:30 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=JSGFhK9OqTC7mZmBq/bSjOwNpBW1RX6ZTtuxyHGFcyJqvXhCpvYMUMDj3/NDGZz0bt kAjOxTO2VOf/ti+ncm7Mz2eNX4i83LInfVmeAfAlF15ILh5WnyzBJ6iSuT7M1kR9lsbo C3eoIqRUNX8sS7hl5y0C3jTX06O3qfV0ccJjs=

I need it exactly the other way round. I simple don't get it from the
opensaml user documentation:
https://spaces.internet2.edu/display/OpenSAML/OSTwoUsrManJavaAnyTypes

My code snippet constructs a ResourceContentType and tries to place
the body of a soap
request as content in the object.


import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.opensaml.xacml.ctx.ResourceContentType;
import org.opensaml.xml.Configuration;
import org.opensaml.xml.XMLObject;
import org.opensaml.xml.XMLObjectBuilder;
import org.opensaml.xml.io.Marshaller;
import org.opensaml.xml.io.MarshallerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class SamlTest {

public SamlTest() {

}

private XMLObject buildXMLObject(QName objectQName) throws Exception{
XMLObjectBuilder builder =
Configuration.getBuilderFactory().getBuilder(objectQName);
if(builder == null){
System.err.println("Unable to retrieve builder for
object QName " +
objectQName);
throw new Exception("Unable to retrieve builder for
object QName "
+ objectQName);
}
XMLObject obj =
builder.buildObject(objectQName.getNamespaceURI(),
objectQName.getLocalPart(), objectQName.getPrefix());
return obj;
}

private ResourceContentType buildResourceCotentType(Element soapBody)
throws Exception {
ResourceContentType resourceContent =
(ResourceContentType)buildXMLObject(new
QName("urn:oasis:names:tc:xacml:2.0:context:schema:os",
"ResourceContent", "xacml-context"));
resourceContent.getUnknownXMLObjects().add(soapBody); //
ClassCast expression
return resourceContent;

}

public void run() throws Exception {


DocumentBuilderFactory dbfac =
DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element fakeSoapBody = doc.createElement("soapbody");
//let's assume the fakeSoapBody was extracted from a SOAP
request.
ResourceContentType resourceContent =
buildResourceCotentType(fakeSoapBody);

MarshallerFactory marshallerFactory =
Configuration.getMarshallerFactory();
Marshaller marshaller =
marshallerFactory.getMarshaller(resourceContent);
Element resourceElement = marshaller.
marshall(resourceContent);
MyXmlPrettyPrinter2 pp = new MyXmlPrettyPrinter2();
pp.serialize(resourceElement.getOwnerDocument(), System.out);


}


}


On Tue, Sep 30, 2008 at 3:38 PM, Håkon Sagehaug
<>
wrote:
> Hi
>
> I tried to unmarshal, with ResourceContentUnamrshaller, xml like this
>
>
> <xacml-context:ResourceContent
> xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os">
> <Element xmlns:xs="http://www.w3.org/2001/XMLSchema";
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:type="xs:string">
> test
> </Element>
> </xacml-context:ResourceContent>
>
> This worked fine, is this much different from what you want?
>
> Håkon
> 2008/9/30 Michael Lausch
> <>
>>
>> On Tue, Sep 30, 2008 at 3:14 PM, Håkon Sagehaug
>> <>
>> wrote:
>> > Hi
>> >
>> > Normally as i remember if you want something form DOM to java object in
>> > opensaml you use the unmarshaller for that object you want.. So for
>>
>> The problem is that i don't know what object it will be.
>> The gaol is to authorise webservice requests with XACML. The plan is to
>> take the SOAP body of the request, put the DOM in the ResourceContent and
>> pass it to the XACML evaluation, which in turn will use use XPath
>> expressions
>> in XACML policy files to extract the values it needs for evaluation.
>>
>>
>> > ResourceContent it would be the ResourceContentUnmarshaller.
>>
>> ResourceContent is an XML any type. I don't think you can write an
>> unmarshaller for this.
>>
>>
>> >
>> > Also content.getContent() methog I cant see ResourceContentType in
>> > opensaml. what library are you using.
>>
>> i just saw that the snippet uses the jboss xacml opensaml extensions.
>> Maybe this is the wrong mailinglist to ask.
>>
>> Nevertheless i also did not manage to implement it using only opensaml.
>
>
>
> --
> Håkon Sagehaug, Software Developer
> Parallab, Bergen Center for Computational Science (BCCS)
> UNIFOB AS (University of Bergen Research Company)
>



Archive powered by MHonArc 2.6.16.

Top of Page