EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Signing xml error.cant load document

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#15273
Posted: 12/11/2010 15:45:29
by Dmytro Bogatskyy (EldoS Corp.)

There is no special classes to manage Oasis SOAP Security specific elements. You can create a SecurityTokenReference node and place it into ElXMLKeyInfo instance.
For example:
Code
...
ElXMLSigner.Sign(); // Generate signature structure
...
KeyInfoNode := TElXMLKeyInfoNode.Create(true);
KeyInfoNode.Value := SecurityTokenReference node // for example created with XMLDocument.CreateElementNS('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'SecurityTokenReference') method
ElXMLSigner.Signature.KeyInfo.Add(KeyInfoNode);
...
ElXMLSigner.Save();
#15296
Posted: 12/13/2010 10:19:20
by San P (Standard support level)
Joined: 11/07/2009
Posts: 37

Quote
Dmytro Bogatskyy wrote:
ElXMLSigner.Signature.KeyInfo.Add(KeyInfoNode);

Thanks a lot, that was an exact solution to my problem.

Yet I have a few more XML formatting questions of the same kind. The XmlBlackbox code just starts to be too splitted around and too complex to me to be able to find the right methods and tweaks myself.

1. This is how I create Canonicalization node:
Code
aElXMLC14NTransform := TElXMLC14NTransform.Create;
aElXMLC14NTransform.CanonicalizationMethod := xcmExclCanon;

and it will make output like this:
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>

Yet I would need to get ouput like this:
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>

I can see that exactly the right kind of string http://www.w3.org/2001/10/xml-exc-c14n# is available in XMLBlackbox resources. None of my testings with all the other Canonicalization methods and properties seem to bring that string out.

2. This is the standard first line for most of the SOAP documents:
<soapenv:Envelope xmlns:cor="http://bxd...
so they start without the standard first line of XML files like:
<?xml version="1.0" encoding="utf-8"?>.

Is there any way how I could get XmlBlackbox to leave that first line out, and thus make the output look like those SOAP messages?

3. A XML node that does not have child nodes can be marked like this.
Code
<ds:Reference URI="#id-4453191">
</ds:Reference>

    or the same thing can be written in one line in shortened mode:

<ds:Reference URI="#id-4453191"/>


Is there any means how I could force XmlBlackbox to use the first one, the long marking method? Some other XML-manipulating tools have property named "UseFullNodes" that can be set, and it then uses full notation everywhere.

That would easen the testing phase with the the SOAP Server side folks. All the XML they self use is written using the longer notation. And this makes the comparing, debugging and finding the XML differences always slightly more complicated.

If the item 3. is not possible without big coding effort, I can live with it. But those 1. and 2. I would really appreciate some hint how to get around of them.

Thanks.
SP
#15297
Posted: 12/13/2010 15:10:25
by Dmytro Bogatskyy (EldoS Corp.)

Quote
This is how I create Canonicalization node: Code
aElXMLC14NTransform := TElXMLC14NTransform.Create;
aElXMLC14NTransform.CanonicalizationMethod := xcmExclCanon;

Where did you use aElXMLC14NTransform? In a reference?
Or you need to set exclusive canonicalization for the signature (SignedInfo element). In this case you need to modify ElXMLSigner.CanonicalizationMethod property
Quote

2. This is the standard first line for most of the SOAP documents:
<soapenv:Envelope xmlns:cor="http://bxd...
so they start without the standard first line of XML files like:
<?xml version="1.0" encoding="utf-8"?>.

You can save an xml document without header to unicode string using OuterXML property:
Data : UnicodeString := XMLDocument.DocumentElement.OuterXML;
Quote

Is there any means how I could force XmlBlackbox to use the first one, the long marking method? Some other XML-manipulating tools have property named "UseFullNodes" that can be set, and it then uses full notation everywhere.

There is no "UseFullNodes" property, but you can save xml document in canonical form to emulate this.
For example for above sample, use:
Data : UnicodeString := XMLDocument.DocumentElement.GetOuterXMLCanonical(xcmCanonComment);

Reply

Statistics

Topic viewed 7299 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!