Kaydet (Commit) 9e997f79 authored tarafından Malte Timmermann's avatar Malte Timmermann

...

üst b95222d7
......@@ -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
......
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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 )
......
......@@ -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();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment