[OpenSaml] normalize namespace

5 views
Skip to first unread message

alessio.l...@iit.cnr.it

unread,
Mar 23, 2012, 10:54:10 AM3/23/12
to d...@shibboleth.net
After a lot of trouble i successfully transform a ResponseCtx from
SunXAML PDP to org.opensaml.xacml.ctx.ResponseType.

But now the situation is:
<xacml-context:Response
xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os">
<Result ResourceId="ID_REID"

xmlns="urn:oasis:names:tc:xacml:2.0:context:schema:os">
<Decision>NotApplicable</Decision>
<Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
</Status>
</Result>
</xacml-context:Response>

Is there a way to normalize namespace like:
<xacml-context:Response
xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os">
<xacml-context:Result ResourceId="REID">
<xacml-context:Decision>NotApplicable</xacml-context:Decision>
<xacml-context:Status>
<xacml-context:StatusCode
Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
</xacml-context:Status>
</xacml-context:Result>
</xacml-context:Response>

the second one was hand-made by me with:
XMLObjectBuilderFactory xmlfac= Configuration.getBuilderFactory();
ResponseTypeImplBuilder builder=(ResponseTypeImplBuilder)
xmlfac.getBuilder(ResponseType.DEFAULT_ELEMENT_NAME);
ResponseType testresponse=builder.buildObject();

ResultTypeImplBuilder b1=(ResultTypeImplBuilder)
xmlfac.getBuilder(ResultType.DEFAULT_ELEMENT_NAME);
ResultType resulttype=b1.buildObject();
DecisionTypeImplBuilder b2=(DecisionTypeImplBuilder)
xmlfac.getBuilder(DecisionType.DEFAULT_ELEMENT_NAME);
DecisionType decisiontype=b2.buildObject();
StatusTypeImplBuilder b3=(StatusTypeImplBuilder)
xmlfac.getBuilder(StatusType.DEFAULT_ELEMENT_NAME);
StatusType statustype=b3.buildObject();

StatusCodeTypeImplBuilder b4=(StatusCodeTypeImplBuilder)
xmlfac.getBuilder(StatusCodeType.DEFAULT_ELEMENT_NAME);
StatusCodeType statuscodetype=b4.buildObject();

statuscodetype.setValue(StatusCodeType.SC_OK);

statustype.setStatusCode(statuscodetype);
decisiontype.setDecision(DECISION.NotApplicable);

resulttype.setDecision(decisiontype);
resulttype.setStatus(statustype);
resulttype.setResourceId("REs IDID");


testresponse.setResult(resulttype);


Thx in advice at all.
Bye,
Alessio
--
To unsubscribe from this list send an email to dev-uns...@shibboleth.net

Brent Putman

unread,
Mar 23, 2012, 12:49:29 PM3/23/12
to d...@shibboleth.net
If the first example is the way it came back from the PDP, then that
must be what the PDP emitted, so that's what the parsed DOM looks like,
before you unmarshall using OpenSAML.

OpenSAML should handle them equivalently, in terms of the XMLObject tree
that it builds when it unmarshalls. The only delta would be the cached DOM.

Question: why do you think it's necessary to "normalize the
namespace"? If the recipient is just going to process the response as
the XMLObject tree, then the namespace decl usage really won't matter.

But if you really, really wanted to make the response you got from the
PDP look like what you built, you could (I think) just drop the cached
DOM from the XMLObject tree, and then re-marshall it. That's
inefficient but it's the only obvious easy way. You could also just fix
up the parsed DOM before you unmarshall it, but that then becomes a DOM
API question, not an OpenSAML one.

--Brent

alessio.l...@iit.cnr.it

unread,
Mar 23, 2012, 1:09:17 PM3/23/12
to d...@shibboleth.net
Thx Brent,
i also tryed somethings with namespacemanager but with no success:
Namespace ns1=new Namespace("testURI","testPrefix");
rt.getNamespaceManager().registerAttributeName(ResponseType.DEFAULT_ELEMENT_NAME);
rt.getNamespaceManager().registerElementName(ResponseType.DEFAULT_ELEMENT_NAME);
rt.getNamespaceManager().registerNamespace(ns1);
rt.getNamespaceManager().registerNamespaceDeclaration(ns1);
nothing happen :)
so you know what? The answer from pdp it's correcly handled by pep, so
give up :)

Thx again for attention.

Reply all
Reply to author
Forward
0 new messages