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: "Håkon Sagehaug" <>
- To:
- Subject: Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml.
- Date: Wed, 1 Oct 2008 16:27:58 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:references:x-google-sender-auth; b=XzVnC5BUh/zrb1bWAUMNjaiOuxMx9VSWWvSaiSDyTHXQhn0ghTI2lME0o/fTm0e4wl QSJXuLHLW5GtxlFgfg94fRDI/8cbo+xbmMbcvI5nS2x0wMQoQ5dFASG/3vyqDs/B3qXU pH7rFSCcphm/wlLetzetMBEjHoW+MQ0JZX4Xs=
Hi
Again my little example
<plb:Element xmlns:plb="http://plb.bccs.uib.no" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">test</plb:Element>
for unmarshalling it to a java object I did this
Unmarshaller unMarshaller = unMarshallerFactory.getUnmarshaller(doc
.getDocumentElement());
XMLObject ob = (XMLObject) unMarshaller.unmarshall(doc
.getDocumentElement());
where doc is the document xml, I get my input form a file. then I could add it to the unknown list of children as some
xacmlResource.getResourceContent().getUnknownXMLObjects().add(ob);
Håkon
--
Håkon Sagehaug, Software Developer
Parallab, Bergen Center for Computational Science (BCCS)
UNIFOB AS (University of Bergen Research Company)
Again my little example
<plb:Element xmlns:plb="http://plb.bccs.uib.no" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">test</plb:Element>
for unmarshalling it to a java object I did this
Unmarshaller unMarshaller = unMarshallerFactory.getUnmarshaller(doc
.getDocumentElement());
XMLObject ob = (XMLObject) unMarshaller.unmarshall(doc
.getDocumentElement());
where doc is the document xml, I get my input form a file. then I could add it to the unknown list of children as some
xacmlResource.getResourceContent().getUnknownXMLObjects().add(ob);
Håkon
2008/10/1 Michael Lausch <>
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)
>
--
Håkon Sagehaug, Software Developer
Parallab, Bergen Center for Computational Science (BCCS)
UNIFOB AS (University of Bergen Research Company)
- Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Michael Lausch, 10/01/2008
- Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Håkon Sagehaug, 10/01/2008
- Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Michael Lausch, 10/01/2008
- Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Michael Lausch, 10/01/2008
- RE: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Scott Cantor, 10/01/2008
- Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Brent Putman, 10/01/2008
- Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Michael Lausch, 10/02/2008
- Re: [OpenSAML] unable to add ResourceContent (XML any type) to Resource attribute with opensaml., Håkon Sagehaug, 10/01/2008
Archive powered by MHonArc 2.6.16.