summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMichael Mi <mmi@openoffice.org>2004-08-12 01:29:21 +0000
committerMichael Mi <mmi@openoffice.org>2004-08-12 01:29:21 +0000
commit690e909ef771703ef848cda41df753d3f96491b0 (patch)
treeaa30f22eca1afeed50ac16fc4fd089b09432dca1 /xmlsecurity
parent2d9016f7b011c9295b0a618479c51c01ae36826a (diff)
change datetime format to ISO string
Issue number: Submitted by: Reviewed by:
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx7
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx8
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx30
-rw-r--r--xmlsecurity/source/helper/xsecctl.cxx271
-rw-r--r--xmlsecurity/source/helper/xsecctl.hxx26
-rw-r--r--xmlsecurity/source/helper/xsecparser.cxx20
-rw-r--r--xmlsecurity/source/helper/xsecparser.hxx8
-rw-r--r--xmlsecurity/source/helper/xsecsign.cxx30
-rw-r--r--xmlsecurity/source/helper/xsecverify.cxx8
9 files changed, 314 insertions, 94 deletions
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index eadaf3c4b2e8..5d1358999015 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: documentdigitalsignatures.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: mt $ $Date: 2004-07-27 11:55:25 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -185,8 +185,11 @@ com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInf
if ( !aInfos[n].Signer.is() )
aInfos[n].Signer = xSecEnv->createCertificateFromAscii( rInfo.ouX509Certificate ) ;
+ // MM : the ouDate and ouTime fields have been replaced with stDateTime (com::sun::star::util::DataTime)
+ /*
aInfos[n].SignatureDate = String( rInfo.ouDate ).ToInt32();
aInfos[n].SignatureTime = String( rInfo.ouTime ).ToInt32();
+ */
DBG_ASSERT( rInfo.nStatus != STATUS_INIT, "Signature not processed!" );
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 615c304d8c37..2fa5ba8cd273 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: digitalsignaturesdialog.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: mt $ $Date: 2004-07-27 11:55:25 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -391,7 +391,11 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox()
{
aSubject = XmlSec::GetContentPart( xCert->getSubjectName(), aCN_Id );
aIssuer = XmlSec::GetContentPart( rInfo.ouX509IssuerName, aCN_Id );
+
+ // MM : the ouDate and ouTime fields have been replaced with stDateTime (com::sun::star::util::DataTime)
+ /*
aDateTimeStr = XmlSec::GetDateTimeString( rInfo.ouDate, rInfo.ouTime );
+ */
}
// New signatures are not verified, must be valid. Status is INIT.
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 7e44191bf0a4..89fb1ef8db0c 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlsignaturehelper.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: mt $ $Date: 2004-07-26 15:45:14 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,7 +74,6 @@
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/lang/XComponent.hpp>
-
#include <tools/date.hxx>
#include <tools/time.hxx>
@@ -85,7 +84,8 @@
/* SEInitializer component */
#define SEINITIALIZER_COMPONENT "com.sun.star.xml.crypto.SEInitializer"
-#define SIGFILEROOTELEMENT "all-signatures"
+#define TAG_DOCUMENTSIGNATURES "document-signatures"
+#define NS_DOCUMENTSIGNATURES "http://openoffice.org/2004/documentsignatures"
using namespace ::com::sun::star;
@@ -231,9 +231,20 @@ void XMLSignatureHelper::SetX509Certificate(
void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const Date& rDate, const Time& rTime )
{
+ /*
rtl::OUString aDate = String::CreateFromInt32( rDate.GetDate() );
rtl::OUString aTime = String::CreateFromInt32( rTime.GetTime() );
mpXSecController->setDateTime( nSecurityId, aDate, aTime );
+ */
+ ::com::sun::star::util::DateTime stDateTime;
+ stDateTime.HundredthSeconds = (::sal_uInt16)rTime.Get100Sec();
+ stDateTime.Seconds = (::sal_uInt16)rTime.GetSec();
+ stDateTime.Minutes = (::sal_uInt16)rTime.GetMin();
+ stDateTime.Hours = (::sal_uInt16)rTime.GetHour();
+ stDateTime.Day = (::sal_uInt16)rDate.GetDay();
+ stDateTime.Month = (::sal_uInt16)rDate.GetMonth();
+ stDateTime.Year = (::sal_uInt16)rDate.GetYear();
+ mpXSecController->setDate( nSecurityId, stDateTime );
}
void XMLSignatureHelper::AddForSigning( sal_Int32 nSecurityId, const rtl::OUString& uri, const rtl::OUString& objectURL, sal_Bool bBinary )
@@ -268,19 +279,24 @@ uno::Reference<xml::sax::XDocumentHandler> XMLSignatureHelper::CreateDocumentHan
/*
* write the xml context for signatures
*/
- rtl::OUString tag_AllSignatures(RTL_CONSTASCII_USTRINGPARAM(SIGFILEROOTELEMENT));
+ rtl::OUString tag_AllSignatures(RTL_CONSTASCII_USTRINGPARAM(TAG_DOCUMENTSIGNATURES));
+
+ SvXMLAttributeList *pAttributeList = new SvXMLAttributeList();
+ pAttributeList->AddAttribute(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS)),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_DOCUMENTSIGNATURES)));
xDocHandler->startDocument();
xDocHandler->startElement(
tag_AllSignatures,
- uno::Reference< xml::sax::XAttributeList > (new SvXMLAttributeList()));
+ uno::Reference< com::sun::star::xml::sax::XAttributeList > (pAttributeList));
return xDocHandler;
}
void XMLSignatureHelper::CloseDocumentHandler( const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler )
{
- rtl::OUString tag_AllSignatures(RTL_CONSTASCII_USTRINGPARAM(SIGFILEROOTELEMENT));
+ rtl::OUString tag_AllSignatures(RTL_CONSTASCII_USTRINGPARAM(TAG_DOCUMENTSIGNATURES));
xDocumentHandler->endElement( tag_AllSignatures );
xDocumentHandler->endDocument();
}
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index d89553a857c0..b4096aa5aa39 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecctl.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mmi $ $Date: 2004-07-15 08:12:08 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,6 +75,13 @@
#include <xmloff/attrlist.hxx>
+#ifndef INCLUDED_RTL_MATH_HXX
+#include <rtl/math.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
namespace cssu = com::sun::star::uno;
namespace cssl = com::sun::star::lang;
namespace cssxc = com::sun::star::xml::crypto;
@@ -82,6 +89,9 @@ namespace cssxs = com::sun::star::xml::sax;
namespace cssxw = com::sun::star::xml::wrapper;
namespace cssb = com::sun::star::beans;
+const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
+const sal_Int8 XML_MAXDIGITSCOUNT_DATETIME = 6;
+
/* bridge component names */
#define XMLSIGNATURE_COMPONENT "com.sun.star.xml.crypto.XMLSignature"
#define XMLDOCUMENTWRAPPER_COMPONENT "com.sun.star.xml.wrapper.XMLDocumentWrapper"
@@ -110,6 +120,182 @@ XSecController::~XSecController()
/*
* private methods
*/
+/** convert string to number with optional min and max values */
+sal_Bool XSecController::convertNumber( sal_Int32& rValue,
+ const rtl::OUString& rString,
+ sal_Int32 nMin, sal_Int32 nMax )
+{
+ sal_Bool bNeg = sal_False;
+ rValue = 0;
+
+ sal_Int32 nPos = 0L;
+ sal_Int32 nLen = rString.getLength();
+
+ // skip white space
+ while( nPos < nLen && sal_Unicode(' ') == rString[nPos] )
+ nPos++;
+
+ if( nPos < nLen && sal_Unicode('-') == rString[nPos] )
+ {
+ bNeg = sal_True;
+ nPos++;
+ }
+
+ // get number
+ while( nPos < nLen &&
+ sal_Unicode('0') <= rString[nPos] &&
+ sal_Unicode('9') >= rString[nPos] )
+ {
+ // TODO: check overflow!
+ rValue *= 10;
+ rValue += (rString[nPos] - sal_Unicode('0'));
+ nPos++;
+ }
+
+ if( bNeg )
+ rValue *= -1;
+
+ return nPos == nLen;
+}
+
+/** convert util::DateTime to ISO Date String */
+void XSecController::convertDateTime( ::rtl::OUStringBuffer& rBuffer,
+ const com::sun::star::util::DateTime& rDateTime )
+{
+ String aString( String::CreateFromInt32( rDateTime.Year ) );
+ aString += '-';
+ if( rDateTime.Month < 10 )
+ aString += '0';
+ aString += String::CreateFromInt32( rDateTime.Month );
+ aString += '-';
+ if( rDateTime.Day < 10 )
+ aString += '0';
+ aString += String::CreateFromInt32( rDateTime.Day );
+
+ if( rDateTime.Seconds != 0 ||
+ rDateTime.Minutes != 0 ||
+ rDateTime.Hours != 0 )
+ {
+ aString += 'T';
+ if( rDateTime.Hours < 10 )
+ aString += '0';
+ aString += String::CreateFromInt32( rDateTime.Hours );
+ aString += ':';
+ if( rDateTime.Minutes < 10 )
+ aString += '0';
+ aString += String::CreateFromInt32( rDateTime.Minutes );
+ aString += ':';
+ if( rDateTime.Seconds < 10 )
+ aString += '0';
+ aString += String::CreateFromInt32( rDateTime.Seconds );
+ if ( rDateTime.HundredthSeconds > 0)
+ {
+ aString += ',';
+ if (rDateTime.HundredthSeconds < 10)
+ aString += '0';
+ aString += String::CreateFromInt32( rDateTime.HundredthSeconds );
+ }
+ }
+
+ rBuffer.append( aString );
+}
+
+/** convert ISO Date String to util::DateTime */
+sal_Bool XSecController::convertDateTime( com::sun::star::util::DateTime& rDateTime,
+ const ::rtl::OUString& rString )
+{
+ sal_Bool bSuccess = sal_True;
+
+ rtl::OUString aDateStr, aTimeStr, sDoubleStr;
+ sal_Int32 nPos = rString.indexOf( (sal_Unicode) 'T' );
+ sal_Int32 nPos2 = rString.indexOf( (sal_Unicode) ',' );
+ if ( nPos >= 0 )
+ {
+ aDateStr = rString.copy( 0, nPos );
+ if ( nPos2 >= 0 )
+ {
+ aTimeStr = rString.copy( nPos + 1, nPos2 - nPos - 1 );
+ sDoubleStr = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0."));
+ sDoubleStr += rString.copy( nPos2 + 1 );
+ }
+ else
+ {
+ aTimeStr = rString.copy(nPos + 1);
+ sDoubleStr = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0.0"));
+ }
+ }
+ else
+ aDateStr = rString; // no separator: only date part
+
+ sal_Int32 nYear = 1899;
+ sal_Int32 nMonth = 12;
+ sal_Int32 nDay = 30;
+ sal_Int32 nHour = 0;
+ sal_Int32 nMin = 0;
+ sal_Int32 nSec = 0;
+
+ const sal_Unicode* pStr = aDateStr.getStr();
+ sal_Int32 nDateTokens = 1;
+ while ( *pStr )
+ {
+ if ( *pStr == '-' )
+ nDateTokens++;
+ pStr++;
+ }
+ if ( nDateTokens > 3 || aDateStr.getLength() == 0 )
+ bSuccess = sal_False;
+ else
+ {
+ sal_Int32 n = 0;
+ if ( !convertNumber( nYear, aDateStr.getToken( 0, '-', n ), 0, 9999 ) )
+ bSuccess = sal_False;
+ if ( nDateTokens >= 2 )
+ if ( !convertNumber( nMonth, aDateStr.getToken( 0, '-', n ), 0, 12 ) )
+ bSuccess = sal_False;
+ if ( nDateTokens >= 3 )
+ if ( !convertNumber( nDay, aDateStr.getToken( 0, '-', n ), 0, 31 ) )
+ bSuccess = sal_False;
+ }
+
+ if ( aTimeStr.getLength() > 0 ) // time is optional
+ {
+ pStr = aTimeStr.getStr();
+ sal_Int32 nTimeTokens = 1;
+ while ( *pStr )
+ {
+ if ( *pStr == ':' )
+ nTimeTokens++;
+ pStr++;
+ }
+ if ( nTimeTokens > 3 )
+ bSuccess = sal_False;
+ else
+ {
+ sal_Int32 n = 0;
+ if ( !convertNumber( nHour, aTimeStr.getToken( 0, ':', n ), 0, 23 ) )
+ bSuccess = sal_False;
+ if ( nTimeTokens >= 2 )
+ if ( !convertNumber( nMin, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
+ bSuccess = sal_False;
+ if ( nTimeTokens >= 3 )
+ if ( !convertNumber( nSec, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
+ bSuccess = sal_False;
+ }
+ }
+
+ if (bSuccess)
+ {
+ rDateTime.Year = (sal_uInt16)nYear;
+ rDateTime.Month = (sal_uInt16)nMonth;
+ rDateTime.Day = (sal_uInt16)nDay;
+ rDateTime.Hours = (sal_uInt16)nHour;
+ rDateTime.Minutes = (sal_uInt16)nMin;
+ rDateTime.Seconds = (sal_uInt16)nSec;
+ rDateTime.HundredthSeconds = sDoubleStr.toDouble() * 100;
+ }
+ return bSuccess;
+}
+
int XSecController::findSignatureInfor( sal_Int32 nSecurityId)
/****** XSecController/findSignatureInfor *************************************
*
@@ -964,9 +1150,12 @@ void XSecController::exportSignature(
rtl::OUString tag_Object(RTL_CONSTASCII_USTRINGPARAM(TAG_OBJECT));
rtl::OUString tag_SignatureProperties(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTIES));
rtl::OUString tag_SignatureProperty(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTY));
+ rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
+#if 0
rtl::OUString tag_Timestamp(RTL_CONSTASCII_USTRINGPARAM(TAG_TIMESTAMP));
rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
rtl::OUString tag_Time(RTL_CONSTASCII_USTRINGPARAM(TAG_TIME));
+#endif
const SignatureReferenceInformations& vReferenceInfors = signatureInfo.vSignatureReferenceInfors;
SvXMLAttributeList *pAttributeList;
@@ -1135,61 +1324,57 @@ void XSecController::exportSignature(
}
xDocumentHandler->endElement( tag_KeyInfo );
- if (signatureInfo.ouDate.getLength()>0 ||signatureInfo.ouTime.getLength()>0)
+ /* Write Object element */
+ xDocumentHandler->startElement(
+ tag_Object,
+ cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
- /* Write Object element */
+ /* Write SignatureProperties element */
xDocumentHandler->startElement(
- tag_Object,
+ tag_SignatureProperties,
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
- /* Write SignatureProperties element */
+ /* Write SignatureProperty element */
+ pAttributeList = new SvXMLAttributeList();
+ pAttributeList->AddAttribute(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
+ signatureInfo.ouPropertyId);
+ pAttributeList->AddAttribute(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_TARGET)),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+signatureInfo.ouSignatureId);
xDocumentHandler->startElement(
- tag_SignatureProperties,
- cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
+ tag_SignatureProperty,
+ cssu::Reference< cssxs::XAttributeList > (pAttributeList));
{
- /* Write SignatureProperty element */
+ /* Write timestamp element */
+
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
- signatureInfo.ouPropertyId);
- pAttributeList->AddAttribute(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_TARGET)),
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+signatureInfo.ouSignatureId);
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC)),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_DC)));
+
xDocumentHandler->startElement(
- tag_SignatureProperty,
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
+ +tag_Date,
cssu::Reference< cssxs::XAttributeList > (pAttributeList));
- {
- /* Write timestamp element */
- pAttributeList = new SvXMLAttributeList();
- pAttributeList->AddAttribute(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS)),
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_DATETIME)));
- xDocumentHandler->startElement(
- tag_Timestamp,
- cssu::Reference< cssxs::XAttributeList > (pAttributeList));
- {
- /* Write date element */
- xDocumentHandler->startElement(
- tag_Date,
- cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
- xDocumentHandler->characters( signatureInfo.ouDate );
- xDocumentHandler->endElement( tag_Date );
- /* Write time element */
- xDocumentHandler->startElement(
- tag_Time,
- cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
- xDocumentHandler->characters( signatureInfo.ouTime );
- xDocumentHandler->endElement( tag_Time );
- }
- xDocumentHandler->endElement( tag_Timestamp );
- }
- xDocumentHandler->endElement( tag_SignatureProperty );
+ ::rtl::OUStringBuffer buffer;
+ convertDateTime( buffer, signatureInfo.stDateTime );
+ xDocumentHandler->characters( buffer.makeStringAndClear() );
+
+ xDocumentHandler->endElement(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
+ +tag_Date);
}
- xDocumentHandler->endElement( tag_SignatureProperties );
+ xDocumentHandler->endElement( tag_SignatureProperty );
}
- xDocumentHandler->endElement( tag_Object );
+ xDocumentHandler->endElement( tag_SignatureProperties );
}
+ xDocumentHandler->endElement( tag_Object );
}
xDocumentHandler->endElement( tag_Signature );
}
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index 516a0046d010..1f271b5fb360 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecctl.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mmi $ $Date: 2004-07-28 02:26:48 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,6 +82,8 @@
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
+#include <rtl/ustrbuf.hxx>
+
#include <cppuhelper/implbase4.hxx>
#ifndef INCLUDED_VECTOR
@@ -121,7 +123,7 @@
#define TAG_SIGNATUREPROPERTY "SignatureProperty"
#define TAG_TIMESTAMP "timestamp"
#define TAG_DATE "date"
-#define TAG_TIME "time"
+//#define TAG_TIME "time"
#define ATTR_XMLNS "xmlns"
#define ATTR_ALGORITHM "Algorithm"
@@ -129,8 +131,11 @@
#define ATTR_ID "Id"
#define ATTR_TARGET "Target"
+#define NSTAG_DC "dc"
+
#define NS_XMLDSIG "http://www.w3.org/2000/09/xmldsig#"
-#define NS_DATETIME "http://www.ietf.org/rfcXXXX.txt"
+//#define NS_DATETIME "http://www.ietf.org/rfcXXXX.txt"
+#define NS_DC "http://purl.org/dc/elements/1.1/"
#define ALGO_C14N "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
#define ALGO_RSASHA1 "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
@@ -401,6 +406,10 @@ private:
/*
* Common methods
*/
+ sal_Bool convertNumber( sal_Int32& rValue, const rtl::OUString& rString, sal_Int32 nMin, sal_Int32 nMax );
+ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, const com::sun::star::util::DateTime& rDateTime );
+ sal_Bool convertDateTime( com::sun::star::util::DateTime& rDateTime, const ::rtl::OUString& rString );
+
void createXSecComponent( );
int findSignatureInfor( sal_Int32 nSecurityId );
bool chainOn( bool bRetrievingLastEvent );
@@ -436,8 +445,9 @@ private:
void setX509Certificate( rtl::OUString& ouX509Certificate );
void setSignatureValue( rtl::OUString& ouSignatureValue );
void setDigestValue( rtl::OUString& ouDigestValue );
+
void setDate( rtl::OUString& ouDate );
- void setTime( rtl::OUString& ouTime );
+
void setId( rtl::OUString& ouId );
void setPropertyId( rtl::OUString& ouPropertyId );
@@ -507,10 +517,10 @@ public:
const rtl::OUString& ouX509IssuerName,
const rtl::OUString& ouX509SerialNumber);
- void setDateTime(
+ void setDate(
sal_Int32 nSecurityId,
- const rtl::OUString& ouDate,
- const rtl::OUString& ouTime);
+ const ::com::sun::star::util::DateTime& rDateTime );
+
bool WriteSignature(
const com::sun::star::uno::Reference<
diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx
index 6c3e76a59d13..4f52d82f9d85 100644
--- a/xmlsecurity/source/helper/xsecparser.cxx
+++ b/xmlsecurity/source/helper/xsecparser.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecparser.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mmi $ $Date: 2004-07-28 02:26:48 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -105,7 +105,7 @@ void SAL_CALL XSecParser::startDocument( )
m_bInSignatureValue = false;
m_bInDigestValue = false;
m_bInDate = false;
- m_bInTime = false;
+ //m_bInTime = false;
if (m_xNextHandler.is())
{
@@ -210,16 +210,20 @@ void SAL_CALL XSecParser::startElement(
m_pXSecController->setPropertyId( ouIdAttr );
}
}
- else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_DATE)))
+ else if (aName == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE)))
{
m_ouDate = rtl::OUString::createFromAscii("");
m_bInDate = true;
}
+ /*
else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_TIME)))
{
m_ouTime = rtl::OUString::createFromAscii("");
m_bInTime = true;
}
+ */
if (m_xNextHandler.is())
{
@@ -271,16 +275,20 @@ void SAL_CALL XSecParser::endElement( const rtl::OUString& aName )
m_pXSecController->setX509Certificate( m_ouX509Certificate );
m_bInX509Certificate = false;
}
- else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_DATE)) )
+ else if (aName == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
+ +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE)))
{
m_pXSecController->setDate( m_ouDate );
m_bInDate = false;
}
+ /*
else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_TIME)) )
{
m_pXSecController->setTime( m_ouTime );
m_bInTime = false;
}
+ */
if (m_xNextHandler.is())
{
@@ -315,10 +323,12 @@ void SAL_CALL XSecParser::characters( const rtl::OUString& aChars )
{
m_ouDate += aChars;
}
+ /*
else if (m_bInTime)
{
m_ouTime += aChars;
}
+ */
if (m_xNextHandler.is())
{
diff --git a/xmlsecurity/source/helper/xsecparser.hxx b/xmlsecurity/source/helper/xsecparser.hxx
index da2b765a7ad6..06432b4e33e2 100644
--- a/xmlsecurity/source/helper/xsecparser.hxx
+++ b/xmlsecurity/source/helper/xsecparser.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecparser.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -109,7 +109,7 @@ private:
rtl::OUString m_ouDigestValue;
rtl::OUString m_ouSignatureValue;
rtl::OUString m_ouDate;
- rtl::OUString m_ouTime;
+ //rtl::OUString m_ouTime;
/*
* whether inside a particular element
@@ -120,7 +120,7 @@ private:
bool m_bInDigestValue;
bool m_bInSignatureValue;
bool m_bInDate;
- bool m_bInTime;
+ //bool m_bInTime;
/*
* the XSecController collaborating with XSecParser
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index 813f47237427..360b5242d8ab 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecsign.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mmi $ $Date: 2004-07-15 08:12:09 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -199,17 +199,10 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
cssu::Reference<cssxc::sax::XKeyCollector> keyCollector (xReferenceResolvedListener, cssu::UNO_QUERY);
keyCollector->setKeyId(0);
- if (internalSignatureInfor.signatureInfor.ouDate.getLength()>0 ||internalSignatureInfor.signatureInfor.ouTime.getLength()>0)
- /*
- * add a reference to datatime property, this reference is transparent to the xmlsecurity
- * framework
- */
- {
- internalSignatureInfor.signatureInfor.ouSignatureId = createId();
- internalSignatureInfor.signatureInfor.ouPropertyId = createId();
- internalSignatureInfor.addReference(TYPE_SAMEDOCUMENT_REFERENCE, internalSignatureInfor.signatureInfor.ouPropertyId, -1 );
- size++;
- }
+ internalSignatureInfor.signatureInfor.ouSignatureId = createId();
+ internalSignatureInfor.signatureInfor.ouPropertyId = createId();
+ internalSignatureInfor.addReference(TYPE_SAMEDOCUMENT_REFERENCE, internalSignatureInfor.signatureInfor.ouPropertyId, -1 );
+ size++;
/*
* replace both digestValues and signatueValue to " "
@@ -296,26 +289,23 @@ void XSecController::setX509Certificate(
}
}
-void XSecController::setDateTime(
+void XSecController::setDate(
sal_Int32 nSecurityId,
- const rtl::OUString& ouDate,
- const rtl::OUString& ouTime)
+ const ::com::sun::star::util::DateTime& rDateTime )
{
int index = findSignatureInfor( nSecurityId );
if ( index == -1 )
{
InternalSignatureInformation isi(nSecurityId, NULL);
- isi.signatureInfor.ouDate = ouDate;
- isi.signatureInfor.ouTime = ouTime;
+ isi.signatureInfor.stDateTime = rDateTime;
m_vInternalSignatureInformations.push_back( isi );
}
else
{
SignatureInformation &si
= m_vInternalSignatureInformations[index].signatureInfor;
- si.ouDate = ouDate;
- si.ouTime = ouTime;
+ si.stDateTime = rDateTime;
}
}
diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx
index 33e007d729e6..7c2299c3c5ce 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecverify.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mmi $ $Date: 2004-07-28 02:26:48 $
+ * last change: $Author: mmi $ $Date: 2004-08-12 02:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -248,14 +248,16 @@ void XSecController::setDigestValue( rtl::OUString& ouDigestValue )
void XSecController::setDate( rtl::OUString& ouDate )
{
InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
- isi.signatureInfor.ouDate = ouDate;
+ convertDateTime( isi.signatureInfor.stDateTime, ouDate );
}
+/*
void XSecController::setTime( rtl::OUString& ouTime )
{
InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
isi.signatureInfor.ouTime = ouTime;
}
+*/
void XSecController::setId( rtl::OUString& ouId )
{