diff options
Diffstat (limited to 'xmlsecurity/source/dialogs')
-rw-r--r-- | xmlsecurity/source/dialogs/certificatechooser.cxx | 216 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/certificatechooser.src | 125 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/certificateviewer.cxx | 397 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/certificateviewer.src | 334 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/dialogs.hrc | 263 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 545 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.src | 159 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/makefile.mk | 100 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/resourcemanager.cxx | 190 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/resourcemanager.hxx | 96 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/stbcontrl.cxx | 232 |
11 files changed, 2657 insertions, 0 deletions
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx new file mode 100644 index 000000000000..efab9b3143e1 --- /dev/null +++ b/xmlsecurity/source/dialogs/certificatechooser.cxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * $RCSfile: certificatechooser.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <xmlsecurity/certificatechooser.hxx> +#include <xmlsecurity/certificateviewer.hxx> + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_ +#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> +#endif + +#ifndef _COMPHELPER_SEQUENCE_HXX_ +#include <comphelper/sequence.hxx> +#endif + +// MM : added for password exception +#include <vcl/msgbox.hxx> +#include <com/sun/star/security/NoPasswordException.hpp> +using namespace ::com::sun::star::security; + +// Only for bigIntegerToNumericString +#include <xmlsecurity/xmlsignaturehelper.hxx> + +#include "dialogs.hrc" +#include "resourcemanager.hxx" + +/* HACK: disable some warnings for MS-C */ +#ifdef _MSC_VER +#pragma warning (disable : 4355) // 4355: this used in initializer-list +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star; + +#define INVAL_SEL 0xFFFF + + +USHORT CertificateChooser::GetSelectedEntryPos( void ) const +{ + USHORT nSel = INVAL_SEL; + + SvLBoxEntry* pSel = maCertLB.FirstSelected(); + if( pSel ) + nSel = ( USHORT ) pSel->GetUserData(); + + return nSel; +} + +CertificateChooser::CertificateChooser( Window* _pParent, uno::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, const SignatureInformations& _rCertsToIgnore ) + :ModalDialog ( _pParent, XMLSEC_RES( RID_XMLSECDLG_CERTCHOOSER ) ) + ,maHintFT ( this, ResId( FT_HINT_SELECT ) ) + ,maCertLB ( this, ResId( LB_SIGNATURES ) ) + ,maViewBtn ( this, ResId( BTN_VIEWCERT ) ) + ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP ) ) + ,maOKBtn ( this, ResId( BTN_OK ) ) + ,maCancelBtn ( this, ResId( BTN_CANCEL ) ) + ,maHelpBtn ( this, ResId( BTN_HELP ) ) +{ + static long nTabs[] = { 3, 0, 30*CS_LB_WIDTH/100, 60*CS_LB_WIDTH/100 }; + maCertLB.SetTabs( &nTabs[0] ); + maCertLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) ); + + FreeResource(); + + mxSecurityEnvironment = _rxSecurityEnvironment; + + + maCertLB.SetSelectHdl( LINK( this, CertificateChooser, CertificateHighlightHdl ) ); + maCertLB.SetDoubleClickHdl( LINK( this, CertificateChooser, CertificateSelectHdl ) ); + + // MM : added for password exception + try + { + maCerts = mxSecurityEnvironment->getPersonalCertificates(); + } + catch (NoPasswordException&) + { + InfoBox( this, rtl::OUString( String( RTL_CONSTASCII_USTRINGPARAM( "No password is provided!\n\n" ) ) ) ).Execute(); + } + + sal_Int32 nCertificates = maCerts.getLength(); + sal_Int32 nCertificatesToIgnore = _rCertsToIgnore.size(); + if( nCertificatesToIgnore ) + { + for( sal_Int32 nCert = nCertificates; nCert; ) + { + uno::Reference< security::XCertificate > xCert = maCerts[ --nCert ]; + int nCertsToIgnore = _rCertsToIgnore.size(); + for( sal_Int32 nSig = 0; nSig < nCertificatesToIgnore; ++nSig ) + { + const SignatureInformation& rInf = _rCertsToIgnore[ nSig ]; + if( ( xCert->getIssuerName() == rInf.ouX509IssuerName ) && ( bigIntegerToNumericString( xCert->getSerialNumber() ) == rInf.ouX509SerialNumber ) ) + { + ::comphelper::removeElementAt( maCerts, nCert ); + } + } + } + nCertificates = maCerts.getLength(); + } + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + + for( sal_Int32 nC = 0; nC < nCertificates; ++nC ) + { + String aSubject ( XmlSec::GetContentPart( maCerts[ nC ]->getSubjectName(), aCN_Id ) ); + String aDateTimeStr( XmlSec::GetDateString( maCerts[ nC ]->getNotAfter() ) ); + String aIssuer ( XmlSec::GetContentPart( maCerts[ nC ]->getIssuerName(), aCN_Id ) ); + + SvLBoxEntry* pEntry = maCertLB.InsertEntry( aSubject ); + maCertLB.SetEntryText( aIssuer, pEntry, 1 ); + maCertLB.SetEntryText( aDateTimeStr, pEntry, 2 ); + pEntry->SetUserData( ( void* ) nC ); // missuse user data as index + } + + maViewBtn.SetClickHdl( LINK( this, CertificateChooser, ViewButtonHdl ) ); + maViewBtn.Disable(); +} + +CertificateChooser::~CertificateChooser() +{ +} + +uno::Reference< dcss::security::XCertificate > CertificateChooser::GetSelectedCertificate() +{ + uno::Reference< dcss::security::XCertificate > xCert; + USHORT nSelected = GetSelectedEntryPos(); + if( nSelected < maCerts.getLength() ) + xCert = maCerts[ nSelected ]; + + return xCert; +} + +IMPL_LINK( CertificateChooser, CertificateHighlightHdl, void*, EMPTYARG ) +{ + maViewBtn.Enable(); + return 0; +} + +IMPL_LINK( CertificateChooser, CertificateSelectHdl, void*, EMPTYARG ) +{ + EndDialog( 1 ); + return 0; +} + +IMPL_LINK( CertificateChooser, ViewButtonHdl, Button*, EMPTYARG ) +{ + ImplShowCertificateDetails(); + return 0; +} + +void CertificateChooser::ImplShowCertificateDetails() +{ + uno::Reference< dcss::security::XCertificate > xCert = GetSelectedCertificate(); + if( xCert.is() ) + { + CertificateViewer aViewer( this, mxSecurityEnvironment, xCert ); + aViewer.Execute(); + } +}
\ No newline at end of file diff --git a/xmlsecurity/source/dialogs/certificatechooser.src b/xmlsecurity/source/dialogs/certificatechooser.src new file mode 100644 index 000000000000..9431a3405608 --- /dev/null +++ b/xmlsecurity/source/dialogs/certificatechooser.src @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: certificatechooser.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "dialogs.hrc" + +ModalDialog RID_XMLSECDLG_CERTCHOOSER +{ +// HelpId = HID_XMLSECDLG_CERTCHOOSER; + Size = MAP_APPFONT( CS_WIDTH, CS_HEIGHT ); + OutputSize = TRUE; + Closeable = TRUE; + Moveable = TRUE; + SVLook = TRUE; + +// Text = "Zertifikat auswhlen"; + Text = "Select Certificate"; + Text [ en-US ] = "Select Certificate"; + + FixedText FT_HINT_SELECT + { + Pos = MAP_APPFONT( CS_COL_0, CS_ROW_0 ); + Size = MAP_APPFONT( CS_COL_2-CS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Select the certificate you want to use for signing"; + Text [ en-US ] = "Select the certificate you want to use for signing"; + }; + Control LB_SIGNATURES + { + Pos = MAP_APPFONT( CS_COL_0, CS_ROW_1 ); + Size = MAP_APPFONT( CS_LB_WIDTH, CS_ROW_2-CS_ROW_1 ); + SVLook = TRUE; + Border = TRUE; + }; + String STR_HEADERBAR + { + Text = "Issued to\tIssued by\tExpiration Date"; + Text [ en-US ] = "Issued to\tIssued by\tExpiration Date"; + }; + PushButton BTN_VIEWCERT + { + Pos = MAP_APPFONT( CS_COL_1, CS_ROW_3 ); + Size = MAP_APPFONT( CS_COL_2-CS_COL_1, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Zertifikat anzeigen..."; + Text = "View Certificate..."; + Text [ en-US ] = "View Certificate..."; + }; + FixedLine FL_BOTTOM_SEP + { + Pos = MAP_APPFONT( 0, DLGS_BOTTOM_FL_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( CS_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ); + }; + OKButton BTN_OK + { + DefButton = TRUE; + Pos = MAP_APPFONT( DLGS_BOTTOM_OK_X( CS_WIDTH ), DLGS_BOTTOM_BTN_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT( DLGS_BOTTOM_CANCEL_X( CS_WIDTH ), DLGS_BOTTOM_BTN_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT( DLGS_BOTTOM_HELP_X( CS_WIDTH ), DLGS_BOTTOM_BTN_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; +}; diff --git a/xmlsecurity/source/dialogs/certificateviewer.cxx b/xmlsecurity/source/dialogs/certificateviewer.cxx new file mode 100644 index 000000000000..1d106bc4f51b --- /dev/null +++ b/xmlsecurity/source/dialogs/certificateviewer.cxx @@ -0,0 +1,397 @@ +/************************************************************************* + * + * $RCSfile: certificateviewer.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <xmlsecurity/certificateviewer.hxx> + +// Only for bigIntegerToNumericString +#include <xmlsecurity/xmlsignaturehelper.hxx> + + +#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATE_HPP_ +#include <com/sun/star/security/XCertificate.hpp> +#endif + +#include "dialogs.hrc" +#include "resourcemanager.hxx" + +/* HACK: disable some warnings for MS-C */ +#ifdef _MSC_VER +#pragma warning (disable : 4355) // 4355: this used in initializer-list +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; + + +namespace +{ + void AdjustPosAndSize( Control& _rCtrl, Point& _rStartIn_EndOut, long _nXOffset = 0 ); + + void AdjustPosAndSize( Control& _rCtrl, Point& _rStartIn_EndOut, long _nOffs ) + { + long nWidth = _rCtrl.GetTextWidth( _rCtrl.GetText() ); + Size aSize( _rCtrl.GetSizePixel() ); + nWidth += _nOffs; + aSize.Width() = nWidth; + _rCtrl.SetPosPixel( _rStartIn_EndOut ); + _rCtrl.SetSizePixel( aSize ); + _rStartIn_EndOut.X() += nWidth; + } +}; + +CertificateViewer::CertificateViewer( + Window* _pParent, + cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, + cssu::Reference< dcss::security::XCertificate >& _rXCert ) + :TabDialog ( _pParent, XMLSEC_RES( RID_XMLSECDLG_CERTVIEWER ) ) + ,maTabCtrl ( this, ResId( 1 ) ) + ,maOkBtn ( this, ResId( BTN_OK ) ) + ,maHelpBtn ( this, ResId( BTN_HELP ) ) +{ + FreeResource(); + + mxSecurityEnvironment = _rxSecurityEnvironment; + mxCert = _rXCert; + + maTabCtrl.SetTabPage( RID_XMLSECTP_GENERAL, new CertificateViewerGeneralTP( &maTabCtrl, this ) ); + maTabCtrl.SetTabPage( RID_XMLSECTP_DETAILS, new CertificateViewerDetailsTP( &maTabCtrl, this ) ); + maTabCtrl.SetTabPage( RID_XMLSECTP_CERTPATH, new CertificateViewerCertPathTP( &maTabCtrl, this ) ); + maTabCtrl.SetCurPageId( RID_XMLSECTP_GENERAL ); +} + +CertificateViewer::~CertificateViewer() +{ + delete maTabCtrl.GetTabPage( RID_XMLSECTP_CERTPATH ); + delete maTabCtrl.GetTabPage( RID_XMLSECTP_DETAILS ); + delete maTabCtrl.GetTabPage( RID_XMLSECTP_GENERAL ); +} + +CertificateViewerTP::CertificateViewerTP( Window* _pParent, const ResId& _rResId, CertificateViewer* _pDlg ) + :TabPage ( _pParent, _rResId ) + ,mpDlg ( _pDlg ) +{ +} + + +CertificateViewerGeneralTP::CertificateViewerGeneralTP( Window* _pParent, CertificateViewer* _pDlg ) + :CertificateViewerTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_GENERAL ), _pDlg ) + ,maFrameWin ( this, ResId( WIN_FRAME ) ) + ,maCertImg ( this, ResId( IMG_CERT ) ) + ,maCertInfoFI ( this, ResId( FI_CERTINFO ) ) + ,maSep1FL ( this, ResId( FL_SEP1 ) ) + ,maHintNotTrustedFI ( this, ResId( FI_HINTNOTTRUST ) ) + ,maSep2FL ( this, ResId( FL_SEP2 ) ) + ,maIssuedToLabelFI ( this, ResId( FI_ISSTOLABEL ) ) + ,maIssuedToFI ( this, ResId( FI_ISSTO ) ) + ,maIssuedByLabelFI ( this, ResId( FI_ISSBYLABEL ) ) + ,maIssuedByFI ( this, ResId( FI_ISSBY ) ) + ,maValidFromLabelFI ( this, ResId( FI_VALFROMLABEL ) ) + ,maValidFromFI ( this, ResId( FI_VALFROM ) ) + ,maValidToLabelFI ( this, ResId( FI_VALTOLABEL ) ) + ,maValidToFI ( this, ResId( FI_VALTO ) ) + ,maKeyImg ( this, ResId( IMG_KEY ) ) + ,maHintCorrespPrivKeyFI ( this, ResId( FI_CORRPRIVKEY ) ) +{ + FreeResource(); + + Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() ); + + maFrameWin.SetBackground( aBack ); + maCertInfoFI.SetBackground( aBack ); + maSep1FL.SetBackground( aBack ); + maHintNotTrustedFI.SetBackground( aBack ); + maSep2FL.SetBackground( aBack ); + maIssuedToLabelFI.SetBackground( aBack ); + maIssuedToFI.SetBackground( aBack ); + maIssuedByLabelFI.SetBackground( aBack ); + maIssuedByFI.SetBackground( aBack ); + maValidFromLabelFI.SetBackground( aBack ); + maValidFromFI.SetBackground( aBack ); + maValidToLabelFI.SetBackground( aBack ); + maValidToFI.SetBackground( aBack ); + maKeyImg.SetBackground( aBack ); + maHintCorrespPrivKeyFI.SetBackground( aBack ); + + // make some bold + Font aFnt( maCertInfoFI.GetFont() ); + aFnt.SetWeight( WEIGHT_BOLD ); + maCertInfoFI.SetFont( aFnt ); + maHintNotTrustedFI.SetFont( aFnt ); + maIssuedToLabelFI.SetFont( aFnt ); + maIssuedByLabelFI.SetFont( aFnt ); + maValidFromLabelFI.SetFont( aFnt ); + maValidToLabelFI.SetFont( aFnt ); + + // insert data + cssu::Reference< dcss::security::XCertificate > xCert = mpDlg->mxCert; + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + + maIssuedToFI.SetText( XmlSec::GetContentPart( xCert->getSubjectName(), aCN_Id ) ); + maIssuedByFI.SetText( XmlSec::GetContentPart( xCert->getIssuerName(), aCN_Id ) ); + maValidFromFI.SetText( XmlSec::GetDateString( xCert->getNotBefore() ) ); + maValidToFI.SetText( XmlSec::GetDateString( xCert->getNotAfter() ) ); + + // recalc positions for date fields according to real size + Point aPos( maValidFromLabelFI.GetPosPixel() ); +// long nWidth; + +// nWidth = GetTextWidth( maValidFromLabelFI.GetText() ); +// maValidFromLabelFI.SetSizePixel +// aPos.X() += nWidth; + AdjustPosAndSize( maValidFromLabelFI, aPos ); + +// maValidFromFI.SetPosPixel( aPos ); +// nWidth = GetTextWidth( maValidFromFI.GetText() ); +// aPos.X() += nWidth; + AdjustPosAndSize( maValidFromFI, aPos ); + +// maValidToLabelFI.SetPosPixel( aPos ); +// nWidth = GetTextWidth( maValidToLabelFI.GetText() ); +// aPos.X() += nWidth; + +// maValidToFI.SetPosPixel( aPos ); + AdjustPosAndSize( maValidToLabelFI, aPos ); + AdjustPosAndSize( maValidToFI, aPos ); + + // adjust position of fixed text depending on image sizes + long nWidth = maCertImg.GetSizePixel().Width(); + aPos = maCertInfoFI.GetPosPixel(); + aPos.X() = maCertImg.GetPosPixel().X(); + aPos.X() += nWidth; + maCertInfoFI.SetPosPixel( aPos ); + + nWidth = maKeyImg.GetSizePixel().Width(); + aPos = maHintCorrespPrivKeyFI.GetPosPixel(); + aPos.X() = maKeyImg.GetPosPixel().X(); + aPos.X() += nWidth; +// maHintCorrespPrivKeyFI.SetPosPixel( aPos ); + AdjustPosAndSize( maHintCorrespPrivKeyFI, aPos ); +} + +void CertificateViewerGeneralTP::ActivatePage() +{ +} + + +void CertificateViewerDetailsTP::Clear( void ) +{ + maElementML.SetText( String() ); + ULONG i = 0; + SvLBoxEntry* pEntry = maElementsLB.GetEntry( i ); + while( pEntry ) + { + delete ( String* ) pEntry->GetUserData(); + ++i; + pEntry = maElementsLB.GetEntry( i ); + } + + maElementsLB.Clear(); +} + +void CertificateViewerDetailsTP::InsertElement( const String& _rField, const String& _rValue, const String& _rDetails ) +{ + SvLBoxEntry* pEntry = maElementsLB.InsertEntry( _rField ); + maElementsLB.SetEntryText( _rValue, pEntry, 1 ); + pEntry->SetUserData( ( void* ) new String( _rDetails ) ); // extended view of value +// pEntry->SetUserData( ( void* ) new String( XmlSec::GetPureContent( _rValue, "\n", true ) ) ); +} + +CertificateViewerDetailsTP::CertificateViewerDetailsTP( Window* _pParent, CertificateViewer* _pDlg ) + :CertificateViewerTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_DETAILS ), _pDlg ) + ,maElementsLB ( this, ResId( LB_ELEMENTS ) ) + ,maElementML ( this, ResId( ML_ELEMENT ) ) +{ + static long nTabs[] = { 2, 0, 40*CS_LB_WIDTH/100 }; + maElementsLB.SetTabs( &nTabs[ 0 ] ); + maElementsLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) ); + + // fill list box + Reference< security::XCertificate > xCert = mpDlg->mxCert; + String aLBEntry; + String aDetails; + aLBEntry = aDetails = String::CreateFromInt32( xCert->getVersion() ); + InsertElement( String( ResId( STR_VERSION ) ), aLBEntry, aDetails ); + Sequence< sal_Int8 > aSerNumSeq = xCert->getSerialNumber(); + const sal_Int8* pSerNumSeq = aSerNumSeq.getConstArray(); + int nCnt = aSerNumSeq.getLength(); + String aSerNumStr; + const char pHexDigs[ 17 ] = "0123456789ABCEDF"; + char pBuffer[ 4 ] = " "; + UINT8 nNum; + for( int i = 0 ; i < nCnt ; ++i ) + { + nNum = UINT8( pSerNumSeq[ i ] ); + pBuffer[ 0 ] = pHexDigs[ nNum & 0x0F ]; + nNum >>= 4; + pBuffer[ 1 ] = pHexDigs[ nNum ]; +// aSerNumStr += String::CreateFromInt32( UINT8( pSerNumSeq[ i ] ), 16 ); +// aSerNumStr.AppendAscii( " " ); + aSerNumStr.AppendAscii( pBuffer ); + } + InsertElement( String( ResId( STR_SERIALNUM ) ), aSerNumStr, aSerNumStr ); + InsertElement( String( ResId( STR_SIGALGORITHM ) ), String::CreateFromAscii( "n/a" ), String() ); + aLBEntry = XmlSec::GetPureContent( xCert->getIssuerName(), ", " ); + aDetails = XmlSec::GetPureContent( xCert->getIssuerName(), "\n", true ); + InsertElement( String( ResId( STR_ISSUER ) ), aLBEntry, aDetails ); + aLBEntry = aDetails = XmlSec::GetDateTimeString( xCert->getNotBefore() ); + InsertElement( String( ResId( STR_VALIDFROM ) ), aLBEntry, aDetails ); + aLBEntry = aDetails = XmlSec::GetDateTimeString( xCert->getNotAfter() ); + InsertElement( String( ResId( STR_VALIDTO ) ), aLBEntry, aDetails ); + aLBEntry = XmlSec::GetPureContent( xCert->getSubjectName(), ", " ); + aDetails = XmlSec::GetPureContent( xCert->getSubjectName(), "\n", true ); + InsertElement( String( ResId( STR_SUBJECT ) ), aLBEntry, aDetails ); + + FreeResource(); + + maElementsLB.SetSelectHdl( LINK( this, CertificateViewerDetailsTP, ElementSelectHdl ) ); +} + +CertificateViewerDetailsTP::~CertificateViewerDetailsTP() +{ + Clear(); +} + +void CertificateViewerDetailsTP::ActivatePage() +{ +} + +IMPL_LINK( CertificateViewerDetailsTP, ElementSelectHdl, void*, EMPTYARG ) +{ + SvLBoxEntry* pEntry = maElementsLB.FirstSelected(); + String aElementText; + if( pEntry ) + { + aElementText = *( ( String* ) pEntry->GetUserData() ); + } + + maElementML.SetText( aElementText ); + + return 0; +} + + + +CertificateViewerCertPathTP::CertificateViewerCertPathTP( Window* _pParent, CertificateViewer* _pDlg ) + :CertificateViewerTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_CERTPATH ), _pDlg ) + ,maCertPathFT ( this, ResId( FT_CERTPATH ) ) + ,maCertPathLB ( this, ResId( LB_SIGNATURES ) ) + ,maCertStatusFT ( this, ResId( FT_CERTSTATUS ) ) + ,maCertStatusML ( this, ResId( ML_CERTSTATUS ) ) +{ + // fill list box + Sequence< Reference< security::XCertificate > > + aCertPath = _pDlg->mxSecurityEnvironment->buildCertificatePath( _pDlg->mxCert ); + const Reference< security::XCertificate >* + pCertPath = aCertPath.getConstArray(); + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + int nCnt = aCertPath.getLength(); + for( int i = 0 ; i < nCnt ; ++i ) + InsertCert( i, XmlSec::GetContentPart( pCertPath[ i ]->getIssuerName(), aCN_Id ), String::CreateFromInt32( i ) ); + + FreeResource(); + + maCertPathLB.SetSelectHdl( LINK( this, CertificateViewerCertPathTP, CertSelectHdl ) ); +} + +CertificateViewerCertPathTP::~CertificateViewerCertPathTP() +{ + Clear(); +} + +void CertificateViewerCertPathTP::ActivatePage() +{ +} + +IMPL_LINK( CertificateViewerCertPathTP, CertSelectHdl, void*, EMPTYARG ) +{ + SvLBoxEntry* pEntry = maCertPathLB.FirstSelected(); + String aStatus; + if( pEntry ) + aStatus = *( ( String* ) pEntry->GetUserData() ); + + maCertStatusML.SetText( aStatus ); + + return 0; +} + +void CertificateViewerCertPathTP::Clear( void ) +{ + maCertStatusML.SetText( String() ); + ULONG i = 0; + SvLBoxEntry* pEntry = maCertPathLB.GetEntry( i ); + while( pEntry ) + { + delete ( String* ) pEntry->GetUserData(); + ++i; + pEntry = maCertPathLB.GetEntry( i ); + } + + maCertPathLB.Clear(); +} + +void CertificateViewerCertPathTP::InsertCert( int _nLevel, const String& _rName, const String& _rStatus ) +{ + SvLBoxEntry* pEntry = maCertPathLB.InsertEntry( _rName ); + pEntry->SetUserData( ( void* ) new String( _rStatus ) ); +} diff --git a/xmlsecurity/source/dialogs/certificateviewer.src b/xmlsecurity/source/dialogs/certificateviewer.src new file mode 100644 index 000000000000..3749294bdfc1 --- /dev/null +++ b/xmlsecurity/source/dialogs/certificateviewer.src @@ -0,0 +1,334 @@ +/************************************************************************* + * + * $RCSfile: certificateviewer.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "dialogs.hrc" + +TabDialog RID_XMLSECDLG_CERTVIEWER +{ + // HelpID = HID_XMLSECDLG_CERTVIEWER; + Size = MAP_APPFONT( TD_WIDTH, TD_HEIGHT ); + OutputSize = TRUE; + Closeable = TRUE; + Moveable = TRUE; + SVLook = TRUE; + + Text = "View Certificate"; + Text [ en-US ] = "View Certificate"; + TabControl 1 + { + Pos = MAP_APPFONT( TD_SP_INNERBORDER_LEFT, TD_SP_INNERBORDER_TOP ); + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT+RIDDER_HEIGHT ); + SVLook = TRUE ; + PageList = + { + PageItem + { + Identifier = RID_XMLSECTP_GENERAL; + Text = "General"; + Text [ en-US ] = "General"; + }; + PageItem + { + Identifier = RID_XMLSECTP_DETAILS; + Text = "Details"; + Text [ en-US ] = "Details"; + }; + PageItem + { + Identifier = RID_XMLSECTP_CERTPATH; + Text = "Certification Path"; + Text [ en-US ] = "Certification Path"; + }; + }; + }; + OKButton BTN_OK + { + Pos = MAP_APPFONT( CV_COL_A, CV_ROW_A ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + DefButton = TRUE; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT( CV_COL_C, CV_ROW_A ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; +}; + +TabPage RID_XMLSECTP_GENERAL +{ +// HelpId = HID_XMLSECTP_GENERAL; + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT ); + OutputSize = TRUE; + Hide = TRUE; + SVLook = TRUE; + Window WIN_FRAME + { + SVLook = TRUE; + Border = TRUE; + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_CONT_HEIGHT ); + }; + FixedImage IMG_CERT + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_0 ); + Size = MAP_APPFONT( CW_COL_2-CW_COL_0, CW_ROW_2-CW_ROW_0 ); +// Fixed = Image +// { +// ImageBitmap = Bitmap { File = "xmlsec_cert_l.bmp"; }; +// MaskColor = STD_MASKCOLOR; +// }; + }; + FixedText FI_CERTINFO + { + Pos = MAP_APPFONT( CW_COL_3, CW_ROW_1 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_3, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = " Certificate Information"; + Text [ en-US ] = " Certificate Information"; + }; + FixedLine FL_SEP1 + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_3 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_0, RSC_CD_FIXEDLINE_HEIGHT ); + }; + FixedText FI_HINTNOTTRUST + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_4 ); + Size = MAP_APPFONT( CW_COL_5a-CW_COL_1, CW_ROW_4a-CW_ROW_4 ); + WordBreak = TRUE; + Text = "This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authorities store"; + Text [ en-US ] = "This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authorities store"; + }; + FixedLine FL_SEP2 + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_5 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_0, RSC_CD_FIXEDLINE_HEIGHT ); + }; + FixedText FI_ISSTOLABEL + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_6 ); + Size = MAP_APPFONT( CW_COL_4-CW_COL_1-1, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Issued to:"; + Text [ en-US ] = "Issued to:"; + }; + FixedText FI_ISSTO + { + Pos = MAP_APPFONT( CW_COL_4, CW_ROW_6 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_4, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedText FI_ISSBYLABEL + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_7 ); + Size = MAP_APPFONT( CW_COL_4-CW_COL_1-1, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Issued by:"; + Text [ en-US ] = "Issued by:"; + }; + FixedText FI_ISSBY + { + Pos = MAP_APPFONT( CW_COL_4, CW_ROW_7 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_4, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedText FI_VALFROMLABEL + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_4a-CW_COL_1-1, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Valid from "; + Text [ en-US ] = "Valid from "; + }; + FixedText FI_VALFROM + { + Pos = MAP_APPFONT( CW_COL_4a, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_4b-CW_COL_4a, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedText FI_VALTOLABEL + { + Pos = MAP_APPFONT( CW_COL_4c, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_4d-CW_COL_4c, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = " to "; + Text [ en-US ] = " to "; + }; + FixedText FI_VALTO + { + Pos = MAP_APPFONT( CW_COL_4e, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_4e, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedImage IMG_KEY + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_9 ); + Size = MAP_APPFONT( CW_COL_2-CW_COL_0, CW_ROW_11-CW_ROW_9 ); +// Fixed = Image +// { +// ImageBitmap = Bitmap { File = "xmlsec_key.bmp"; }; +// MaskColor = STD_MASKCOLOR; +// }; + }; + FixedText FI_CORRPRIVKEY + { + Pos = MAP_APPFONT( CW_COL_1a, CW_ROW_10 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_1a, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "You have a private key that corresponds to this certificate."; + Text [ en-US ] = "You have a private key that corresponds to this certificate."; + }; +}; + +TabPage RID_XMLSECTP_DETAILS +{ +// HelpId = HID_XMLSECTP_DETAILS; + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT ); + OutputSize = TRUE; + Hide = TRUE; + SVLook = TRUE; + Control LB_ELEMENTS + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_1-CV_ROW_0 ); + SVLook = TRUE; + Border = TRUE; + }; + String STR_HEADERBAR + { + Text = "Field\tValue"; + Text [ en-US ] = "Field\tValue"; + }; + MultiLineEdit ML_ELEMENT + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_2 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_3-CV_ROW_2 ); + ReadOnly = TRUE; + Border = TRUE; + }; + String STR_VERSION + { + Text = "Version"; + Text [ en-US ] = "Version"; + }; + String STR_SERIALNUM + { + Text = "Serial Number"; + Text [ en-US ] = "Serial Number"; + }; + String STR_SIGALGORITHM + { + Text = "Signature Algorithm"; + Text [ en-US ] = "Signature Algorithm"; + }; + String STR_ISSUER + { + Text = "Issuer"; + Text [ en-US ] = "Issuer"; + }; + String STR_VALIDFROM + { + Text = "Valid From"; + Text [ en-US ] = "Valid From"; + }; + String STR_VALIDTO + { + Text = "Valid to"; + Text [ en-US ] = "Valid to"; + }; + String STR_SUBJECT + { + Text = "Subject"; + Text [ en-US ] = "Subject"; + }; + String STR_PUBKEY + { + Text = "Public Key"; + Text [ en-US ] = "Public Key"; + }; +}; + +TabPage RID_XMLSECTP_CERTPATH +{ +// HelpId = HID_XMLSECTP_CERTPATH; + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT ); + OutputSize = TRUE; + Hide = TRUE; + SVLook = TRUE; + FixedText FT_CERTPATH + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Certification path"; + Text [ en-US ] = "Certification path"; + }; + Control LB_SIGNATURES + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0A ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_1-CV_ROW_0A ); + SVLook = TRUE; + Border = TRUE; + }; + FixedText FT_CERTSTATUS + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_2 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Certification status"; + Text [ en-US ] = "Certification status"; + }; + MultiLineEdit ML_CERTSTATUS + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_2A ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_3-CV_ROW_2A ); + ReadOnly = TRUE; + Border = TRUE; + }; +}; diff --git a/xmlsecurity/source/dialogs/dialogs.hrc b/xmlsecurity/source/dialogs/dialogs.hrc new file mode 100644 index 000000000000..eda9da08473a --- /dev/null +++ b/xmlsecurity/source/dialogs/dialogs.hrc @@ -0,0 +1,263 @@ +/************************************************************************* + * + * $RCSfile: dialogs.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. +* + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _DIALOGS_HRC +#define _DIALOGS_HRC + +#include <svtools/controldims.hrc> + + +#define STD_MASKCOLOR Color{Red=0xffff;Green=0x0000;Blue=0xffff;} + +// --------- general dialog ids --------- + +#define RID_XMLSECDLG_DIGSIG 1000 +#define RID_XMLSECDLG_CERTCHOOSER 1001 +#define RID_XMLSECDLG_CERTVIEWER 1002 +#define RID_XMLSECTP_GENERAL 1003 +#define RID_XMLSECTP_DETAILS 1004 +#define RID_XMLSECTP_CERTPATH 1005 + +#define FL_BOTTOM_SEP 50 +#define BTN_OK 51 +#define BTN_CANCEL 52 +#define BTN_HELP 53 +#define LB_SIGNATURES 54 +#define BTN_VIEWCERT 55 +#define STR_HEADERBAR 56 + +// --------- general metrics --------- +#define DLGS_WIDTH 287 +#define DLGS_HEIGHT 195 +// --------- ... for tab dialogs ----- +#define TP_WIDTH 260 +#define TP_HEIGHT 185 +#define RIDDER_HEIGHT (RSC_CD_PUSHBUTTON_HEIGHT) +#define TD_SP_INNERBORDER_LEFT 3 +#define TD_SP_INNERBORDER_RIGHT 3 +#define TD_SP_INNERBORDER_TOP 3 +#define TD_SP_INNERBORDER_BOTTOM 3 +#define TD_WIDTH (TP_WIDTH+TD_SP_INNERBORDER_LEFT+TD_SP_INNERBORDER_RIGHT) +#define TD_HEIGHT (TP_HEIGHT+TD_SP_INNERBORDER_TOP+2*TD_SP_INNERBORDER_BOTTOM+RSC_CD_PUSHBUTTON_HEIGHT+RIDDER_HEIGHT) + +#define SEP_FL_SPACE_Y 6 +#define SEP_FL_ADJ_Y(val) (val-3) +#define DLGS_BOTTOM_BTN_L(dlgh) (dlgh-RSC_SP_DLG_INNERBORDER_BOTTOM) +#define DLGS_BOTTOM_BTN_Y(dlgh) (DLGS_BOTTOM_BTN_L(dlgh)-RSC_CD_PUSHBUTTON_HEIGHT) +#define DLGS_BOTTOM_FL_Y(dlgh) (DLGS_BOTTOM_BTN_Y(dlgh)-SEP_FL_SPACE_Y-5) +#define DLGS_BOTTOM_LAST_CTRL_L(dlgh) (DLGS_BOTTOM_BTN_Y(dlgh)-2*SEP_FL_SPACE_Y-3) +#define DLGS_BOTTOM_HELP_X(dlgw) (dlgw-RSC_SP_DLG_INNERBORDER_RIGHT-RSC_CD_PUSHBUTTON_WIDTH) +#define DLGS_BOTTOM_CANCEL_X(dlgw) (DLGS_BOTTOM_HELP_X(dlgw)-RSC_SP_CTRL_X-RSC_CD_PUSHBUTTON_WIDTH) +#define DLGS_BOTTOM_OK_X(dlgw) (DLGS_BOTTOM_CANCEL_X(dlgw)-RSC_SP_CTRL_X-RSC_CD_PUSHBUTTON_WIDTH) + + +// --------- dialog Digital Signatures --------- +#define BTN_ADDCERT 2 +#define BTN_REMOVECERT 3 +#define FT_HINT_DOC 4 +#define FT_HINT_BASIC 5 +#define FT_HINT_PACK 6 + +//#define DS_WIDTH DLGS_WIDTH +//#define DS_HEIGHT DLGS_HEIGHT +#define DS_BTNWIDTH_1 70 +#define DS_BTNSPACE_X RSC_SP_CTRL_X +#define DS_WIDTH (RSC_SP_DLG_INNERBORDER_LEFT+RSC_SP_DLG_INNERBORDER_RIGHT+2*DS_BTNSPACE_X+3*DS_BTNWIDTH_1) +#define DS_HEIGHT (DLGS_WIDTH*2/3) + +#define DS_COL_0 RSC_SP_DLG_INNERBORDER_LEFT +//#define DS_COL_MID (DS_WIDTH/2) +//#define DS_COL_3 (DS_COL_MID-(DS_BTNWIDTH_1/2)) +//#define DS_COL_4 (DS_COL_2+DS_BTNWIDTH_1) +//#define DS_COL_2 (DS_COL_3-DS_BTNSPACE_X) +//#define DS_COL_1 (DS_COL_2-DS_BTNWIDTH_1) +#define DS_COL_1 DS_COL_0 +#define DS_COL_2 (DS_COL_1+DS_BTNWIDTH_1) +#define DS_COL_3 (DS_COL_2+DS_BTNSPACE_X) +#define DS_COL_4 (DS_COL_3+DS_BTNWIDTH_1) +#define DS_COL_5 (DS_COL_4+DS_BTNSPACE_X) +//#define DS_COL_6 (DS_COL_5+DS_BTNWIDTH_1) +#define DS_COL_7 (DS_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT) +#define DS_COL_6 DS_COL_7 + +#define DS_ROW_0 RSC_SP_DLG_INNERBORDER_TOP +#define DS_ROW_1 (DS_ROW_0+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_X) +#define DS_ROW_7 DLGS_BOTTOM_BTN_L(DS_HEIGHT) +#define DS_ROW_6 DLGS_BOTTOM_BTN_Y(DS_HEIGHT) +#define DS_ROW_5 DLGS_BOTTOM_FL_Y(DS_HEIGHT) +#define DS_ROW_4 DLGS_BOTTOM_LAST_CTRL_L(DS_HEIGHT) +#define DS_ROW_3 (DS_ROW_4-RSC_CD_PUSHBUTTON_HEIGHT) +#define DS_ROW_2 (DS_ROW_3-RSC_SP_CTRL_Y) + +#define DS_LB_WIDTH (DS_COL_7-DS_COL_0) + +// --------- dialog Ceritficate chooser --------- +#define FT_HINT_SELECT 1 + +#define CS_WIDTH DLGS_WIDTH +#define CS_HEIGHT DLGS_HEIGHT +#define CS_BTNWIDTH_1 DS_BTNWIDTH_1 + +#define CS_COL_0 RSC_SP_DLG_INNERBORDER_LEFT +#define CS_COL_2 (CS_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT) +#define CS_COL_1 (CS_COL_2-CS_BTNWIDTH_1) + +#define CS_ROW_0 RSC_SP_DLG_INNERBORDER_TOP +#define CS_ROW_1 (CS_ROW_0+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_X) +#define CS_ROW_4 DLGS_BOTTOM_LAST_CTRL_L(CS_HEIGHT) +#define CS_ROW_3 (CS_ROW_4-RSC_CD_PUSHBUTTON_HEIGHT) +#define CS_ROW_2 (CS_ROW_3-RSC_SP_CTRL_Y) + +#define CS_LB_WIDTH (CS_COL_2-CS_COL_0) + +// --------- tab dialog Certificate viewer --------- + +#define CV_COL_0 TD_SP_INNERBORDER_LEFT +#define CV_COL_1 (TP_WIDTH-RSC_SP_TBPG_INNERBORDER_RIGHT) +#define CV_ROW_0 RSC_SP_TBPG_INNERBORDER_TOP +#define CV_ROW_3 (TP_HEIGHT-RSC_SP_TBPG_INNERBORDER_BOTTOM) +#define CV_CONT_WIDTH (CV_COL_1-CV_COL_0) +#define CV_CONT_HEIGHT (CV_ROW_3-CV_ROW_0) +#define CV_ROW_1 (CV_ROW_0+2*CV_CONT_HEIGHT/3) +#define CV_ROW_2 (CV_ROW_1+RSC_SP_CTRL_GROUP_Y) + +#define CV_COL_D (TD_WIDTH-TD_SP_INNERBORDER_RIGHT) +#define CV_COL_C (CV_COL_D-RSC_CD_PUSHBUTTON_WIDTH) +#define CV_COL_B (CV_COL_C-RSC_SP_CTRL_X) +#define CV_COL_A (CV_COL_B-RSC_CD_PUSHBUTTON_WIDTH) + +#define CV_ROW_B (TD_HEIGHT-TD_SP_INNERBORDER_BOTTOM) +#define CV_ROW_A (CV_ROW_B-RSC_CD_PUSHBUTTON_HEIGHT) + +// --------- tab page Certificate viewer - General --------- +#define WIN_FRAME 2 +#define IMG_CERT 3 +#define FI_CERTINFO 4 +#define FL_SEP1 5 +#define FI_HINTNOTTRUST 6 +#define FL_SEP2 7 +#define FI_ISSTOLABEL 8 +#define FI_ISSTO 9 +#define FI_ISSBYLABEL 10 +#define FI_ISSBY 11 +#define FI_VALFROMLABEL 12 +#define FI_VALFROM 13 +#define FI_VALTOLABEL 14 +#define FI_VALTO 15 +#define IMG_KEY 16 +#define FI_CORRPRIVKEY 17 + +#define IMG1_WIDTH 33 +#define IMG1_HEIGHT 22 +#define IMG2_WIDTH 20 +#define IMG2_HEIGHT 20 +#define DATE_WIDTH 30 +#define CW_COL_0 (CV_COL_0+RSC_SP_GRP_INNERBORDER_LEFT) +#define CW_COL_1 (CW_COL_0+RSC_SP_FLGR_SPACE_X) +#define CW_COL_1a (CW_COL_0+IMG2_WIDTH+1) +#define CW_COL_2 (CW_COL_0+IMG1_WIDTH) +#define CW_COL_3 (CW_COL_2+RSC_SP_CTRL_GROUP_X) +#define CW_COL_4 (CW_COL_1+40) +#define CW_COL_5 (CV_CONT_WIDTH-RSC_SP_GRP_INNERBORDER_RIGHT) +#define CW_COL_5a (CW_COL_5-RSC_SP_GRP_INNERBORDER_RIGHT) +#define CW_COL_4a (CW_COL_1+38) +#define CW_COL_4b (CW_COL_4a+DATE_WIDTH) +#define CW_COL_4c (CW_COL_4b+3) +#define CW_COL_4d (CW_COL_4c+8) +#define CW_COL_4e (CW_COL_4d+3) +#define CW_ROW_0 (CV_ROW_0+RSC_SP_GRP_INNERBORDER_TOP) +#define CW_ROW_1 (CW_ROW_0+RSC_SP_GRP_INNERBORDER_TOP) +#define CW_ROW_2 (CW_ROW_0+IMG1_HEIGHT) +#define CW_ROW_3 (CW_ROW_2+3) +#define CW_ROW_4 (CW_ROW_3+RSC_SP_CTRL_Y+RSC_CD_FIXEDLINE_HEIGHT) +#define CW_ROW_4a (CW_ROW_4+35) +#define CW_ROW_5 (CW_ROW_4a+3) +#define CW_ROW_6 (CW_ROW_5+RSC_SP_CTRL_Y+RSC_CD_FIXEDLINE_HEIGHT) +#define CW_ROW_7 (CW_ROW_6+RSC_SP_CTRL_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CW_ROW_8 (CW_ROW_7+RSC_SP_CTRL_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CW_ROW_9 (CW_ROW_8+RSC_SP_CTRL_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CW_ROW_10 (CW_ROW_9+2) +#define CW_ROW_11 (CW_ROW_9+IMG2_HEIGHT) + +// --------- tab page Certificate viewer - Details --------- + +#define LB_ELEMENTS 1 +#define ML_ELEMENT 2 + +#define STR_VERSION 1 +#define STR_SERIALNUM 2 +#define STR_SIGALGORITHM 3 +#define STR_ISSUER 4 +#define STR_VALIDFROM 5 +#define STR_VALIDTO 6 +#define STR_SUBJECT 7 +#define STR_PUBKEY 8 + +// --------- tab page Certificate viewer - Certification Path --------- + +#define FT_CERTPATH 1 +#define FT_CERTSTATUS 2 +#define ML_CERTSTATUS 3 + +#define CV_ROW_0A (CV_ROW_0+RSC_SP_CTRL_DESC_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CV_ROW_2A (CV_ROW_2+RSC_SP_CTRL_DESC_Y+RSC_CD_FIXEDTEXT_HEIGHT) + +#endif diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx new file mode 100644 index 000000000000..65650a5645ea --- /dev/null +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -0,0 +1,545 @@ +/************************************************************************* + * + * $RCSfile: digitalsignaturesdialog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <xmlsecurity/digitalsignaturesdialog.hxx> +#include <xmlsecurity/certificatechooser.hxx> +#include <xmlsecurity/certificateviewer.hxx> + +#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ +#include <com/sun/star/embed/XStorage.hpp> +#endif +#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_ +#include <com/sun/star/embed/ElementModes.hpp> +#endif +#include <com/sun/star/embed/XTransactedObject.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +// Only needed until sig is in storage: +#include <unotools/streamhelper.hxx> + +/*- + * deleted by AF. base64.h is a mozilla nss file, this file should not depend + * on nss/nspr. + */ +//#include <external/base64.h> + +#if OSL_DEBUG_LEVEL > 1 +#include <vcl/msgbox.hxx> +#endif + +#include <tools/intn.hxx> + +#include "dialogs.hrc" +#include "resourcemanager.hxx" + +// MM : added for password exception +#include <com/sun/star/security/NoPasswordException.hpp> +using namespace ::com::sun::star::security; + +/* HACK: disable some warnings for MS-C */ +#ifdef _MSC_VER +#pragma warning (disable : 4355) // 4355: this used in initializer-list +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star; + +DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Reference< lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode ) + :ModalDialog ( pParent, XMLSEC_RES( RID_XMLSECDLG_DIGSIG ) ) + ,maSignatureHelper ( rxMSF ) + ,meSignatureMode ( eMode ) + ,maHintDocFT ( this, ResId( FT_HINT_DOC ) ) + ,maHintBasicFT ( this, ResId( FT_HINT_BASIC ) ) + ,maHintPackageFT ( this, ResId( FT_HINT_PACK ) ) + ,maSignaturesLB ( this, ResId( LB_SIGNATURES ) ) + ,maViewBtn ( this, ResId( BTN_VIEWCERT ) ) + ,maAddBtn ( this, ResId( BTN_ADDCERT ) ) + ,maRemoveBtn ( this, ResId( BTN_REMOVECERT ) ) + ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP ) ) + ,maOKBtn ( this, ResId( BTN_OK ) ) + ,maCancelBtn ( this, ResId( BTN_CANCEL ) ) + ,maHelpBtn ( this, ResId( BTN_HELP ) ) +{ + static long nTabs[] = { 3, 0, 32*DS_LB_WIDTH/100, 64*DS_LB_WIDTH/100 }; + maSignaturesLB.SetTabs( &nTabs[ 0 ] ); + maSignaturesLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) ); + + FreeResource(); + mbVerifySignatures = true; + + maSignaturesLB.SetSelectHdl( LINK( this, DigitalSignaturesDialog, SignatureHighlightHdl ) ); + maSignaturesLB.SetDoubleClickHdl( LINK( this, DigitalSignaturesDialog, SignatureSelectHdl ) ); + + maViewBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, ViewButtonHdl ) ); + maViewBtn.Disable(); + + maAddBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, AddButtonHdl ) ); + + maRemoveBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, RemoveButtonHdl ) ); + maRemoveBtn.Disable(); + + switch( meSignatureMode ) + { + case SignatureModeDocumentContent: maHintDocFT.Show(); break; + case SignatureModeMacros: maHintBasicFT.Show(); break; + case SignatureModePackage: maHintPackageFT.Show(); break; + } +} + +DigitalSignaturesDialog::~DigitalSignaturesDialog() +{ +} + +BOOL DigitalSignaturesDialog::Init( const rtl::OUString& rTokenName ) +{ + bool bInit = maSignatureHelper.Init( rTokenName ); + + DBG_ASSERT( bInit, "Error initializing security context!" ); + + if ( bInit ) + { + maSignatureHelper.SetStartVerifySignatureHdl( LINK( this, DigitalSignaturesDialog, StartVerifySignatureHdl ) ); + } + + return bInit; +} + +void DigitalSignaturesDialog::SetStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStore ) +{ + mxStore = rxStore; + maSignatureHelper.SetStorage( mxStore ); +} + + + +short DigitalSignaturesDialog::Execute() +{ + // Verify Signatures and add certificates to ListBox... + mbVerifySignatures = true; + ImplGetSignatureInformations(); + ImplFillSignaturesBox(); + + // Only verify once, content will not change. + // But for refreshing signature information, StartVerifySignatureHdl will be called after each add/remove + mbVerifySignatures = false; + + short nRet = Dialog::Execute(); + + return nRet; +} + +IMPL_LINK( DigitalSignaturesDialog, SignatureHighlightHdl, void*, EMPTYARG ) +{ + bool bSel = maSignaturesLB.FirstSelected() != 0; + maViewBtn.Enable( bSel ); + maRemoveBtn.Enable( bSel ); + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, SignatureSelectHdl, void*, EMPTYARG ) +{ + ImplShowSignaturesDetails(); + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, ViewButtonHdl, Button*, EMPTYARG ) +{ + ImplShowSignaturesDetails(); + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG ) +{ + try + { + // Check if we have the password for the key store. + // If no, we don't want to raise an empty dialog. + maSignatureHelper.GetSecurityEnvironment()->getPersonalCertificates(); + + uno::Reference<com::sun::star::xml::crypto::XSecurityEnvironment> xSecEnv = maSignatureHelper.GetSecurityEnvironment(); + CertificateChooser aChooser( (Window*)this, xSecEnv, aCurrentSignatureInformations ); + if( aChooser.Execute() ) + { + maSignatureHelper.StartMission(); + + sal_Int32 nSecurityId = maSignatureHelper.GetNewSecurityId(); + uno::Reference< ::com::sun::star::security::XCertificate > xCert = aChooser.GetSelectedCertificate(); + maSignatureHelper.SetX509Certificate( nSecurityId, xCert->getIssuerName(), bigIntegerToNumericString( xCert->getSerialNumber() ) ); + + std::vector< rtl::OUString > aElements = CreateElementList( mxStore, rtl::OUString(), meSignatureMode ); + + ::rtl::OUString aXMLExt( RTL_CONSTASCII_USTRINGPARAM( "XML" ) ); + sal_Int32 nElements = aElements.size(); + for ( sal_Int32 n = 0; n < nElements; n++ ) + { + bool bBinaryMode = true; + sal_Int32 nSep = aElements[n].lastIndexOf( '.' ); + if ( nSep != (-1) ) + { + ::rtl::OUString aExt = aElements[n].copy( nSep+1 ); + if ( aExt.equalsIgnoreAsciiCase( aXMLExt ) ) + bBinaryMode = false; + } + maSignatureHelper.AddForSigning( nSecurityId, aElements[n], aElements[n], bBinaryMode ); + } + + bool bDone = false; + bool bRefreshInformations = false; + + if ( !maSigFileName.getLength() ) + { + ::rtl::OUString aSIGStreamName( RTL_CONSTASCII_USTRINGPARAM( "SIGNATURES" ) ); + uno::Reference < io::XStream > xStream = mxStore->openStreamElement( aSIGStreamName, embed::ElementModes::WRITE ); + uno::Reference< io::XOutputStream > xOutputStream( xStream, uno::UNO_QUERY ); + // CHANGE TO KEEP OLD SIGS WHEN SIG IN STREAM WORKS! + //bDone = maSignatureHelper.CreateAndWriteSignatue( xOutputStream ); + + uno::Reference< com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + // Export old signatures... + int nInfos = aCurrentSignatureInformations.size(); + for ( int n = 0; n < nInfos; n++ ) + maSignatureHelper.ExportSignature( xDocumentHandler, aCurrentSignatureInformations[n]); + + // Create a new one... + bDone = maSignatureHelper.CreateAndWriteSignatue( xDocumentHandler ); + + // That's it... + maSignatureHelper.CloseDocumentHandler( xDocumentHandler); + + uno::Reference< embed::XTransactedObject > xTrans( mxStore, uno::UNO_QUERY ); + xTrans->commit(); + uno::Reference< lang::XComponent > xComp( mxStore, uno::UNO_QUERY ); + xComp->dispose(); + } + else + { + SvFileStream* pStream = new SvFileStream( maSigFileName, STREAM_WRITE|STREAM_TRUNC ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + uno::Reference< com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + // Export old signatures... + int nInfos = aCurrentSignatureInformations.size(); + for ( int n = 0; n < nInfos; n++ ) + maSignatureHelper.ExportSignature( xDocumentHandler, aCurrentSignatureInformations[n]); + + // Create a new one... + bDone = maSignatureHelper.CreateAndWriteSignatue( xDocumentHandler ); + + // That's it... + maSignatureHelper.CloseDocumentHandler( xDocumentHandler); + } + + maSignatureHelper.EndMission(); + + if ( bDone ) + { + // Can't simply remember current information, need parsing for getting full information :( + ImplGetSignatureInformations(); + ImplFillSignaturesBox(); + } + + } + } + catch (NoPasswordException&) + { + } + + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, RemoveButtonHdl, Button*, EMPTYARG ) +{ + if( maSignaturesLB.FirstSelected() ) + { + USHORT nSelected = (USHORT) maSignaturesLB.FirstSelected()->GetUserData(); + aCurrentSignatureInformations.erase( aCurrentSignatureInformations.begin()+nSelected ); + + // Export all other signatures... + if ( !maSigFileName.getLength() ) + { + // See AddButtonHdl, later.... + } + else + { + SvFileStream* pStream = new SvFileStream( maSigFileName, STREAM_WRITE|STREAM_TRUNC ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + uno::Reference< css::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + + int nInfos = aCurrentSignatureInformations.size(); + for( int n = 0 ; n < nInfos ; ++n ) + maSignatureHelper.ExportSignature( xDocumentHandler, aCurrentSignatureInformations[ n ] ); + + // That's it... + maSignatureHelper.CloseDocumentHandler( xDocumentHandler ); + } + + ImplFillSignaturesBox(); + } + + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, StartVerifySignatureHdl, void*, EMPTYARG ) +{ + return mbVerifySignatures ? 1 : 0; +} + +void DigitalSignaturesDialog::ImplFillSignaturesBox() +{ + maSignaturesLB.Clear(); + + uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecEnv = maSignatureHelper.GetSecurityEnvironment(); + uno::Reference< ::com::sun::star::security::XCertificate > xCert; + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + int nInfos = aCurrentSignatureInformations.size(); + for( int n = 0; n < nInfos; ++n ) + { + const SignatureInformation& rInfo = aCurrentSignatureInformations[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() ); + } + else + { +#if OSL_DEBUG_LEVEL > 1 + aSubject = String::CreateFromAscii( "ERROR getting certificate!" ); +#endif + } + SvLBoxEntry* pEntry = maSignaturesLB.InsertEntry( aSubject ); + maSignaturesLB.SetEntryText( aIssuer, pEntry, 1 ); + maSignaturesLB.SetEntryText( aDateTimeStr, pEntry, 2 ); + pEntry->SetUserData( ( void* ) n ); // missuse user data as index + } + +// maViewBtn.Disable(); + SignatureHighlightHdl( NULL ); +} + +void DigitalSignaturesDialog::ImplGetSignatureInformations() +{ + aCurrentSignatureInformations.clear(); + + maSignatureHelper.StartMission(); + + bool bVerifyOK = false; + + if ( maSigFileName.getLength() ) + { + SvFileStream* pStream = new SvFileStream( maSigFileName, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + ULONG nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + if ( nBytes ) + { + uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + bVerifyOK = maSignatureHelper.ReadAndVerifySignatue( xInputStream ); + xInputStream->closeInput(); + } + } + else + { + ::rtl::OUString aSIGStreamName( RTL_CONSTASCII_USTRINGPARAM( "SIGNATURE" ) ); + if ( mxStore->isStreamElement( aSIGStreamName ) ) + { + uno::Reference < io::XStream > xStream = mxStore->openStreamElement( aSIGStreamName, embed::ElementModes::READ ); + uno::Reference< io::XInputStream > xInputStream( xStream, uno::UNO_QUERY ); + bVerifyOK = maSignatureHelper.ReadAndVerifySignatue( xInputStream ); + } + } + + if ( bVerifyOK ) + aCurrentSignatureInformations = maSignatureHelper.GetSignatureInformations(); + + maSignatureHelper.EndMission(); + + mbVerifySignatures = false; +} + +void DigitalSignaturesDialog::ImplShowSignaturesDetails() +{ + if( maSignaturesLB.FirstSelected() ) + { + USHORT nSelected = (USHORT) maSignaturesLB.FirstSelected()->GetUserData(); + const SignatureInformation& rInfo = aCurrentSignatureInformations[ nSelected ]; + uno::Reference< dcss::security::XCertificate > xCert = maSignatureHelper.GetSecurityEnvironment()->getCertificate( rInfo.ouX509IssuerName, numericStringToBigInteger( rInfo.ouX509SerialNumber ) ); + + // If we don't get it, create it from signature data: + if ( !xCert.is() ) + xCert = maSignatureHelper.GetSecurityEnvironment()->createCertificateFromAscii( rInfo.ouX509Certificate ) ; + + DBG_ASSERT( xCert.is(), "Certificate not found and can't be created!" ); + + uno::Reference<com::sun::star::xml::crypto::XSecurityEnvironment> xSecEnv = maSignatureHelper.GetSecurityEnvironment(); + CertificateViewer aViewer( this, xSecEnv, xCert ); + aViewer.Execute(); + } +} + +void ImplFillElementList( std::vector< rtl::OUString >& rList, uno::Reference < embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, bool bRecursive ) +{ + ::rtl::OUString aMetaInfName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ); + ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); + + uno::Reference < container::XNameAccess > xElements( rxStore, uno::UNO_QUERY ); + uno::Sequence< ::rtl::OUString > aElements = xElements->getElementNames(); + sal_Int32 nElements = aElements.getLength(); + const ::rtl::OUString* pNames = aElements.getConstArray(); + for ( sal_Int32 n = 0; n < nElements; n++ ) + { + if ( pNames[n] != aMetaInfName ) + { + if ( rxStore->isStreamElement( pNames[n] ) ) + { + ::rtl::OUString aFullName( rRootStorageName + pNames[n] ); + rList.push_back( aFullName ); + } + else if ( bRecursive && rxStore->isStorageElement( pNames[n] ) ) + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( pNames[n], embed::ElementModes::READ ); + rtl::OUString aFullRootName( rRootStorageName + pNames[n] + aSep ); + ImplFillElementList( rList, rxStore, aFullRootName, bRecursive ); + } + } + } +} + +std::vector< rtl::OUString > DigitalSignaturesDialog::CreateElementList( uno::Reference < embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, DocumentSignatureMode eMode ) +{ + std::vector< rtl::OUString > aElements; + ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); + + + switch ( eMode ) + { + case SignatureModeDocumentContent: + { + // 1) Main content + ImplFillElementList( aElements, rxStore, ::rtl::OUString(), false ); + + // 2) Pictures... + rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Pictures" ) ); + try + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, embed::ElementModes::READ ); + ImplFillElementList( aElements, xSubStore, aSubStorageName+aSep, true ); + } + catch( com::sun::star::io::IOException& ) + { + ; // Doesn't have to exist... + } + } + break; + case SignatureModeMacros: + { + // 1) Macros + rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Basic" ) ); + try + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, embed::ElementModes::READ ); + ImplFillElementList( aElements, xSubStore, aSubStorageName+aSep, true ); + } + catch( com::sun::star::io::IOException& ) + { + ; // Doesn't have to exist... + } + + // 2) Dialogs + aSubStorageName = rtl::OUString::createFromAscii( "Dialogs") ; + try + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, embed::ElementModes::READ ); + ImplFillElementList( aElements, xSubStore, aSubStorageName+aSep, true ); + } + catch( com::sun::star::io::IOException& ) + { + ; // Doesn't have to exist... + } + } + break; + case SignatureModePackage: + { + // Everything except META-INF + ImplFillElementList( aElements, rxStore, ::rtl::OUString(), true ); + } + break; + } + + return aElements; +} diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.src b/xmlsecurity/source/dialogs/digitalsignaturesdialog.src new file mode 100644 index 000000000000..8ea04dc9e2fd --- /dev/null +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.src @@ -0,0 +1,159 @@ +/************************************************************************* + * + * $RCSfile: digitalsignaturesdialog.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "dialogs.hrc" + +ModalDialog RID_XMLSECDLG_DIGSIG +{ +// HelpId = HID_XMLSECDLG_DIGSIG; + Size = MAP_APPFONT( DS_WIDTH, DS_HEIGHT ); + OutputSize = TRUE; + Closeable = TRUE; + Moveable = TRUE; + SVLook = TRUE; + +// Text = "Digital Signatures"; + Text = "Digital Signatures"; + Text [ en-US ] = "Digital Signatures"; + + FixedText FT_HINT_DOC + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_0 ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "The following have signed the document content"; + Text [ en-US ] = "The following have signed the document content"; + }; + FixedText FT_HINT_BASIC + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_0 ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "The following have signed the document macro"; + Text [ en-US ] = "The following have signed the document macro"; + }; + FixedText FT_HINT_PACK + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_0 ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "The following have signed this package"; + Text [ en-US ] = "The following have signed this package"; + }; +// ListBox LB_SIGNATURES + Control LB_SIGNATURES + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_1 ); + Size = MAP_APPFONT( DS_LB_WIDTH, DS_ROW_2-DS_ROW_1 ); + SVLook = TRUE; + Border = TRUE; + }; + String STR_HEADERBAR + { + Text = "Signer\tDigital ID Issued by\tDate"; + Text [ en-US ] = "Signer\tDigital ID Issued by\tDate"; + }; + PushButton BTN_VIEWCERT + { + Pos = MAP_APPFONT( DS_COL_1, DS_ROW_3 ); + Size = MAP_APPFONT( DS_COL_2-DS_COL_1, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Zertifikat anzeigen..."; + Text = "View Certificate..."; + Text [ en-US ] = "View Certificate..."; + }; + PushButton BTN_ADDCERT + { + Pos = MAP_APPFONT( DS_COL_3, DS_ROW_3 ); + Size = MAP_APPFONT( DS_COL_4-DS_COL_3, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Hinzufgen..."; + Text = "Add..."; + Text [ en-US ] = "Add..."; + }; + PushButton BTN_REMOVECERT + { + Pos = MAP_APPFONT( DS_COL_5, DS_ROW_3 ); + Size = MAP_APPFONT( DS_COL_6-DS_COL_5, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Entfernen"; + Text = "Remove"; + Text [ en-US ] = "Remove"; + }; + FixedLine FL_BOTTOM_SEP + { + Pos = MAP_APPFONT( 0, DLGS_BOTTOM_FL_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( DS_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ); + }; + OKButton BTN_OK + { + DefButton = TRUE; + Pos = MAP_APPFONT( DLGS_BOTTOM_OK_X( DS_WIDTH ), DLGS_BOTTOM_BTN_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT( DLGS_BOTTOM_CANCEL_X( DS_WIDTH ), DLGS_BOTTOM_BTN_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT( DLGS_BOTTOM_HELP_X( DS_WIDTH ), DLGS_BOTTOM_BTN_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; +}; diff --git a/xmlsecurity/source/dialogs/makefile.mk b/xmlsecurity/source/dialogs/makefile.mk new file mode 100644 index 000000000000..bf12824c8e0a --- /dev/null +++ b/xmlsecurity/source/dialogs/makefile.mk @@ -0,0 +1,100 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=xmlsecurity +TARGET=dialogs +TARGETTYPE=GUI + + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + + +# --- Files -------------------------------------------------------- + +BMP_IN=$(PRJ)$/res + +SRS1NAME=dialogs +SRC1FILES = \ + digitalsignaturesdialog.src \ + certificatechooser.src \ + certificateviewer.src + +SLOFILES= \ + $(SLO)$/stbcontrl.obj \ + $(SLO)$/digitalsignaturesdialog.obj \ + $(SLO)$/certificatechooser.obj \ + $(SLO)$/certificateviewer.obj \ + $(SLO)$/resourcemanager.obj + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/xmlsecurity/source/dialogs/resourcemanager.cxx b/xmlsecurity/source/dialogs/resourcemanager.cxx new file mode 100644 index 000000000000..aa19d487bc3b --- /dev/null +++ b/xmlsecurity/source/dialogs/resourcemanager.cxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * $RCSfile: resourcemanager.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "resourcemanager.hxx" + +#include <vcl/svapp.hxx> +#include <svtools/solar.hrc> + + +namespace XmlSec +{ + static ResMgr* pResMgr = 0; + static International* pInternational = 0; + + ResMgr* GetResMgr( void ) + { + if( !pResMgr ) + { + ByteString aName( "xmlsec" ); + aName += ByteString::CreateFromInt32( SOLARUPD ); +// pResMgr = ResMgr::CreateResMgr( aName.GetBuffer(), Application::GetSettings().GetUILanguage() ); + LanguageType aLang( LANGUAGE_ENGLISH_US ); +// pResMgr = ResMgr::CreateResMgr( aName.GetBuffer(), aLang ); +// MT: Change to Locale + pResMgr = ResMgr::CreateResMgr( aName.GetBuffer()); + } + + return pResMgr; + } + + International* GetInternational( void ) + { + if( !pInternational ) + { + LanguageType aLang( LANGUAGE_ENGLISH_US ); + pInternational = new International( aLang ); + } + return pInternational; + } + + DateTime GetDateTime( const ::com::sun::star::util::DateTime& _rDT ) + { + return DateTime( + Date( _rDT.Day, _rDT.Month, _rDT.Year ), + Time( _rDT.Hours, _rDT.Minutes, _rDT.Seconds, _rDT.HundredthSeconds ) ); + } + + String GetDateTimeString( const ::com::sun::star::util::DateTime& _rDT ) + { + return GetInternational()->GetLongDate( GetDateTime( _rDT ) ); + } + + String GetDateString( const ::com::sun::star::util::DateTime& _rDT ) + { + return GetInternational()->GetLongDate( GetDateTime( _rDT ) ); + } + + String GetPureContent( const String& _rRawString, const char* _pCommaReplacement, bool _bPreserveId ) + { + enum STATE { ID, EQUALSIGN, CONT }; + String s; + STATE e = ID; + + const sal_Unicode* p = _rRawString.GetBuffer(); + sal_Unicode c; + const sal_Unicode cComma = ','; + const sal_Unicode cEqualSign = '='; + String aCommaReplacement; + if( _pCommaReplacement ) + aCommaReplacement = String::CreateFromAscii( _pCommaReplacement ); + + while( *p ) + { + c = *p; + switch( e ) + { + case ID: + if( _bPreserveId ) + s += c; + + if( c == cEqualSign ) + e = CONT; + break; +// case EQUALSIGN: +// break; + case CONT: + if( c == cComma ) + { + s += aCommaReplacement; + e = ID; + } + else + s += c; + break; + } + + ++p; + } + +// xub_StrLen nEquPos = _rRawString.SearchAscii( "=" ); +// if( nEquPos == STRING_NOTFOUND ) +// s = _rRawString; +// else +// { +// ++nEquPos; +// s = String( _rRawString, nEquPos, STRING_MAXLEN ); +// s.EraseLeadingAndTrailingChars(); +// } + + return s; + } + + String GetContentPart( const String& _rRawString, const String& _rPartId ) + { + String s; + + xub_StrLen nContStart = _rRawString.Search( _rPartId ); + if( nContStart != STRING_NOTFOUND ) + { + nContStart += _rPartId.Len(); + ++nContStart; // now it's start of content, directly after Id + + xub_StrLen nContEnd = _rRawString.Search( sal_Unicode( ',' ), nContStart ); + + s = String( _rRawString, nContStart, nContEnd - nContStart ); + } + + return s; + } +} + + diff --git a/xmlsecurity/source/dialogs/resourcemanager.hxx b/xmlsecurity/source/dialogs/resourcemanager.hxx new file mode 100644 index 000000000000..3b215dfbe7bb --- /dev/null +++ b/xmlsecurity/source/dialogs/resourcemanager.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: resourcemanager.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RESOURCEMANAGER_HXX +#define _RESOURCEMANAGER_HXX + +#ifndef _TOOLS_RESMGR_HXX +#include <tools/resmgr.hxx> +#endif +#ifndef _TOOLS_INTN_HXX +#include <tools/intn.hxx> +#endif +#ifndef _DATETIME_HXX +#include <tools/datetime.hxx> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif + + +namespace XmlSec +{ + ResMgr* GetResMgr( void ); + + International* GetInternational( void ); + DateTime GetDateTime( const ::com::sun::star::util::DateTime& _rDT ); + String GetDateTimeString( const ::com::sun::star::util::DateTime& _rDT ); + String GetDateString( const ::com::sun::star::util::DateTime& _rDT ); + + String GetPureContent( const String& _rRawString, + const char* _pCommaReplacement = ", ", + bool _bPreserveId = false ); // strips "CN=" and so from string + String GetContentPart( const String& _rRawString, const String& _rPartId ); +} + +#define XMLSEC_RES(id) ResId(id,XmlSec::GetResMgr()) + +#endif diff --git a/xmlsecurity/source/dialogs/stbcontrl.cxx b/xmlsecurity/source/dialogs/stbcontrl.cxx new file mode 100644 index 000000000000..a4d92885b424 --- /dev/null +++ b/xmlsecurity/source/dialogs/stbcontrl.cxx @@ -0,0 +1,232 @@ +/************************************************************************* + * + * $RCSfile: stbcontrl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#ifndef _SHL_HXX //autogen +#include <tools/shl.hxx> +#endif +#ifndef _STATUS_HXX //autogen +#include <vcl/status.hxx> +#endif +#ifndef _MENU_HXX //autogen +#include <vcl/menu.hxx> +#endif +#ifndef _SV_IMAGE_HXX +#include <vcl/image.hxx> +#endif +//#ifndef _SFXITEMPOOL_HXX +//#include <svtools/itempool.hxx> +//#endif +#ifndef _SFXAPP_HXX +#include <sfx2/app.hxx> +#endif +#ifndef _SFXMODULE_HXX +#include <sfx2/module.hxx> +#endif +#ifndef _SFXDISPATCH_HXX //autogen +#include <sfx2/dispatch.hxx> +#endif +#ifndef _SFX_OBJSH_HXX //autogen +#include <sfx2/objsh.hxx> +#endif + +#include <svtools/eitem.hxx> + + +#include <xmlsecurity/stbcontrl.hxx> + +#define PAINT_OFFSET 5 + +//#include "sizeitem.hxx" +//#include "dialmgr.hxx" +//#include "dlgutil.hxx" +//#include "stbctrls.h" + +//#include "dialogs.hrc" + +/*#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX +#include <unotools/localedatawrapper.hxx> +#endif +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX +#include <comphelper/processfactory.hxx> +#endif*/ + + + +SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxBoolItem ); + +/* +class FunctionPopup_Impl : public PopupMenu +{ +public: + FunctionPopup_Impl( USHORT nCheck ); + + USHORT GetSelected() const { return nSelected; } + +private: + USHORT nSelected; + + virtual void Select(); +}; + +// ----------------------------------------------------------------------- + +FunctionPopup_Impl::FunctionPopup_Impl( USHORT nCheck ) : + PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ), + nSelected( 0 ) +{ + if (nCheck) + CheckItem( nCheck ); +} + +// ----------------------------------------------------------------------- + +void FunctionPopup_Impl::Select() +{ + nSelected = GetCurItemId(); +} +*/ + + + +struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl +{ + Point maPos; + Size maSize; + bool mbSigned; + Image maImage; +}; + + +XmlSecStatusBarControl::XmlSecStatusBarControl( USHORT _nId, StatusBar& _rStb, SfxBindings& _rBind ) + :SfxStatusBarControl( _nId, _rStb, _rBind ) + + ,mpImpl( new XmlSecStatusBarControl_Impl ) +{ + mpImpl->mbSigned = false; +// pImp->maImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) ); +} + +XmlSecStatusBarControl::~XmlSecStatusBarControl() +{ + delete mpImpl; +} + +void XmlSecStatusBarControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + GetStatusBar().SetHelpText( GetId(), String() ); // necessary ? + GetStatusBar().SetHelpId( GetId(), nSID ); // necessary ? + + if( SFX_ITEM_AVAILABLE != eState ) + { + mpImpl->mbSigned = false; + } + else if( pState->ISA( SfxBoolItem ) ) + { + mpImpl->mbSigned = ( ( SfxBoolItem* ) pState )->GetValue(); + } + else + { + DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" ); + mpImpl->mbSigned = false; + } + + if( GetStatusBar().AreItemsVisible() ) // necessary ? + GetStatusBar().SetItemData( GetId(), 0 ); + + GetStatusBar().SetItemText( GetId(), String() ); // necessary ? +} + +void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt ) +{ + // can / has to be done when integrated in Office! +// if( rCEvt.GetCommand() == .... ) + if( false ) + { +// GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L ); + } + else + SfxStatusBarControl::Command( rCEvt ); +} + +void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) +{ + OutputDevice* pDev = rUsrEvt.GetDevice(); + DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." ); + const Rectangle& rRect = rUsrEvt.GetRect(); + StatusBar& rBar = GetStatusBar(); + Point aItemPos = rBar.GetItemTextPos( GetId() ); + Color aOldLineColor = pDev->GetLineColor(); + Color aOldFillColor = pDev->GetFillColor(); + + // just 4 testing until we've got a bitmap + pDev->SetLineColor(); + pDev->SetFillColor( pDev->GetBackground().GetColor() ); + + String s( String::CreateFromAscii( mpImpl->mbSigned? "X" : "-" ) ); + pDev->DrawRect( rRect ); + pDev->DrawText( Point( rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( s ) / 2, aItemPos.Y() ), s ); + + pDev->SetLineColor( aOldLineColor ); + pDev->SetFillColor( aOldFillColor ); +} + |