Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ codeunit 1460 SignedXml
SignedXmlImpl.InitializeReference(Uri);
end;

/// <summary>
/// Sets the type Uniform Resource Identifier (URI) of the current Reference.
/// </summary>
/// <param name="Type">The type URI of the current Reference.</param>
procedure SetReferenceType(Type: Text)
begin
SignedXmlImpl.SetReferenceType(Type);
end;

/// <summary>
/// Sets the digest method Uniform Resource Identifier (URI) of the current Reference.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ codeunit 1461 "SignedXml Impl."
DotNetReference := DotNetReference.Reference(Uri);
end;

procedure SetReferenceType(Type: Text)
begin
DotNetReference.Type := Type;
end;

procedure SetDigestMethod(DigestMethod: Text)
begin
DotNetReference.DigestMethod := DigestMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,43 @@ codeunit 132612 "Signed Xml Module Test"
LibraryAssert.IsTrue(SignedXml.CheckSignature(CertBase64Data, Password, true), 'Failed to verify the xml signature.');
end;

[Test]
procedure SetReferenceType()
var
SignatureKey: Codeunit "Signature Key";
XmlToSign: XmlDocument;
KeyText: SecretText;
Signature: XmlElement;
NamespaceMgr: XmlNamespaceManager;
Node: XmlNode;
SignatureNamespaceUriTok: Label 'http://www.w3.org/2000/09/xmldsig#', Locked = true;
ReferenceTypeTok: Label 'http://uri.etsi.org/01903#SignedProperties', Locked = true;
begin
XmlDocument.ReadFrom('<XmlData Id="ID01">This is a document</XmlData>', XmlToSign);
GetSignatureKeyXmlString(KeyText);
SignatureKey.FromXmlString(KeyText);

SignedXml.InitializeSignedXml(XmlToSign);
SignedXml.SetSigningKey(SignatureKey);
SignedXml.InitializeReference('#ID01');
SignedXml.SetReferenceType(ReferenceTypeTok);
SignedXml.AddReferenceToSignedXML();

SignedXml.ComputeSignature();
Signature := SignedXml.GetXml();

NamespaceMgr.AddNamespace('ns', SignatureNamespaceUriTok);
Signature.SelectSingleNode(
'./ns:SignedInfo/ns:Reference/@Type',
NamespaceMgr,
Node);

LibraryAssert.AreEqual(
ReferenceTypeTok,
Node.AsXmlAttribute().Value,
'Incorrect reference type was applied.');
end;

[Test]
procedure SetXmlDSigC14NTranform()
var
Expand Down
Loading