#i21596# Digital Signatures...

This commit is contained in:
Malte Timmermann
2004-07-26 11:13:29 +00:00
parent f2cd9e259f
commit 0295f68c9d
3 changed files with 57 additions and 72 deletions

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: macrosecurity.hxx,v $ * $RCSfile: macrosecurity.hxx,v $
* *
* $Revision: 1.7 $ * $Revision: 1.8 $
* *
* last change: $Author: mt $ $Date: 2004-07-26 06:08:22 $ * last change: $Author: mt $ $Date: 2004-07-26 12:13:28 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -115,8 +115,8 @@ private:
PushButton maResetBtn; PushButton maResetBtn;
cssu::Reference< dcss::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment; cssu::Reference< dcss::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment;
SignatureInformations maCurrentSignatureInformations;
SvtSecurityOptions maSecOptions; SvtSecurityOptions maSecOptions;
MacroSecurityTP* mpLevelTP; MacroSecurityTP* mpLevelTP;
MacroSecurityTP* mpTrustSrcTP; MacroSecurityTP* mpTrustSrcTP;
@@ -133,8 +133,6 @@ inline void MacroSecurity::EnableReset( bool _bEnable )
maResetBtn.Enable ( _bEnable ); maResetBtn.Enable ( _bEnable );
} }
class MacroSecurityTP : public TabPage class MacroSecurityTP : public TabPage
{ {
protected: protected:
@@ -185,7 +183,9 @@ private:
PushButton maAddLocPB; PushButton maAddLocPB;
PushButton maRemoveLocPB; PushButton maRemoveLocPB;
// DECL_LINK( AddCertPBHdl, void* ); cssu::Sequence< SvtSecurityOptions::Certificate > maTrustedAuthors;
DECL_LINK( ViewCertPBHdl, void* ); DECL_LINK( ViewCertPBHdl, void* );
DECL_LINK( RemoveCertPBHdl, void* ); DECL_LINK( RemoveCertPBHdl, void* );
DECL_LINK( AddLocPBHdl, void* ); DECL_LINK( AddLocPBHdl, void* );
@@ -193,9 +193,9 @@ private:
DECL_LINK( TrustCertLBSelectHdl, void* ); DECL_LINK( TrustCertLBSelectHdl, void* );
DECL_LINK( TrustFileLocLBSelectHdl, void* ); DECL_LINK( TrustFileLocLBSelectHdl, void* );
cssu::Sequence< SvtSecurityOptions::Certificate > maTrustedAuthors;
// void InsertCert( cssu::Reference< css::security::XCertificate >& _rxCert, USHORT _nInd );
void FillCertLB( void ); void FillCertLB( void );
void ImplCheckButtons();
public: public:
MacroSecurityTrustedSourcesTP( Window* pParent, MacroSecurity* _pDlg ); MacroSecurityTrustedSourcesTP( Window* pParent, MacroSecurity* _pDlg );

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: documentdigitalsignatures.cxx,v $ * $RCSfile: documentdigitalsignatures.cxx,v $
* *
* $Revision: 1.10 $ * $Revision: 1.11 $
* *
* last change: $Author: mt $ $Date: 2004-07-26 07:29:30 $ * last change: $Author: mt $ $Date: 2004-07-26 12:13:28 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -241,9 +241,9 @@ void DocumentDigitalSignatures::addAuthorToTrustedSources( const ::com::sun::sta
{ {
SvtSecurityOptions aSecOpts; SvtSecurityOptions aSecOpts;
SvtSecurityOptions::Certificate aNewCert; SvtSecurityOptions::Certificate aNewCert( 3 );
aNewCert[ 0 ] = XmlSec::GetContentPart( Author->getIssuerName(), String::CreateFromAscii( "CN" ) ); aNewCert[ 0 ] = Author->getIssuerName();
aNewCert[ 1 ] = XmlSec::GetHexString( Author->getIssuerUniqueID(), " " ); aNewCert[ 1 ] = bigIntegerToNumericString( Author->getSerialNumber() );
aNewCert[ 2 ] = baseEncode( Author->getEncoded(), BASE64 ); aNewCert[ 2 ] = baseEncode( Author->getEncoded(), BASE64 );
uno::Sequence< SvtSecurityOptions::Certificate > aTrustedAuthors = aSecOpts.GetTrustedAuthors(); uno::Sequence< SvtSecurityOptions::Certificate > aTrustedAuthors = aSecOpts.GetTrustedAuthors();

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: macrosecurity.cxx,v $ * $RCSfile: macrosecurity.cxx,v $
* *
* $Revision: 1.14 $ * $Revision: 1.15 $
* *
* last change: $Author: mt $ $Date: 2004-07-26 07:29:31 $ * last change: $Author: mt $ $Date: 2004-07-26 12:13:29 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -64,6 +64,8 @@
#include <xmlsecurity/certificateviewer.hxx> #include <xmlsecurity/certificateviewer.hxx>
#include <xmlsecurity/biginteger.hxx> #include <xmlsecurity/biginteger.hxx>
#include <osl/file.hxx>
#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_ #ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_
#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
@@ -197,25 +199,6 @@ MacroSecurityLevelTP::MacroSecurityLevelTP( Window* _pParent, MacroSecurity* _pD
,maLowRB ( this, ResId( RB_LOW ) ) ,maLowRB ( this, ResId( RB_LOW ) )
{ {
FreeResource(); FreeResource();
// Don't use the default v-center here...
/*
WinBits nStyle = maVeryHighRB.GetStyle();
nStyle |= WB_TOP;
maVeryHighRB.SetStyle( nStyle );
nStyle = maHighRB.GetStyle();
nStyle |= WB_TOP;
maHighRB.SetStyle( nStyle );
nStyle = maMediumRB.GetStyle();
nStyle |= WB_TOP;
maMediumRB.SetStyle( nStyle );
nStyle = maLowRB.GetStyle();
nStyle |= WB_TOP;
maLowRB.SetStyle( nStyle );
*/
} }
void MacroSecurityLevelTP::ActivatePage() void MacroSecurityLevelTP::ActivatePage()
@@ -234,40 +217,36 @@ void MacroSecurityLevelTP::ClosePage( void )
mpDlg->maSecOptions.SetMacroSecurityLevel( nLevel ); mpDlg->maSecOptions.SetMacroSecurityLevel( nLevel );
} }
void MacroSecurityTrustedSourcesTP::ImplCheckButtons()
{
bool bCertSelected = maTrustCertLB.FirstSelected() != NULL;
maViewCertPB.Enable( bCertSelected );
maRemoveCertPB.Enable( bCertSelected );
/*IMPL_LINK( MacroSecurityTrustedSourcesTP, AddCertPBHdl, void*, EMTYARG ) bool bLocationSelected = maTrustFileLocLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND;
{ maRemoveLocPB.Enable( bLocationSelected );
CertificateChooser aChooser( this, mpDlg->mxSecurityEnvironment, mpDlg->maCurrentSignatureInformations );
if( aChooser.Execute() )
{
uno::Reference< css::security::XCertificate > xCert = aChooser.GetSelectedCertificate();
if( xCert.is() )
{
FillCertLB();
}
} }
return 0;
}*/
IMPL_LINK( MacroSecurityTrustedSourcesTP, ViewCertPBHdl, void*, EMTYARG ) IMPL_LINK( MacroSecurityTrustedSourcesTP, ViewCertPBHdl, void*, EMTYARG )
{ {
if( maTrustCertLB.FirstSelected() ) if( maTrustCertLB.FirstSelected() )
{ {
USHORT nSelected = USHORT( sal_Int32( maTrustCertLB.FirstSelected()->GetUserData() ) ); USHORT nSelected = USHORT( sal_Int32( maTrustCertLB.FirstSelected()->GetUserData() ) );
const SignatureInformation& rInfo = mpDlg->maCurrentSignatureInformations[ nSelected ]; uno::Reference< dcss::security::XCertificate > xCert = mpDlg->mxSecurityEnvironment->getCertificate( maTrustedAuthors[nSelected][0], numericStringToBigInteger( maTrustedAuthors[nSelected][1] ) );
uno::Reference< dcss::security::XCertificate > xCert = mpDlg->mxSecurityEnvironment->getCertificate( rInfo.ouX509IssuerName, numericStringToBigInteger( rInfo.ouX509SerialNumber ) );
// If we don't get it, create it from signature data: // If we don't get it, create it from signature data:
if ( !xCert.is() ) if ( !xCert.is() )
xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rInfo.ouX509Certificate ) ; xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( maTrustedAuthors[nSelected][2] ) ;
DBG_ASSERT( xCert.is(), "*MacroSecurityTrustedSourcesTP::ViewCertPBHdl(): Certificate not found and can't be created!" ); DBG_ASSERT( xCert.is(), "*MacroSecurityTrustedSourcesTP::ViewCertPBHdl(): Certificate not found and can't be created!" );
if ( xCert.is() )
{
CertificateViewer aViewer( this, mpDlg->mxSecurityEnvironment, xCert ); CertificateViewer aViewer( this, mpDlg->mxSecurityEnvironment, xCert );
aViewer.Execute(); aViewer.Execute();
} }
}
return 0; return 0;
} }
@@ -297,6 +276,7 @@ IMPL_LINK( MacroSecurityTrustedSourcesTP, RemoveCertPBHdl, void*, EMTYARG )
maTrustedAuthors = aNewSeq; maTrustedAuthors = aNewSeq;
FillCertLB(); FillCertLB();
ImplCheckButtons();
} }
return 0; return 0;
@@ -322,10 +302,17 @@ IMPL_LINK( MacroSecurityTrustedSourcesTP, AddLocPBHdl, void*, EMTYARG )
// then the new path also an URL else system path // then the new path also an URL else system path
String aNewPathStr = ( aNewObj.GetProtocol() != INET_PROT_NOT_VALID )? aPathStr : aNewObj.getFSysPath( INetURLObject::FSYS_DETECT ); String aNewPathStr = ( aNewObj.GetProtocol() != INET_PROT_NOT_VALID )? aPathStr : aNewObj.getFSysPath( INetURLObject::FSYS_DETECT );
::rtl::OUString aSystemFileURL( aNewPathStr );
if ( osl::FileBase::getSystemPathFromFileURL( aSystemFileURL, aSystemFileURL ) == osl::FileBase::E_None )
aNewPathStr = aSystemFileURL;
if( maTrustFileLocLB.GetEntryPos( aNewPathStr ) == LISTBOX_ENTRY_NOTFOUND ) if( maTrustFileLocLB.GetEntryPos( aNewPathStr ) == LISTBOX_ENTRY_NOTFOUND )
{ {
maTrustFileLocLB.InsertEntry( aNewPathStr ); maTrustFileLocLB.InsertEntry( aNewPathStr );
} }
ImplCheckButtons();
} }
catch( uno::Exception& ) catch( uno::Exception& )
{ {
@@ -341,6 +328,7 @@ IMPL_LINK( MacroSecurityTrustedSourcesTP, RemoveLocPBHdl, void*, EMTYARG )
if( nSel != LISTBOX_ENTRY_NOTFOUND ) if( nSel != LISTBOX_ENTRY_NOTFOUND )
{ {
maTrustFileLocLB.RemoveEntry( nSel ); maTrustFileLocLB.RemoveEntry( nSel );
ImplCheckButtons();
} }
return 0; return 0;
@@ -348,30 +336,16 @@ IMPL_LINK( MacroSecurityTrustedSourcesTP, RemoveLocPBHdl, void*, EMTYARG )
IMPL_LINK( MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl, void*, EMTYARG ) IMPL_LINK( MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl, void*, EMTYARG )
{ {
bool bSel = maTrustCertLB.FirstSelected() != NULL; ImplCheckButtons();
maViewCertPB.Enable( bSel );
maRemoveCertPB.Enable( bSel );
return 0; return 0;
} }
IMPL_LINK( MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl, void*, EMTYARG ) IMPL_LINK( MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl, void*, EMTYARG )
{ {
maRemoveLocPB.Enable( maTrustFileLocLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND ); ImplCheckButtons();
return 0; return 0;
} }
/*void MacroSecurityTrustedSourcesTP::InsertCert( uno::Reference< css::security::XCertificate >& _rxCert, USHORT _nInd )
{
String aCN_Id( String::CreateFromAscii( "CN" ) );
SvLBoxEntry* pEntry = maTrustCertLB.InsertEntry( XmlSec::GetContentPart( _rxCert->getIssuerName(), aCN_Id ) );
maTrustCertLB.SetEntryText( XmlSec::GetContentPart( _rxCert->getIssuerName(), aCN_Id ), pEntry, 1 );
maTrustCertLB.SetEntryText( XmlSec::GetDateString( _rxCert->getNotAfter() ), pEntry, 2 );
pEntry->SetUserData( ( void* ) _nInd );
}*/
void MacroSecurityTrustedSourcesTP::FillCertLB( void ) void MacroSecurityTrustedSourcesTP::FillCertLB( void )
{ {
maTrustCertLB.Clear(); maTrustCertLB.Clear();
@@ -413,7 +387,6 @@ MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP( Window* _pParent,
FreeResource(); FreeResource();
maTrustCertLB.SetSelectHdl( LINK( this, MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl ) ); maTrustCertLB.SetSelectHdl( LINK( this, MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl ) );
// maAddCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, AddCertPBHdl ) );
maAddCertPB.Hide(); // not used in the moment... maAddCertPB.Hide(); // not used in the moment...
maViewCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, ViewCertPBHdl ) ); maViewCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, ViewCertPBHdl ) );
maViewCertPB.Disable(); maViewCertPB.Disable();
@@ -425,10 +398,18 @@ MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP( Window* _pParent,
maRemoveLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveLocPBHdl ) ); maRemoveLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveLocPBHdl ) );
maRemoveLocPB.Disable(); maRemoveLocPB.Disable();
maTrustedAuthors = mpDlg->maSecOptions.GetTrustedAuthors();
FillCertLB();
cssu::Sequence< rtl::OUString > aSecureURLs = mpDlg->maSecOptions.GetSecureURLs(); cssu::Sequence< rtl::OUString > aSecureURLs = mpDlg->maSecOptions.GetSecureURLs();
sal_Int32 nEntryCnt = aSecureURLs.getLength(); sal_Int32 nEntryCnt = aSecureURLs.getLength();
for( sal_Int32 i = 0 ; i < nEntryCnt ; ++i ) for( sal_Int32 i = 0 ; i < nEntryCnt ; ++i )
maTrustFileLocLB.InsertEntry( aSecureURLs[ i ] ); {
::rtl::OUString aSystemFileURL( aSecureURLs[ i ] );
osl::FileBase::getSystemPathFromFileURL( aSystemFileURL, aSystemFileURL );
maTrustFileLocLB.InsertEntry( aSystemFileURL );
}
} }
void MacroSecurityTrustedSourcesTP::ActivatePage() void MacroSecurityTrustedSourcesTP::ActivatePage()
@@ -444,7 +425,11 @@ void MacroSecurityTrustedSourcesTP::ClosePage( void )
{ {
cssu::Sequence< rtl::OUString > aSecureURLs( nEntryCnt ); cssu::Sequence< rtl::OUString > aSecureURLs( nEntryCnt );
for( USHORT i = 0 ; i < nEntryCnt ; ++i ) for( USHORT i = 0 ; i < nEntryCnt ; ++i )
aSecureURLs[ i ] = maTrustFileLocLB.GetEntry( i ); {
::rtl::OUString aURL( maTrustFileLocLB.GetEntry( i ) );
osl::FileBase::getFileURLFromSystemPath( aURL, aURL );
aSecureURLs[ i ] = aURL;
}
mpDlg->maSecOptions.SetSecureURLs( aSecureURLs ); mpDlg->maSecOptions.SetSecureURLs( aSecureURLs );
} }