eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
202 stars 110 forks source link

DTD namespace is all-or-nothing #253

Open Tomas-Kraus opened 18 years ago

Tomas-Kraus commented 18 years ago

Given the following DTD:

<!ELEMENT TEST (SUB_TEST*, Signature?)> <!ELEMENT SUB_TEST EMPTY> <!ENTITY % signature.dtd SYSTEM "signature.dtd"> %signature.dtd;

And the included signature.dtd:

<!ENTITY % Object.ANY ''> <!ENTITY % Method.ANY ''> <!ENTITY % Transform.ANY ''> <!ENTITY % SignatureProperty.ANY ''> <!ENTITY % KeyInfo.ANY ''> <!ENTITY % KeyValue.ANY ''> <!ENTITY % PGPData.ANY ''> <!ENTITY % X509Data.ANY ''> <!ENTITY % SPKIData.ANY ''>

<!ELEMENT Signature (SignedInfo, SignatureValue, KeyInfo?, Object*)> <!ATTLIST Signature xmlns CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#" Id ID #IMPLIED

<!ELEMENT SignatureValue (#PCDATA)> <!ATTLIST SignatureValue Id ID #IMPLIED

<!ELEMENT SignedInfo (CanonicalizationMethod, SignatureMethod, Reference+)> <!ATTLIST SignedInfo Id ID #IMPLIED

<!ELEMENT CanonicalizationMethod (#PCDATA %Method.ANY* > <!ATTLIST CanonicalizationMethod Algorithm CDATA #REQUIRED

<!ELEMENT SignatureMethod (#PCDATA|HMACOutputLength %Method.ANY* > <!ATTLIST SignatureMethod Algorithm CDATA #REQUIRED

<!ELEMENT Reference (Transforms?, DigestMethod, DigestValue)> <!ATTLIST Reference Id ID #IMPLIED URI CDATA #IMPLIED Type CDATA #IMPLIED

<!ELEMENT Transforms (Transform+)> <!ELEMENT Transform (#PCDATA|XPath %Transform.ANY* > <!ATTLIST Transform Algorithm CDATA #REQUIRED

<!ELEMENT XPath (#PCDATA)> <!ELEMENT DigestMethod (#PCDATA %Method.ANY* > <!ATTLIST DigestMethod Algorithm CDATA #REQUIRED

<!ELEMENT DigestValue (#PCDATA)> <!ELEMENT KeyInfo (#PCDATA|KeyName|KeyValue|RetrievalMethod| X509Data|PGPData|SPKIData|MgmtData %KeyInfo.ANY* > <!ATTLIST KeyInfo Id ID #IMPLIED

<!ELEMENT KeyName (#PCDATA)> <!ELEMENT KeyValue (#PCDATA|DSAKeyValue|RSAKeyValue %KeyValue.ANY* > <!ELEMENT MgmtData (#PCDATA)> <!ELEMENT RetrievalMethod (Transforms?)> <!ATTLIST RetrievalMethod URI CDATA #REQUIRED Type CDATA #IMPLIED

<!ELEMENT X509Data ((X509IssuerSerial | X509SKI | X509SubjectName | X509Certificate | X509CRL )+ %X509Data.ANY> <!ELEMENT X509IssuerSerial (X509IssuerName, X509SerialNumber)> <!ELEMENT X509IssuerName (#PCDATA)> <!ELEMENT X509SubjectName (#PCDATA)> <!ELEMENT X509SerialNumber (#PCDATA)> <!ELEMENT X509SKI (#PCDATA)> <!ELEMENT X509Certificate (#PCDATA)> <!ELEMENT X509CRL (#PCDATA)>

<!ELEMENT PGPData ((PGPKeyID, PGPKeyPacket?) | (PGPKeyPacket) %PGPData.ANY > <!ELEMENT PGPKeyPacket (#PCDATA)> <!ELEMENT PGPKeyID (#PCDATA)>

<!ELEMENT SPKIData (SPKISexp %SPKIData.ANY > <!ELEMENT SPKISexp (#PCDATA)>

<!ELEMENT Object (#PCDATA|Signature|SignatureProperties|Manifest %Object.ANY* > <!ATTLIST Object Id ID #IMPLIED MimeType CDATA #IMPLIED Encoding CDATA #IMPLIED

<!ELEMENT Manifest (Reference+)> <!ATTLIST Manifest Id ID #IMPLIED

<!ELEMENT SignatureProperties (SignatureProperty+)> <!ATTLIST SignatureProperties Id ID #IMPLIED

<!ELEMENT DateTimeStamp EMPTY> <!ATTLIST DateTimeStamp DateTime CDATA #REQUIRED>

<!ELEMENT SignatureProperty (#PCDATA| DateTimeStamp %SignatureProperty.ANY* > <!ATTLIST SignatureProperty Target CDATA #REQUIRED Id ID #IMPLIED

<!ELEMENT HMACOutputLength (#PCDATA)> <!ELEMENT DSAKeyValue ((P, Q)?, G?, Y, J?, (Seed, PgenCounter)?)> <!ELEMENT P (#PCDATA)> <!ELEMENT Q (#PCDATA)> <!ELEMENT G (#PCDATA)> <!ELEMENT Y (#PCDATA)> <!ELEMENT J (#PCDATA)> <!ELEMENT Seed (#PCDATA)> <!ELEMENT PgenCounter (#PCDATA)> <!ELEMENT RSAKeyValue (Modulus, Exponent)> <!ELEMENT Modulus (#PCDATA)> <!ELEMENT Exponent (#PCDATA)>

And the sample XML:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE TEST PUBLIC "" "test.dtd">

xjc produces code that fails to unmarshall the above XML, reporting that it expects to find a root TEST with namespace URI "http://www.w3.org/2000/09/xmldsig#"

Removing the xmlns attribute from the Signature element (in signature.dtd) results in code that will marshall and unmarshall without error, but also has the effect of stripping the xmlns attribute from the Signature element, which breaks signature verification.

Environment

Operating System: All Platform: All

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

Tomas-Kraus commented 6 years ago
Tomas-Kraus commented 18 years ago

@glassfishrobot Commented Reported by rshan

Tomas-Kraus commented 18 years ago

@glassfishrobot Commented kohsuke said: DTD and namespaces really don't work well, so I think some kind of heuristic like what XJC does today is needed.

Do you have some suggestions as to how to make this work?

One dumb approach is to let you specify what element is supposed to be in what namespace, maybe in a property file or something.

Tomas-Kraus commented 18 years ago

@glassfishrobot Commented rshan said: How about allowing disablement of dtd namespace support so that 'xmlns' is simply treated as an attribute?

Tomas-Kraus commented 18 years ago

@glassfishrobot Commented kohsuke said: That requires the runtime to be aware of such mode, as well as some annotations to communicate to the runtime that these classes are supposed to be namespace-unaware.

No, that's not going to work. It's just too expensive.

Tomas-Kraus commented 17 years ago

@glassfishrobot Commented kohsuke said: Reclassifying as this is an enhancement request.

Tomas-Kraus commented 18 years ago

@glassfishrobot Commented Was assigned to jaxb-issues

Tomas-Kraus commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-253