#i20883# macro security
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: macrosecurity.hxx,v $
|
* $RCSfile: macrosecurity.hxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.1 $
|
* $Revision: 1.2 $
|
||||||
*
|
*
|
||||||
* last change: $Author: gt $ $Date: 2004-07-16 06:23:45 $
|
* last change: $Author: gt $ $Date: 2004-07-16 07:52:00 $
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -72,6 +72,9 @@
|
|||||||
#include <svx/simptabl.hxx>
|
#include <svx/simptabl.hxx>
|
||||||
#include <svtools/svmedit.hxx>
|
#include <svtools/svmedit.hxx>
|
||||||
|
|
||||||
|
#include <xmlsecurity/documentsignaturehelper.hxx>
|
||||||
|
#include <xmlsecurity/xmlsignaturehelper.hxx>
|
||||||
|
|
||||||
namespace com {
|
namespace com {
|
||||||
namespace sun {
|
namespace sun {
|
||||||
namespace star {
|
namespace star {
|
||||||
@@ -81,6 +84,17 @@ namespace xml { namespace crypto {
|
|||||||
class XSecurityEnvironment; }}
|
class XSecurityEnvironment; }}
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
|
namespace com {
|
||||||
|
namespace sun {
|
||||||
|
namespace star {
|
||||||
|
namespace lang {
|
||||||
|
class XMultiServiceFactory; }
|
||||||
|
namespace io {
|
||||||
|
class XStream; }
|
||||||
|
namespace embed {
|
||||||
|
class XStorage; }
|
||||||
|
}}}
|
||||||
|
|
||||||
namespace css = com::sun::star;
|
namespace css = com::sun::star;
|
||||||
namespace cssu = com::sun::star::uno;
|
namespace cssu = com::sun::star::uno;
|
||||||
namespace dcss = ::com::sun::star;
|
namespace dcss = ::com::sun::star;
|
||||||
@@ -97,10 +111,13 @@ private:
|
|||||||
HelpButton maHelpBtn;
|
HelpButton maHelpBtn;
|
||||||
PushButton maResetBtn;
|
PushButton maResetBtn;
|
||||||
|
|
||||||
|
XMLSignatureHelper maSignatureHelper;
|
||||||
cssu::Reference< dcss::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment;
|
cssu::Reference< dcss::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment;
|
||||||
// cssu::Reference< dcss::security::XCertificate > mxCert;
|
SignatureInformations maCurrentSignatureInformations;
|
||||||
public:
|
public:
|
||||||
MacroSecurity( Window* pParent, cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment );
|
MacroSecurity( Window* pParent,
|
||||||
|
cssu::Reference< css::lang::XMultiServiceFactory >& rxMSF,
|
||||||
|
cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment );
|
||||||
virtual ~MacroSecurity();
|
virtual ~MacroSecurity();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,7 +125,7 @@ public:
|
|||||||
class MacroSecurityTP : public TabPage
|
class MacroSecurityTP : public TabPage
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
MacroSecurity* mpDlg;
|
MacroSecurity* mpDlg;
|
||||||
public:
|
public:
|
||||||
MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg );
|
MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg );
|
||||||
inline void SetTabDlg( MacroSecurity* pTabDlg );
|
inline void SetTabDlg( MacroSecurity* pTabDlg );
|
||||||
@@ -154,6 +171,11 @@ private:
|
|||||||
DECL_LINK( RemoveCertPBHdl, void* );
|
DECL_LINK( RemoveCertPBHdl, void* );
|
||||||
DECL_LINK( AddLocPBHdl, void* );
|
DECL_LINK( AddLocPBHdl, void* );
|
||||||
DECL_LINK( RemoveLocPBHdl, void* );
|
DECL_LINK( RemoveLocPBHdl, void* );
|
||||||
|
DECL_LINK( TrustCertLBSelectHdl, void* );
|
||||||
|
DECL_LINK( TrustFileLocLBSelectHdl, void* );
|
||||||
|
|
||||||
|
// void InsertCert( cssu::Reference< css::security::XCertificate >& _rxCert, USHORT _nInd );
|
||||||
|
void FillCertLB( void );
|
||||||
public:
|
public:
|
||||||
MacroSecurityTrustedSourcesTP( Window* pParent, MacroSecurity* _pDlg );
|
MacroSecurityTrustedSourcesTP( Window* pParent, MacroSecurity* _pDlg );
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: macrosecurity.cxx,v $
|
* $RCSfile: macrosecurity.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.1 $
|
* $Revision: 1.2 $
|
||||||
*
|
*
|
||||||
* last change: $Author: gt $ $Date: 2004-07-16 06:27:38 $
|
* last change: $Author: gt $ $Date: 2004-07-16 07:51:43 $
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -60,6 +60,7 @@
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#include <xmlsecurity/macrosecurity.hxx>
|
#include <xmlsecurity/macrosecurity.hxx>
|
||||||
|
#include <xmlsecurity/certificatechooser.hxx>
|
||||||
#include <xmlsecurity/certificateviewer.hxx>
|
#include <xmlsecurity/certificateviewer.hxx>
|
||||||
|
|
||||||
#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_
|
#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_
|
||||||
@@ -90,13 +91,14 @@ using namespace ::com::sun::star;
|
|||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
|
|
||||||
|
|
||||||
MacroSecurity::MacroSecurity( Window* _pParent, cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment )
|
MacroSecurity::MacroSecurity( Window* _pParent, cssu::Reference< lang::XMultiServiceFactory >& rxMSF, cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment )
|
||||||
:TabDialog ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROSEC ) )
|
:TabDialog ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROSEC ) )
|
||||||
,maTabCtrl ( this, ResId( 1 ) )
|
,maSignatureHelper ( rxMSF )
|
||||||
,maOkBtn ( this, ResId( BTN_OK ) )
|
,maTabCtrl ( this, ResId( 1 ) )
|
||||||
,maCancelBtn ( this, ResId( BTN_CANCEL ) )
|
,maOkBtn ( this, ResId( BTN_OK ) )
|
||||||
,maHelpBtn ( this, ResId( BTN_HELP ) )
|
,maCancelBtn ( this, ResId( BTN_CANCEL ) )
|
||||||
,maResetBtn ( this, ResId( BTN_RESET ) )
|
,maHelpBtn ( this, ResId( BTN_HELP ) )
|
||||||
|
,maResetBtn ( this, ResId( BTN_RESET ) )
|
||||||
{
|
{
|
||||||
FreeResource();
|
FreeResource();
|
||||||
|
|
||||||
@@ -137,11 +139,37 @@ void MacroSecurityLevelTP::ActivatePage()
|
|||||||
|
|
||||||
IMPL_LINK( MacroSecurityTrustedSourcesTP, AddCertPBHdl, void*, EMTYARG )
|
IMPL_LINK( MacroSecurityTrustedSourcesTP, AddCertPBHdl, void*, EMTYARG )
|
||||||
{
|
{
|
||||||
|
CertificateChooser aChooser( this, mpDlg->mxSecurityEnvironment, mpDlg->maCurrentSignatureInformations );
|
||||||
|
if( aChooser.Execute() )
|
||||||
|
{
|
||||||
|
uno::Reference< css::security::XCertificate > xCert = aChooser.GetSelectedCertificate();
|
||||||
|
|
||||||
|
// InsertCert( xCert );
|
||||||
|
|
||||||
|
FillCertLB();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPL_LINK( MacroSecurityTrustedSourcesTP, ViewCertPBHdl, void*, EMTYARG )
|
IMPL_LINK( MacroSecurityTrustedSourcesTP, ViewCertPBHdl, void*, EMTYARG )
|
||||||
{
|
{
|
||||||
|
if( maTrustCertLB.FirstSelected() )
|
||||||
|
{
|
||||||
|
USHORT nSelected = (USHORT) maTrustCertLB.FirstSelected()->GetUserData();
|
||||||
|
const SignatureInformation& rInfo = mpDlg->maCurrentSignatureInformations[ nSelected ];
|
||||||
|
uno::Reference< dcss::security::XCertificate > xCert = mpDlg->maSignatureHelper.GetSecurityEnvironment()->getCertificate( rInfo.ouX509IssuerName, numericStringToBigInteger( rInfo.ouX509SerialNumber ) );
|
||||||
|
|
||||||
|
// If we don't get it, create it from signature data:
|
||||||
|
if ( !xCert.is() )
|
||||||
|
xCert = mpDlg->maSignatureHelper.GetSecurityEnvironment()->createCertificateFromAscii( rInfo.ouX509Certificate ) ;
|
||||||
|
|
||||||
|
DBG_ASSERT( xCert.is(), "*MacroSecurityTrustedSourcesTP::ViewCertPBHdl(): Certificate not found and can't be created!" );
|
||||||
|
|
||||||
|
uno::Reference< css::xml::crypto::XSecurityEnvironment > xSecEnv = mpDlg->maSignatureHelper.GetSecurityEnvironment();
|
||||||
|
CertificateViewer aViewer( this, xSecEnv, xCert );
|
||||||
|
aViewer.Execute();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +188,77 @@ IMPL_LINK( MacroSecurityTrustedSourcesTP, RemoveLocPBHdl, void*, EMTYARG )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMPL_LINK( MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl, void*, EMTYARG )
|
||||||
|
{
|
||||||
|
bool bSel = maTrustCertLB.FirstSelected() != NULL;
|
||||||
|
maViewCertPB.Enable( bSel );
|
||||||
|
maRemoveCertPB.Enable( bSel );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPL_LINK( MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl, void*, EMTYARG )
|
||||||
|
{
|
||||||
|
maRemoveLocPB.Enable( maTrustFileLocLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND );
|
||||||
|
|
||||||
|
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 )
|
||||||
|
{
|
||||||
|
maTrustCertLB.Clear();
|
||||||
|
|
||||||
|
uno::Reference< css::xml::crypto::XSecurityEnvironment > xSecEnv = mpDlg->maSignatureHelper.GetSecurityEnvironment();
|
||||||
|
uno::Reference< css::security::XCertificate > xCert;
|
||||||
|
|
||||||
|
String aCN_Id( String::CreateFromAscii( "CN" ) );
|
||||||
|
int nInfos = mpDlg->maCurrentSignatureInformations.size();
|
||||||
|
for( int n = 0; n < nInfos; ++n )
|
||||||
|
{
|
||||||
|
const SignatureInformation& rInfo = mpDlg->maCurrentSignatureInformations[n];
|
||||||
|
xCert = xSecEnv->getCertificate( rInfo.ouX509IssuerName, numericStringToBigInteger( rInfo.ouX509SerialNumber ) );
|
||||||
|
|
||||||
|
// If we don't get it, create it from signature data:
|
||||||
|
if ( !xCert.is() )
|
||||||
|
xCert = xSecEnv->createCertificateFromAscii( rInfo.ouX509Certificate ) ;
|
||||||
|
|
||||||
|
DBG_ASSERT( xCert.is(), "Certificate not found and can't be created!" );
|
||||||
|
|
||||||
|
String aSubject;
|
||||||
|
String aIssuer;
|
||||||
|
String aDateTimeStr;
|
||||||
|
if( xCert.is() )
|
||||||
|
{
|
||||||
|
aSubject = XmlSec::GetContentPart( xCert->getSubjectName(), aCN_Id );
|
||||||
|
aIssuer = XmlSec::GetContentPart( rInfo.ouX509IssuerName, aCN_Id );
|
||||||
|
// aDateTimeStr = XmlSec::GetDateString( xCert->getNotAfter() );
|
||||||
|
aDateTimeStr = XmlSec::GetDateTimeString( rInfo.ouDate, rInfo.ouTime );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if OSL_DEBUG_LEVEL > 1
|
||||||
|
aSubject = String::CreateFromAscii( "ERROR getting certificate!" );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
SvLBoxEntry* pEntry = maTrustCertLB.InsertEntry( aSubject );
|
||||||
|
maTrustCertLB.SetEntryText( aIssuer, pEntry, 1 );
|
||||||
|
maTrustCertLB.SetEntryText( aDateTimeStr, pEntry, 2 );
|
||||||
|
pEntry->SetUserData( ( void* ) n ); // missuse user data as index
|
||||||
|
}
|
||||||
|
|
||||||
|
TrustCertLBSelectHdl( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP( Window* _pParent, MacroSecurity* _pDlg )
|
MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP( Window* _pParent, MacroSecurity* _pDlg )
|
||||||
:MacroSecurityTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_TRUSTSOURCES ), _pDlg )
|
:MacroSecurityTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_TRUSTSOURCES ), _pDlg )
|
||||||
,maTrustCertFL ( this, ResId( FL_TRUSTCERT ) )
|
,maTrustCertFL ( this, ResId( FL_TRUSTCERT ) )
|
||||||
@@ -178,6 +277,17 @@ MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP( Window* _pParent,
|
|||||||
maTrustCertLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) );
|
maTrustCertLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) );
|
||||||
|
|
||||||
FreeResource();
|
FreeResource();
|
||||||
|
|
||||||
|
maAddCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, AddCertPBHdl ) );
|
||||||
|
maViewCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, ViewCertPBHdl ) );
|
||||||
|
maViewCertPB.Disable();
|
||||||
|
maRemoveCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveCertPBHdl ) );
|
||||||
|
maRemoveCertPB.Disable();
|
||||||
|
maAddLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, AddLocPBHdl ) );
|
||||||
|
maRemoveLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveLocPBHdl ) );
|
||||||
|
maRemoveLocPB.Disable();
|
||||||
|
|
||||||
|
FillCertLB();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSecurityTrustedSourcesTP::ActivatePage()
|
void MacroSecurityTrustedSourcesTP::ActivatePage()
|
||||||
|
|||||||
Reference in New Issue
Block a user