EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Adding SPURI to the XAdES elements

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#37671
Posted: 09/09/2016 05:09:32
by Olivier Sannier (Basic support level)
Joined: 09/08/2016
Posts: 6

Hello,

I'm trying to add a SPURI element to the SigPolicyQualifiers collection inside the XAdES part of my signature.
Looking at the documentation, I found this link:
https://www.eldos.com/documentation/sbb/documentation/ref_cl_xmlspuri.html

Despite its lack of documentation, I thought from its name that it's what I'm looking for.
I thus tried to do this:

Code
TElXMLSPURI SPURI = new TElXMLSPURI(XAdESSigner.XAdESVersion);
SPURI.URI = "http://www.some.site.com/somefile.pdf";
XAdESSigner.PolicyId.SigPolicyQualifiers.Add(SPURI);


However, this does not compile because SPURI is not of the appropriate type.
In the end I'm doing this:

Code
TElXMLAnyType Qualifier = new TElXMLAnyType(XAdESSigner.XAdESVersion, "");
TElXMLDOMDocument DummyDocument = new TElXMLDOMDocument();
TElXMLDOMElement QualifierElement = DummyDocument.CreateElement("Qualifier");
TElXMLDOMElement SPURIElement = DummyDocument.CreateElement("xad:SPURI");
SPURIElement.TextContent = "http://www.some.site.com/somefile.pdf";
QualifierElement.AppendChild(SPURIElement);
Qualifier.Value = QualifierElement;
XAdESSigner.PolicyId.SigPolicyQualifiers.Add(Qualifier);


It works as it gives me this:

Code
<xad:SigPolicyQualifiers>
  <xad:SigPolicyQualifier><xad:SPURI>http://www.some.site.com/somefile.pdf</xad:SPURI>
  </xad:SigPolicyQualifier>
</xad:SigPolicyQualifiers>


But I find this very verbose because I have to create a dummy document, then have to repeat the XAdES prefix inside the CreateElement call.

Is there a better way to declare all this, or will it be part of a future update?
#37674
Posted: 09/09/2016 08:38:31
by Dmytro Bogatskyy (EldoS Corp.)

Hi,

Quote
However, this does not compile because SPURI is not of the appropriate type.
Is there a better way to declare all this, or will it be part of a future update?

We will consider adding TElXMLSigPolicyQualifierList.Add() method overloads to support TElXMLSPURI objects.
Thank you for pointing this out.
Quote
But I find this very verbose because I have to create a dummy document, then have to repeat the XAdES prefix inside the CreateElement call.

You don't need to use a dummy document, you can use a current xml document object to create elements.
Quote
TElXMLDOMElement SPURIElement = DummyDocument.CreateElement("xad:SPURI");

Here, you should use CreateElementNS() method and specify element NamespaceURI in it.
#37677
Posted: 09/09/2016 09:11:37
by Olivier Sannier (Basic support level)
Joined: 09/08/2016
Posts: 6

Thanks for your answer.

As I'm creating a detached signature, I don't have a XML document just yet.
Thanks for pointing out the CreateElementNS method, I'm now using this:

Code
TElXMLDOMElement SPURIElement = DummyDocument.CreateElementNS(SBXMLAdES.Unit.GetXAdESNamespaceURI(XAdESSigner.XAdESVersion), "SPURI");


This way it will always have the correct value should I ever change the XAdES version that I use, and it adds automatically the appropriate prefix.
#37685
Posted: 09/09/2016 18:30:34
by Dmytro Bogatskyy (EldoS Corp.)

Hi,

Thank you for sharing the code.

Reply

Statistics

Topic viewed 524 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!