summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMalte Timmermann <mt@openoffice.org>2004-07-15 06:16:12 +0000
committerMalte Timmermann <mt@openoffice.org>2004-07-15 06:16:12 +0000
commit9e997f79d05ae5be084bed24758f38d4c49328c3 (patch)
treedfe79105170d593887907e44bc3e4ec8dddbc3b3 /xmlsecurity
parentb95222d74caa71fa217ac713048d2694816d38f5 (diff)
...
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx4
-rw-r--r--xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx8
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx44
-rw-r--r--xmlsecurity/source/dialogs/certificateviewer.cxx12
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx8
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx19
-rw-r--r--xmlsecurity/workben/signaturetest.cxx19
7 files changed, 80 insertions, 34 deletions
diff --git a/xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx
index 9d452bf32d28..289964698191 100644
--- a/xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx
+++ b/xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: documentsignaturehelper.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-14 11:06:05 $
+ * last change: $Author: mt $ $Date: 2004-07-15 07:16:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
diff --git a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
index c726fd27c18a..d4fc5098ca63 100644
--- a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
+++ b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlsignaturehelper.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mt $ $Date: 2004-07-14 11:05:44 $
+ * last change: $Author: mt $ $Date: 2004-07-15 07:16:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,6 +83,8 @@ extern rtl::OUString bigIntegerToNumericString( ::com::sun::star::uno::Sequence<
extern ::com::sun::star::uno::Sequence< sal_Int8 > numericStringToBigInteger ( rtl::OUString serialNumber );
class XSecController;
+class Date;
+class Time;
namespace com {
namespace sun {
@@ -196,7 +198,7 @@ public:
void EndMission();
sal_Int32 GetNewSecurityId();
void SetX509Certificate( sal_Int32 nSecurityId, const rtl::OUString& ouX509IssuerName, const rtl::OUString& ouX509SerialNumber);
- void SetDateTime( sal_Int32 nSecurityId, const rtl::OUString& ouDate, const rtl::OUString& ouTime);
+ void SetDateTime( sal_Int32 nSecurityId, const Date& rDate, const Time& rTime );
void AddForSigning( sal_Int32 securityId, const rtl::OUString& uri, const rtl::OUString& objectURL, sal_Bool bBinary );
bool CreateAndWriteSignature( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler );
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 1b0efa72f835..1143fbf6f2ee 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: documentdigitalsignatures.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mt $ $Date: 2004-07-14 11:05:44 $
+ * last change: $Author: mt $ $Date: 2004-07-15 07:16:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -143,8 +143,6 @@ sal_Bool DocumentDigitalSignatures::ImplViewSignatures( const ::com::sun::star::
com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > DocumentDigitalSignatures::ImplVerifySignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, DocumentSignatureMode eMode ) throw (::com::sun::star::uno::RuntimeException)
{
- std::vector< rtl::OUString > aElementsToBeVerified = DocumentSignatureHelper::CreateElementList( rxStorage, ::rtl::OUString(), eMode );
-
XMLSignatureHelper aSignatureHelper( mxMSF );
aSignatureHelper.Init( rtl::OUString() );
aSignatureHelper.SetStorage( rxStorage );
@@ -168,10 +166,42 @@ com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInf
aSignatureHelper.EndMission();
- // MT: LATER...
- // = aHelper.GetSignatureInformations();
+ uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecEnv = aSignatureHelper.GetSecurityEnvironment();
+
+ SignatureInformations aSignInfos = aSignatureHelper.GetSignatureInformations();
+ int nInfos = aSignInfos.size();
+ ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > aInfos(nInfos);
- ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > aInfos;
+ if ( nInfos )
+ {
+ std::vector< rtl::OUString > aElementsToBeVerified = DocumentSignatureHelper::CreateElementList( rxStorage, ::rtl::OUString(), eMode );
+ for( int n = 0; n < nInfos; ++n )
+ {
+ const SignatureInformation& rInfo = aSignInfos[n];
+ aInfos[n].Signer = xSecEnv->getCertificate( rInfo.ouX509IssuerName, numericStringToBigInteger( rInfo.ouX509SerialNumber ) );
+ if ( !aInfos[n].Signer.is() )
+ aInfos[n].Signer = xSecEnv->createCertificateFromAscii( rInfo.ouX509Certificate ) ;
+
+ aInfos[n].SignatureDate = String( rInfo.ouDate ).ToInt32();
+ aInfos[n].SignatureTime = String( rInfo.ouTime ).ToInt32();
+
+ aInfos[n].SignatureIsValid = ( rInfo.nStatus == STATUS_VERIFY_SUCCEED );
+
+ if ( aInfos[n].SignatureIsValid )
+ {
+ // Can only be valid if ALL streams are signed, which means real stream count == signed stream count
+ int nRealCount = 0;
+ for ( int i = rInfo.vSignatureReferenceInfors.size(); i; )
+ {
+ const SignatureReferenceInformation& rInf = rInfo.vSignatureReferenceInfors[--i];
+ if ( ( rInf.nType == 2 ) || ( rInf.nType == 3 ) )
+ nRealCount++;
+ }
+ aInfos[n].SignatureIsValid = ( aElementsToBeVerified.size() == nRealCount );
+ }
+
+ }
+ }
return aInfos;
}
diff --git a/xmlsecurity/source/dialogs/certificateviewer.cxx b/xmlsecurity/source/dialogs/certificateviewer.cxx
index 029ab38e54b6..ba3b6bbec96a 100644
--- a/xmlsecurity/source/dialogs/certificateviewer.cxx
+++ b/xmlsecurity/source/dialogs/certificateviewer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: certificateviewer.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: gt $ $Date: 2004-07-15 07:13:23 $
+ * last change: $Author: mt $ $Date: 2004-07-15 07:16:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -229,10 +229,10 @@ CertificateViewerGeneralTP::CertificateViewerGeneralTP( Window* _pParent, Certif
// recalc positions for date fields according to real size
Point aPos( maValidFromLabelFI.GetPosPixel() );
- AdjustPosAndSize( maValidFromLabelFI, aPos );
- AdjustPosAndSize( maValidFromFI, aPos );
- AdjustPosAndSize( maValidToLabelFI, aPos );
- AdjustPosAndSize( maValidToFI, aPos );
+ AdjustPosAndSize( maValidFromLabelFI, aPos, 5 );
+ AdjustPosAndSize( maValidFromFI, aPos, 5 );
+ AdjustPosAndSize( maValidToLabelFI, aPos, 5 );
+ AdjustPosAndSize( maValidToFI, aPos, 5 );
// adjust position of fixed text depending on image sizes
ShrinkToFit( maCertImg );
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 91aa5af56c3b..0f5ef48bb30f 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: digitalsignaturesdialog.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: gt $ $Date: 2004-07-15 06:20:09 $
+ * last change: $Author: mt $ $Date: 2004-07-15 07:16:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,6 +76,8 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <tools/intn.hxx>
+#include <tools/date.hxx>
+#include <tools/time.hxx>
#include "dialogs.hrc"
#include "resourcemanager.hxx"
@@ -234,6 +236,8 @@ IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG )
maSignatureHelper.AddForSigning( nSecurityId, aElements[n], aElements[n], bBinaryMode );
}
+ maSignatureHelper.SetDateTime( nSecurityId, Date(), Time() );
+
SignatureStreamHelper aStreamHelper = DocumentSignatureHelper::OpenSignatureStream( mxStore, embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, meSignatureMode );
uno::Reference< io::XOutputStream > xOutputStream( aStreamHelper.xSignatureStream, uno::UNO_QUERY );
uno::Reference< com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream );
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 3b3a4befe741..304499c28f3e 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlsignaturehelper.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mt $ $Date: 2004-07-14 11:05:46 $
+ * last change: $Author: mt $ $Date: 2004-07-15 07:16:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,6 +73,9 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <tools/date.hxx>
+#include <tools/time.hxx>
+
/* SEInitializer component */
#define SEINITIALIZER_COMPONENT "com.sun.star.xml.crypto.SEInitializer"
@@ -163,15 +166,11 @@ void XMLSignatureHelper::SetX509Certificate(
ouX509SerialNumber);
}
-void XMLSignatureHelper::SetDateTime(
- sal_Int32 nSecurityId,
- const rtl::OUString& ouDate,
- const rtl::OUString& ouTime)
+void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const Date& rDate, const Time& rTime )
{
- mpXSecController->setDateTime(
- nSecurityId,
- ouDate,
- ouTime);
+ rtl::OUString aDate = String::CreateFromInt32( rDate.GetDate() );
+ rtl::OUString aTime = String::CreateFromInt32( rTime.GetTime() );
+ mpXSecController->setDateTime( nSecurityId, aDate, aTime );
}
void XMLSignatureHelper::AddForSigning( sal_Int32 nSecurityId, const rtl::OUString& uri, const rtl::OUString& objectURL, sal_Bool bBinary )
diff --git a/xmlsecurity/workben/signaturetest.cxx b/xmlsecurity/workben/signaturetest.cxx
index be0d061f87bc..95309a87d7da 100644
--- a/xmlsecurity/workben/signaturetest.cxx
+++ b/xmlsecurity/workben/signaturetest.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: signaturetest.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mt $ $Date: 2004-07-14 11:05:47 $
+ * last change: $Author: mt $ $Date: 2004-07-15 07:16:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -421,8 +421,19 @@ IMPL_LINK( MyWin, VerifyDigitalSignaturesHdl, Button*, EMPTYARG )
comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
if ( xD.is() )
{
- com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > aInfos = xD->VerifyDocumentContentSignatures( xStore );
- // ...
+ uno::Sequence< security::DocumentSignaturesInformation > aInfos = xD->VerifyDocumentContentSignatures( xStore );
+ int nInfos = aInfos.getLength();
+ for ( int n = 0; n < nInfos; n++ )
+ {
+ security::DocumentSignaturesInformation& rInf = aInfos[n];
+ String aText( RTL_CONSTASCII_USTRINGPARAM( "The document is signed by\n\n " ) );
+ aText += String( rInf.Signer->getSubjectName() );
+ aText += String( RTL_CONSTASCII_USTRINGPARAM( "\n\n The signature is " ) );
+ if ( !rInf.SignatureIsValid )
+ aText += String( RTL_CONSTASCII_USTRINGPARAM( "NOT " ) );
+ aText += String( RTL_CONSTASCII_USTRINGPARAM( "valid" ) );
+ InfoBox( this, aText ).Execute();
+ }
}