Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.
Merged
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 @@ -37,6 +37,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
92 changes: 79 additions & 13 deletions dotnet/dotnetframework/GeneXusXmlSignature/Utils/SignatureUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,37 +150,103 @@ internal static bool validateExtensionSchema(string path)
}


internal static XmlNode getNodeFromID(XmlDocument doc, string id, string xPath, Error error)
/* internal static XmlNode getNodeFromID(XmlDocument doc, string id, string xPath, Error error)
{
if (id == null || SecurityUtils.compareStrings(id, ""))
{
error.setError("SU010", "Error, id data is empty");
return null;
}
string idToFind = xPath.Substring(1);
XmlNode rootNode = doc.DocumentElement;
XmlNodeList allNodes = rootNode.ChildNodes;
foreach (XmlNode node in allNodes)
{

XmlAttributeCollection attributes = node.Attributes;
if (attributes != null)
{
foreach (XmlAttribute attribute in node.Attributes)
{
if (SecurityUtils.compareStrings(attribute.Name, id) && SecurityUtils.compareStrings(attribute.Value, idToFind))
{
return node;
}
}
}


}
error.setError("SU009", "Could not found element attribute " + id + " with id: " + idToFind);
return null;
}*/

internal static XmlNode getNodeFromID(XmlDocument doc, String id, String xPath, Error error)
{
if (id == null || SecurityUtils.compareStrings(id, ""))
{
error.setError("SU010", "Error, id data is empty");
return null;
}
string idToFind = xPath.Substring(1);
XmlNode rootNode = doc.DocumentElement;
XmlNodeList allNodes = rootNode.ChildNodes;
foreach (XmlNode node in allNodes)
XmlNode root = doc.DocumentElement;
XmlNodeList allNodes = root.ChildNodes;

XmlNode n = RecursivegetNodeFromID(allNodes, id, idToFind);
if (n == null)
{
error.setError("SU009", "Could not find element with id " + idToFind);
}
return n;

XmlAttributeCollection attributes = node.Attributes;
if (attributes != null)
}

private static XmlNode FindAttribute(XmlNode node, String id, String idToFind)
{
XmlAttributeCollection attributes = node.Attributes;
if (attributes != null)
{
foreach (XmlAttribute attribute in node.Attributes)
{
foreach (XmlAttribute attribute in node.Attributes)
if (SecurityUtils.compareStrings(attribute.Name, id) && SecurityUtils.compareStrings(attribute.Value, idToFind))
{
if (SecurityUtils.compareStrings(attribute.Name, id) && SecurityUtils.compareStrings(attribute.Value, idToFind))
return node;
}
}
}
return null;
}

private static XmlNode RecursivegetNodeFromID(XmlNodeList list, String id, String idToFind)
{
if (list.Count == 0)
{
return null;
}
else
{
for (int i = 0; i < list.Count; i++)
{
XmlNode node = FindAttribute(list.Item(i), id, idToFind);
if (node == null)
{
XmlNode n1 = RecursivegetNodeFromID(list.Item(i).ChildNodes, id, idToFind);
if (n1 != null)
{
return node;
return n1;
}
}
else
{
return node;
}
}


return null;
}
error.setError("SU009", "Could not found element attribute " + id + " with id: " + idToFind);
return null;
}



internal static string getIDNodeValue(XmlDocument doc)
{
doc.PreserveWhitespace = true;
Expand Down