dsig prefix
- From: Ken Lemieux <KillerCoder@xxxxxxxxxxxxxxxx>
- Date: Mon, 3 Mar 2008 08:08:02 -0800
Hi,
I have a Clickonce application that contains a file element:
<file name="Properties\Resources\wecan32.ico" size="3262">
<hash>
<dsig:Transforms>
<dsig:Transform
Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>hKQC+HwduEy3n7PERz4GD3tPgME=</dsig:DigestValue>
</hash>
</file>
I've coded a routine that tries to duplicate the above XmlNode:
void FormFileAssociationCreator_IconFileElementEvent(object sender,
ResultsEventArgs e)
{
Cursor = Cursors.WaitCursor;
buildOutput.AppendLine(Resources.CreatingIconElement);
XmlDocument applicationManifestDoc = new XmlDocument();
try
{
textBoxOutput.Text =
buildOutput.AppendLine(Resources.AddingIconFileElement).ToString();
applicationManifestDoc.Load(comboBoxApplicationManifest.Text);
XmlNamespaceManager namespaceManager;
namespaceManager = new XmlNamespaceManager(new NameTable());
namespaceManager.AddNamespace("asmv1",
"urn:schemas-microsoft-com:asm.v1");
namespaceManager.AddNamespace("asmv2",
"urn:schemas-microsoft-com:asm.v2");
XmlNode applicationNode =
applicationManifestDoc.SelectSingleNode("/asmv1:assembly/asmv2:application",
namespaceManager);
//create the icon node and add it following the application
node
XmlNode iconNode = CreateIconElement(applicationManifestDoc);
applicationNode.ParentNode.InsertAfter(iconNode,
applicationNode);
XmlNode hashNode =
applicationManifestDoc.CreateNode(XmlNodeType.Element, "hash", null);
iconNode.AppendChild(hashNode);
XmlNode transformsNode =
applicationManifestDoc.CreateNode(XmlNodeType.Element, @"dsig:Transforms",
null);
hashNode.AppendChild(transformsNode);
XmlNode transformNode =
applicationManifestDoc.CreateNode(XmlNodeType.Element, @"dsig:Transform",
null);
XmlNode transformAlgorithmAttrib =
applicationManifestDoc.CreateNode(XmlNodeType.Attribute, "Algorithm", null);
transformAlgorithmAttrib.Value =
"urn:schemas-microsoft-com:HashTransforms.Identity";
transformNode.Attributes.SetNamedItem(transformAlgorithmAttrib);
transformsNode.AppendChild(transformNode);
XmlNode digestMethodNode =
applicationManifestDoc.CreateNode(XmlNodeType.Element, @"dsig:DigestMethod",
null);
XmlNode digestMethodAttrib =
applicationManifestDoc.CreateNode(XmlNodeType.Attribute, "Algorithm", null);
digestMethodAttrib.Value =
"http://www.w3.org/2000/09/xmldsig#sha1";
digestMethodNode.Attributes.SetNamedItem(digestMethodAttrib);
hashNode.AppendChild(digestMethodNode);
XmlNode digestValueNode =
applicationManifestDoc.CreateNode(XmlNodeType.Element, @"dsig:DigestValue",
null);
hashNode.AppendChild(digestValueNode);
XmlNode digestValueTextNode =
applicationManifestDoc.CreateNode(XmlNodeType.Text, @"dsig:DigestValue",
null);
hashNode.AppendChild(digestValueTextNode);
FileInfo iconFileInfo = new
FileInfo(comboBoxIconFile.SelectedItem.ToString());
Stream iconStream = iconFileInfo.OpenRead();
SHA1Managed iconHash = new SHA1Managed();
byte[] iconHashBytes = iconHash.ComputeHash(iconStream);
digestValueTextNode.Value =
Convert.ToBase64String(iconHashBytes);
applicationManifestDoc.Save(comboBoxApplicationManifest.Text);
textBoxOutput.Text =
buildOutput.AppendLine(Resources.AddedIconFileElement).ToString();
}
My out put is nearly whats expected except absent is the dsig: prefix on the
hash elements nodes:
<file name="\Properties\Resources\wecan32.ico" size="3262" xmlns="">
<hash>
<Transforms>
<Transform
Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue />hKQC+HwduEy3n7PERz4GD3tPgME=
</hash>
</file>
So my question is how can my impementation be changed so dsig: prefix is
added?
--
Kenneth Lemieux
Project Engineer
Whelen Engineering Co., Inc.
.
- Follow-Ups:
- Re: dsig prefix
- From: Martin Honnen
- Re: dsig prefix
- Prev by Date: Re: .net and XML schema *.XSD ???
- Next by Date: [announce] Free XQuery Tutorial Event
- Previous by thread: Re: XpathNavigtor or XmlNode which one is better?
- Next by thread: Re: dsig prefix
- Index(es):