Skip to Content.
Sympa Menu

mace-opensaml-users - Extending Statements. Problems with toDOM() method

Subject: OpenSAML user discussion

List archive

Extending Statements. Problems with toDOM() method


Chronological Thread 
  • From: Oscar Canovas Reverte <>
  • To:
  • Subject: Extending Statements. Problems with toDOM() method
  • Date: Fri, 02 Apr 2004 20:35:25 +0200
  • Organization: Universidad de Murcia

Hi again,

As I commented in a previous email, I have been programming some
classes extending OpenSAML. One of those classes is the extension of a
SubjectStatement, named "SimpleAuthorizationDecisionStatement". In order
to test the class, I create a SAMLResponse, and I put into it an
assertion containing my statement. Then, I call the method toStream()
and I obtain the corresponding XML representation:

<Response
xmlns="urn:oasis:names:tc:SAML:1.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"
InResponseTo="NULL" IssueInstant="2004-04-02T18:10:42Z"
MajorVersion="1" MinorVersion="1" Recipient="Test"
ResponseID="df167df225b18f6903dedd3686ad108e">
<Status>
<StatusCode Value="samlp:Success">
</StatusCode></Status>
<Assertion xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
AssertionID="c4a0624600843a2f67a7a20e82045a0c"
IssueInstant="2004-04-02T18:10:43Z" Issuer="Test" MajorVersion="1"
MinorVersion="1">
<Conditions NotBefore="2004-04-02T18:10:42Z"
NotOnOrAfter="2004-04-02T18:10:42Z">
</Conditions>
<saml:SubjectStatement xmlns="urn:oasis:names:tc:SAML:1.0:ogsa-saml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
Decision="Deny"
InResponseTo="NOQUERY"
Recipient="NORECIPIENT"
xsi:type="ogsa-saml:SimpleAuthorizationDecisionStatementType">
<Subject xmlns="urn:oasis:names:tc:SAML:1.0:assertion">
<NameIdentifier Format="Free" NameQualifier="OGSASAML">
OGSASAML Test Subject
</NameIdentifier>
</Subject>
</saml:SubjectStatement>
</Assertion>
</Response>

It looks that everything is ok, however when I store the resulting XML
document, and I pass back it to the SAMLResponse constructor, I get the
following error message:

org.xml.sax.SAXParseException: UndeclaredPrefix:
Cannot resolve 'ogsa-saml:SimpleAuthorizationDecisionStatementType' as a
QName: the prefix 'ogsa-saml' is not declared.

at org.opensaml.SAMLObject.fromStream(Unknown Source)
at org.opensaml.SAMLResponse.<init>(Unknown Source)
at
org.opensaml.OGSASAMLTest.testResponseAndSimpleDecision(OGSASAMLTest.java:68)
at org.opensaml.OGSASAMLTest.main(OGSASAMLTest.java:24)


I know that the problem is that the saml:SubjectStatement element should
contain and attribute like xmlns:ogsa-saml="mynamespace", but I can't
insert it, despite my toDOM() method is as follows:


public Node toDOM(Document doc) {
if ((root = super.toDOM(doc)) != null)
return root;

Element s = doc.createElementNS(XML.SAML_NS,
"saml:SubjectStatement");
s.setAttributeNS(XML.XMLNS_NS, "xmlns",OGSASAML.OGSASAML_NS);
s.setAttributeNS(XML.XMLNS_NS, "xmlns:xsi", XML.XSI_NS);
s.setAttributeNS(XML.XMLNS_NS, "xmlns:saml", XML.SAML_NS);
//I TRY TO INCLUDE THE NEEDED ATTRIBUTE (PREFIX DEFINITION)
s.setAttributeNS(XML.XMLNS_NS,"xmlns:ogsa-saml",OGSASAML.OGSASAML_NS);
s.setAttributeNS(XML.XSI_NS,
"xsi:type","ogsa-saml:SimpleAuthorizationDecisionStatementType");
s.setAttributeNS(null, "Decision", decision);
s.setAttributeNS(null, "InResponseTo", inResponseTo);
s.setAttributeNS(null, "Recipient", recipient);
s.appendChild(subject.toDOM(doc));

return root = s;
}

Why is not present the prefix definition in the XML document despite I
include the attribute "xmlns:ogsa-saml"?

When I save the XML document in a file and I add the attribute by
hand, I can check that the modified XML document is processed properly,
and my SimpleAuthorizationDecisionStatement instace contains the right
values.

Any idea?

Thanks in advance.

--
=============================================
Óscar Cánovas Reverte
Dept. Ingeniería y Tecnología de Computadores
University of Murcia - Spain
Telf: +34 968367344 - Fax: +34 968364151
email:

www: http://ditec.um.es/~ocanovas




Archive powered by MHonArc 2.6.16.

Top of Page