|
I am trying to digitally sign an XML document in C++. Yes, I know that it is easy in .NET 2.0, but alas cannot use that!
An extract of the XML document is below.
All I am trying to do is calculate the DigestValue over the XML sub-document with Id=MsgOperation. I know that the data from this sub-document is converted into a hash with SHA-1 and then Base64.
The problem I am having is converting the sub-document using EXEC-C14N. I am trying to use the LibXML2 library (very good), to EXEC-C14N the sub-document with:
[code]
CString CDigitalCerts::C14N( const char* pszXml, const bool bExclusive )
{
CString sRet = _T("");
xmlChar* pOutput = NULL;
xmlDocPtr pXmlDoc = xmlReadMemory( pszXml, (int)strlen( pszXml ), _T("xml"), NULL, 0 );
int result = 0;
void* pData = NULL;
xmlOutputBufferPtr buf = 0;
if ( pXmlDoc )
{
result = xmlC14NDocDumpMemory( pXmlDoc,
NULL,
(int)bExclusive,
NULL,
0,
&pOutput );
}
xmlFreeDoc( pXmlDoc );
if ( result > 0 )
{
sRet = (LPCTSTR)pOutput;
}
xmlFree( pOutput );
pOutput = NULL;
return sRet;
}
[/code]
If anyone has used the xmlC14NDocDumpMemory function before from the libxml2 library and can advise what I need to add to its 2nd argv (nodes) or the 4th argv (inclusive_ns_prefixes), I would appreciate it. Or what the <ns1:operation ...="" xmlns:ns1="#unknown"> node once EXEC_C14N'ed looks like I would again be very grateful.
[code]
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns1:Operation Id="MsgOperation" soapenv:mustUnderstand="0" xsi:type="xsd:string" xmlns:ns1="http://www.ros.ie/schemas/service/" xmlns:xsi="http://w
ww.w3.org/2001/XMLSchema-instance">CT1/File</ns1:Operation>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">
...
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#MsgOperation">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
...
</ds:SignedInfo>
<ds:SignatureValue>
</ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference>
<wsse:Reference URI="#X509Token"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature></wsse:Security> </soapenv:Header>
[/code]
|
|
|
|
|
Andy H wrote: If anyone has used the xmlC14NDocDumpMemory function before from the libxml2 library
No, I have never used the libxml2 library.
Andy H wrote: can advise what I need to add to its 2nd argv (nodes) or the 4th argv (inclusive_ns_prefixes),
Does this help[^]?
led mike
|
|
|
|
|
Well what was the point of your reply? How f******* stupid.
|
|
|
|
|
Andy H wrote: Well what was the point of your reply?
The point was the link I supplied that appears to define the parameters you asked about, you f***ing moron. F*** off a**hole.
led mike
|
|
|
|
|
I am very sorry, I did not spot the link in your reply.
Thanks, but I have seen the page you referred to.
|
|
|
|
|
Andy H wrote: I am very sorry, I did not spot the link in your reply.
Oh, ok, no problem, simple mistake, I make them all the time, I even make complicated mistakes.
Andy H wrote: Thanks, but I have seen the page you referred to.
Ok then I need more specific information about what you need to know.
nodes : Is a NodeSet that will act like a filter so that it will only dump those nodes rather than the entire document.
inclusive_ns_prefixes : Is a string array of the namespaces, where the last element of the array is NULL.
Based on the doc you can pass NULL for both of those and it should still work.
led mike
|
|
|
|
|
I am currently parsing NULL to both those arguments. But because I am extracting the node with the Id attribute set to "MsgOperation", I am obviously missing namespace declarations etc that are in the parent node, as a result my computed DigestValue is incorrect.
All I require at the moment is for someone to let me know what the EXEC_C14N result of the said node which is then fed into the SHA-1 algorithm and Base64'ed the result of which (i.e. DigestValue) is:
wJsL4RtLToFeHW/xt2ewbAAiNxk=
That way at least I could get some idea of what the node is transformed into as a result of the EXEC_C14N process!
|
|
|
|
|
Andy H wrote: All I require at the moment is for someone to let me know what the EXEC_C14N result of the said node
Sorry, I don't have an environment established where I can do that. Since you have the XML yourself why can't you just give the namespace argument to the function?
led mike
|
|
|
|
|
I tried that, didn't work. I will be working on it further tomorrow. If I get it to work I will post what I did to resolve the issue.
|
|
|
|
|
Just to let anyone know, if they are interested, that I have manually worked out the result of the EXEC-C14N for the //ns1:Operation node of the XML posted in my orriginal message above, to be:
[code]
<ns1:Operation xmlns:ns1="http://www.ros.ie/schemas/service/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="MsgOperation" soapenv:mustUnderstand="0" xsi:type="xsd:string">CT1/File</ns1:Operation>
[/code]
This helped
|
|
|
|
|
Andy, I'm glad you solved your problem.
The only difference in your solution XML from your original post is the addition of
<br />
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
If that was the question you were asking I never even got close to understanding your question.
led mike
|
|
|
|
|
When you Canonicalize an XML sub-document you need to ensure that the namespace declarations used within that node but which were originally declared in an ancester node you need to re-declare in the node in which the namespace is being used in the sub-document. Then having done that you need to ensure that the namespace declarations are in order as per their prefix, AND any attributes but not in alphabetical order of the attribute or its prefix (if used) but per the order of the URI of that prefix... Get it!!!
Having solved that I have a much larger XML node structure extracted from the orginal XML document to sort out along the same lines. All good fun.
If you read the page to which I gave a link it makles it clearer, much clearer than many books I have read on Canonicalization.
|
|
|
|
|
Andy H wrote: If you read the page to which I gave a link
Thanks Andy, I can't find in this thread where you provided any link though?
led mike
|
|
|
|
|
The link was in my message (at the bottom) where I explained I had worked out the EXEC_C14N output.
Here it is
|
|
|
|
|
Andy H wrote: The link was in my message (at the bottom)
Wow, I really did look for it, I guess I picked a bad day to stop smoking crack.
led mike
|
|
|
|
|
Just like I missed your link
|
|
|
|
|
Hi,
I am using the IXMLDOM objects to create an xml file and write tags to this file.
I would like to create a tag <children count="2">, and under that write the names of the children <childname> value </childname>.
this should look as folowing:
<Root>
<Person>
<Name> value </Name>
<PhoneNumber> value </PhoneNumber>
<Children count = 2>
<childName> value </childName>
<childName> value </childName>
</Children>
</Person>
</Root>
1. Using IXMLDOMDocument or IXMLDOMNode, how do I add a node <Children count =2>, is this an attribute? How do I make sure that it is inserted under the tag?
2. How do I add the sub nodes underneath <childName> value </childName>
If you could give me code examples tha twould be great.
I've tried all kinds of options using the IXMLDOM functiom and it doesn't work!!
Thanks.
|
|
|
|
|
|
Hello,
VS 2008.
I am creating a web service that has to return grammar in xml format. A example is below.
<item>
<tag> id="101"; name="Joe Blogs"; </tag>
<one-of>
<item>joe</item>
<item>blogs</item>
<item>joey</item>
</one-of>
</item>
Where I have the question marks I am not sure of what datatype will be used to return the grammar in.
Many thanks for any suggestions,
Steve
[WebMethod(Description="Auto Generate Grammar for ASR")]
public ???? GenerateGrammar()
{
<item>
<tag> id="101"; name="Joe Blogs"; </tag>
<one-of>
<item>joe</item>
<item>blogs</item>
<item>joey</item>
</one-of>
</item>
return ?????
}
|
|
|
|
|
Hi guys,
I am working on Open Office XML and need to set some of the StylePane options Programmatically. The Style Pane Options in word 2007 its available at Style -> Options. The First dropdown in the pane says "Select Style to Show :". I need to select an option "In Current Document". I need to go to all the contents in the sharepoint site and set this option programmatically. If any one can provide some input on this, that will be of great help. I tried by checking in styles.xml or relations xml, but could not find any.
Thanks in adavnce ,
Venki
|
|
|
|
|
Hai,
In my XML File ,i am having a tag<date> which value is Date & Time.
Like this,
<date>2008/05/19 00:00:00
in my output XML File i want value Like this,
<datetime>05/19/2008 00:00:00
what are the codes need to write in XSL File.
by
Mani..
Born to win...!
|
|
|
|
|
check out the tutorials and references at www.w3schools.com[^]
and don't cross post
led mike
|
|
|
|
|
Hello all's
I am new in ajax and XML.When any form data is saved using ajax ( without page refresh ) Then the function return xml ...
How can i do this can any one help me my code is written below.
<?
some required files.
?>
<html>
<head>
<title></title>
<link href="templates/<?php echo $TEMPLATE ?>/css/stylesheet.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="templates/<?php echo $TEMPLATE ?>/javascript/jstb_validations.js"></script>
<script type="text/javascript" src="templates/<?php echo $TEMPLATE ?>/javascript/AjaxRequest.js"></script>
<script language="javascript" type="text/javascript">
function ajaxFunction(sText)
{
var ajaxRequest; // The variable that makes Ajax possible!
try
{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer Browsers
try
{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
// Something went wrong
alert("Your browser browser is not compitable for the page on which you are working!");
return false;
}
}
}
var device_type_name = document.getElementById('device_type_name').value;
var reporting_interval = document.getElementById('reporting_interval').value;
var module = document.getElementById('module').value;
var version = document.getElementById('version').value;
var s_key = document.getElementById('s_key').value;
var uid = document.getElementById('uid').value;
var lang = document.getElementById('lang').value;
// This query string is for direct call using class
//var strUrl = '?device_type_name='+device_type_name+'&reporting_interval='+reporting_interval;
// This query string is for API call
var strUrl = '?device_type_name='+device_type_name+'&reporting_interval='+reporting_interval+'&module='+module+'&version='+version+'&s_key='+s_key+'&uid='+uid+'&lang='+lang;
ajaxRequest.open("GET", "api/index.php" + strUrl,onResponse,true);
ajaxRequest.send(null);
// AjaxRequest.get(
// {
// 'url':'strUrl','onSuccess':function(){ alert('Success!');
// }}
// );
// var ajax = new Ajax();
// ajax.makeRequest('GET', 'api/index.php', onResponse);
//blank all field for new entry
document.getElementById('device_type_name').value='';
document.getElementById('reporting_interval').value='';
/////////
function onResponse()
{
if(ajax.checkReadyState() == "success")
{
// add your parsing code here
alert("success");
}
}
}
</script>
<script type="text/javascript">
function ChkFrm_data()
{
frm=document.add_new_dev_type;
if(frm.device_type_name.value=="")
{
CustomAlert('<?php echo NECESSARY_FIELD_REQUIRED?>');
frm.txt_device_type_name.focus();
return false;
}
if(frm.reporting_interval.value=="")
{
CustomAlert('<?php echo NECESSARY_FIELD_REQUIRED?>');
frm.txt_reporting_interval.focus();
return false;
}
}
function CheckInteger(input_object)
{
if(!isNumeric(input_object.value))
{
CustomAlert('<?php echo NUMERIC_FIELD_REQUIRED?>');
input_object.value = "";
//next two lines are there for compatibility with FireFox
myField = input_object;
setTimeout("this.myField.focus();",0);
//input_object.focus();
return false;
}
}
function CustomAlert(message, message_header, message_type)
{
alert(message);
}
</script>
</head>
<body class="body_inner">
<form action="add_new_dev_type.php" name="add_new_dev_type" method="POST" onSubmit="return ChkFrm_data();">
<table id="form_container">
<tr id="form_header">
<td colspan="2"><?php echo HEADING?></td>
</tr>
<tr id="form_message">
<?if(!empty($message)){?>
<td colspan="2"><?php echo $message;?></td>
<?}?>
</tr>
<tr id="field_row">
<td><?php echo DEVICE_TYPE_NAME?></td>
<td><input type='text' name='device_type_name' id='device_type_name' value='<?php echo $device_type_name ?>' /></td>
</tr>
<tr id="field_row">
<td><?php echo REPORTING_INTERVAL?></td>
<td><input type='text' id="reporting_interval" name='reporting_interval' value='<?php echo $reporting_interval ?>' onChange="return CheckInteger(document.getElementById('txt_reporting_interval'))" /></td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="module" id="module" value="ADD_DEVICE_TYPE">
<input type="hidden" name="version" id="version" value="0.3">
<input type="hidden" name="s_key" id="s_key" value="<?php echo $CURRENT_HASH?>">
<input type="hidden" name="uid" id="uid" value="<?php echo $USER_ID?>">
<input type="hidden" name="lang" id="lang" value="english">
<input type="button" onClick="ajaxFunction(add_new_dev_type)" name='Save' value='Save' />
</td>
</tr>
</table>
</form>
</body>
</html>
Regard's
Kaushik
|
|
|
|
|
Hi frnds...
I hv excel template with it look and feel...
Dat excel i hv converted into .xml file by saving excel sheet to xml.
Used
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
and closing tag
Nw i want to add data frm database into xml for which i hv used
<xsl:for-each select="dataset/table"> and also use <xsl:if test="group_id=1">
then fill the first row of xml and for other group_ids...
the xml file get generated bt when i open the xml file into excel file it gives me error
XML ERROR in Worksheet Setting
REASON: Bad Value
FILE: C:\Documents and Settings\Administrator\Desktop\ReportsinExcelWithXML\AuthorReportGenerator\bin\DebugReport.xml
GROUP: Worksheet
TAG: Table
ATTRIB: ExpandedRowCount
VALUE: 58
and the <Table> tag of xml has
<Table ss:ExpandedColumnCount="9" ss:ExpandedRowCount="58" x:FullColumns="1"
x:FullRows="1" ss:StyleID="s25" ss:DefaultRowHeight="12">
plz help me... its urgent
|
|
|
|
|
Hi Guys,
i am working on a project using vs2005,vb.net.
i have data on a datagrid as follows...
StockCode|Description|Qty,UOM
1234 |TEST |20 |KG
5678 |TEST2 |15 |KG
The Xml format required must be as follows...
<item>
<key>
<stockcode> 1234 </stockcode>
</key>
<description>TEST</description>
<qty>20</qty>
<uom>KG</uom>
</item>
i am currently reading the xml template and creating the xmldoc but it is taking way too long.
What is the fastest way to create this xml, bear in mind that my datagrid may have up to 30000 rows and 80 columns.
thanks
Anoop Brijmohun
|
|
|
|