update dev300-m58
[ooovba.git] / xmlsecurity / workben / signaturetest.cxx
blobac38f29acc158ef06a9da846b3b8d996a464041b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: signaturetest.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
34 #include <sal/main.h>
35 #include <vcl/event.hxx>
36 #include <vcl/svapp.hxx>
37 #include <vcl/wrkwin.hxx>
38 #include <vcl/msgbox.hxx>
39 #include <vcl/fixed.hxx>
40 #include <vcl/edit.hxx>
41 #include <vcl/button.hxx>
42 #include <vcl/lstbox.hxx>
43 #include <svtools/filectrl.hxx>
44 #include <tools/urlobj.hxx>
45 #include <osl/file.hxx>
47 #include <svtools/docpasswdrequest.hxx>
49 #include <comphelper/processfactory.hxx>
50 #include <cppuhelper/servicefactory.hxx>
51 #include <cppuhelper/bootstrap.hxx>
52 #include <unotools/streamhelper.hxx>
54 #include <ucbhelper/contentbroker.hxx>
55 #include <ucbhelper/configurationkeys.hxx>
57 // Will be in comphelper if CWS MAV09 is integrated
58 #include <comphelper/storagehelper.hxx>
60 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
62 #include <xmlsecurity/xmlsignaturehelper.hxx>
63 #include <xmlsecurity/digitalsignaturesdialog.hxx>
64 #include <xmlsecurity/certificatechooser.hxx>
65 #include <xmlsecurity/biginteger.hxx>
67 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
69 using namespace ::com::sun::star;
70 using namespace ::com::sun::star;
72 void Main();
74 #define TEXTFIELDWIDTH 80
75 #define TEXTFIELDSTARTX 10
77 #define EDITWIDTH 200
78 #define EDITHEIGHT 20
80 #define FIXEDLINEHEIGHT 15
82 #define BUTTONWIDTH 50
83 #define BUTTONHEIGHT 22
84 #define BUTTONSPACE 20
86 #define LISTBOXHEIGHT 120
88 // #define TEST_IMPLEMENTATION_DIRECTLY
91 // -----------------------------------------------------------------------
93 SAL_IMPLEMENT_MAIN()
95 uno::Reference< lang::XMultiServiceFactory > xMSF;
96 try
98 uno::Reference< uno::XComponentContext > xCtx( cppu::defaultBootstrap_InitialComponentContext() );
99 if ( !xCtx.is() )
101 DBG_ERROR( "Error creating initial component context!" );
102 return -1;
105 xMSF = uno::Reference< lang::XMultiServiceFactory >(xCtx->getServiceManager(), uno::UNO_QUERY );
107 if ( !xMSF.is() )
109 DBG_ERROR( "No service manager!" );
110 return -1;
113 // Init USB
114 uno::Sequence< uno::Any > aArgs( 2 );
115 aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL );
116 aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE );
117 sal_Bool bSuccess = ::ucb::ContentBroker::initialize( xMSF, aArgs );
118 if ( !bSuccess )
120 DBG_ERROR( "Error creating UCB!" );
121 return -1;
125 catch ( uno::Exception const & )
127 DBG_ERROR( "Exception during creation of initial component context!" );
128 return -1;
130 comphelper::setProcessServiceFactory( xMSF );
132 InitVCL( xMSF );
133 ::Main();
134 DeInitVCL();
136 return 0;
139 // -----------------------------------------------------------------------
141 class MyWin : public WorkWindow
143 private:
144 FixedLine maTokenLine;
145 CheckBox maCryptoCheckBox;
146 FixedText maFixedTextTokenName;
147 FileControl maEditTokenName;
148 FixedLine maTest1Line;
149 FixedText maFixedTextXMLFileName;
150 FileControl maEditXMLFileName;
151 FixedText maFixedTextBINFileName;
152 FileControl maEditBINFileName;
153 FixedText maFixedTextSIGFileName;
154 FileControl maEditSIGFileName;
155 PushButton maSignButton;
156 PushButton maVerifyButton;
157 FixedLine maTest2Line;
158 FixedText maFixedTextDOCFileName;
159 FileControl maEditDOCFileName;
160 PushButton maDigitalSignaturesButton;
161 PushButton maVerifyDigitalSignaturesButton;
162 FixedLine maHintLine;
163 FixedText maHintText;
165 DECL_LINK( CryptoCheckBoxHdl, CheckBox* );
166 DECL_LINK( SignButtonHdl, Button* );
167 DECL_LINK( VerifyButtonHdl, Button* );
168 DECL_LINK( DigitalSignaturesWithServiceHdl, Button* );
169 DECL_LINK( VerifyDigitalSignaturesHdl, Button* );
170 DECL_LINK( DigitalSignaturesWithTokenHdl, Button* );
171 DECL_LINK( StartVerifySignatureHdl, void* );
173 public:
174 MyWin( Window* pParent, WinBits nWinStyle );
178 // -----------------------------------------------------------------------
180 void Main()
182 MyWin aMainWin( NULL, WB_APP | WB_STDWORK | WB_3DLOOK);
183 aMainWin.Show();
185 Application::Execute();
188 // -----------------------------------------------------------------------
190 MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
191 WorkWindow( pParent, nWinStyle ),
192 maTokenLine( this ),
193 maTest1Line( this ),
194 maTest2Line( this ),
195 maHintLine( this ),
196 maFixedTextXMLFileName( this ),
197 maEditXMLFileName( this, WB_BORDER ),
198 maFixedTextBINFileName( this ),
199 maEditBINFileName( this, WB_BORDER ),
200 maFixedTextSIGFileName( this ),
201 maEditSIGFileName( this, WB_BORDER ),
202 maFixedTextTokenName( this ),
203 maEditTokenName( this, WB_BORDER ),
204 maFixedTextDOCFileName( this ),
205 maEditDOCFileName( this, WB_BORDER ),
206 maSignButton( this ),
207 maVerifyButton( this ),
208 maDigitalSignaturesButton( this ),
209 maVerifyDigitalSignaturesButton( this ),
210 maHintText( this, WB_WORDBREAK ),
211 maCryptoCheckBox( this )
214 #ifdef TEST_IMPLEMENTATION_DIRECTLY
215 Size aOutputSize( 400, 600 );
216 #else
217 Size aOutputSize( 400, 400 );
218 #endif
219 SetOutputSizePixel( aOutputSize );
220 SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML Signature Test" ) ) );
222 long nY = 15;
224 maTokenLine.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
225 maTokenLine.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Crypto Settings" ) ) );
226 maTokenLine.Show();
228 nY += EDITHEIGHT*3/2;
230 maCryptoCheckBox.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
231 maCryptoCheckBox.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use Default Token (NSS option only)" ) ) );
232 maCryptoCheckBox.Check( TRUE );
233 maEditTokenName.Disable();
234 maFixedTextTokenName.Disable();
235 maCryptoCheckBox.SetClickHdl( LINK( this, MyWin, CryptoCheckBoxHdl ) );
236 maCryptoCheckBox.Show();
238 nY += EDITHEIGHT;
240 maFixedTextTokenName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
241 maFixedTextTokenName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Crypto Token:" ) ) );
242 maFixedTextTokenName.Show();
244 maEditTokenName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
245 maEditTokenName.Show();
247 nY += EDITHEIGHT*3;
249 #ifdef TEST_IMPLEMENTATION_DIRECTLY
251 maTest1Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
252 maTest1Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test simple files" ) ) );
253 maTest1Line.Show();
255 nY += EDITHEIGHT*3/2;
257 maFixedTextXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
258 maFixedTextXMLFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML File:" ) ) );
259 maFixedTextXMLFileName.Show();
261 maEditXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
262 maEditXMLFileName.Show();
264 nY += EDITHEIGHT*3/2;
266 maFixedTextBINFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
267 maFixedTextBINFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Binary File:" ) ) );
268 maFixedTextBINFileName.Show();
270 maEditBINFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
271 maEditBINFileName.Show();
273 nY += EDITHEIGHT*3/2;
275 maFixedTextSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
276 maFixedTextSIGFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Signature File:" ) ) );
277 maFixedTextSIGFileName.Show();
279 maEditSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
280 maEditSIGFileName.Show();
282 nY += EDITHEIGHT*2;
284 maSignButton.SetPosSizePixel( TEXTFIELDSTARTX, nY, BUTTONWIDTH, BUTTONHEIGHT );
285 maSignButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Sign" ) ) );
286 maSignButton.SetClickHdl( LINK( this, MyWin, SignButtonHdl ) );
287 maSignButton.Show();
289 maVerifyButton.SetPosSizePixel( TEXTFIELDSTARTX+BUTTONWIDTH+BUTTONSPACE, nY, BUTTONWIDTH, BUTTONHEIGHT );
290 maVerifyButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Verify" ) ) );
291 maVerifyButton.SetClickHdl( LINK( this, MyWin, VerifyButtonHdl ) );
292 maVerifyButton.Show();
294 nY += EDITHEIGHT*3;
296 #endif // TEST_IMPLEMENTATION_DIRECTLY
298 maTest2Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
299 maTest2Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test Office Document" ) ) );
300 maTest2Line.Show();
302 nY += EDITHEIGHT*3/2;
305 maFixedTextDOCFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
306 maFixedTextDOCFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Office File:" ) ) );
307 maFixedTextDOCFileName.Show();
309 maEditDOCFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
310 maEditDOCFileName.Show();
312 nY += EDITHEIGHT*2;
314 maDigitalSignaturesButton.SetPosSizePixel( TEXTFIELDSTARTX, nY, BUTTONWIDTH*2, BUTTONHEIGHT );
315 maDigitalSignaturesButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Digital Signatures..." ) ) );
316 maDigitalSignaturesButton.SetClickHdl( LINK( this, MyWin, DigitalSignaturesWithServiceHdl ) );
317 maDigitalSignaturesButton.Show();
319 maVerifyDigitalSignaturesButton.SetPosSizePixel( TEXTFIELDSTARTX+BUTTONWIDTH*2+BUTTONSPACE, nY, BUTTONWIDTH*2, BUTTONHEIGHT );
320 maVerifyDigitalSignaturesButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Verify Signatures" ) ) );
321 maVerifyDigitalSignaturesButton.SetClickHdl( LINK( this, MyWin, VerifyDigitalSignaturesHdl ) );
322 maVerifyDigitalSignaturesButton.Show();
324 nY += EDITHEIGHT*2;
326 maHintLine.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
327 maHintLine.Show();
329 nY += EDITHEIGHT*2;
331 maHintText.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, aOutputSize.Height()-nY );
332 maHintText.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Hint: Copy crypto files from xmlsecurity/tools/cryptoken/nss and sample files from xmlsecurity/tools/examples to <temp>/nss.\nThis location will be used from the demo as the default location." ) ) );
333 maHintText.Show();
335 // Help the user with some default values
336 ::rtl::OUString aTempDirURL;
337 ::osl::File::getTempDirURL( aTempDirURL );
338 INetURLObject aURLObj( aTempDirURL );
339 aURLObj.insertName( String( RTL_CONSTASCII_USTRINGPARAM( "nss" ) ), true );
340 ::rtl::OUString aNSSFolder = aURLObj.getFSysPath( INetURLObject::FSYS_DETECT );
341 String aDefaultXMLFileName( aNSSFolder );
342 maEditXMLFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.xml" ) ) );
343 maEditBINFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.gif" ) ) );
344 maEditDOCFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.sxw" ) ) );
345 maEditSIGFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-result.xml" ) ) );
346 maEditTokenName.SetText( aNSSFolder );
348 #ifdef WNT
349 maEditTokenName.SetText( String() );
350 maEditTokenName.Disable();
351 maCryptoCheckBox.Disable();
352 #endif
356 IMPL_LINK( MyWin, CryptoCheckBoxHdl, CheckBox*, EMPTYARG )
358 if ( maCryptoCheckBox.IsChecked() )
360 maEditTokenName.Disable();
361 maFixedTextTokenName.Disable();
363 else
365 maEditTokenName.Enable();
366 maFixedTextTokenName.Enable();
368 return 1;
371 IMPL_LINK( MyWin, DigitalSignaturesWithServiceHdl, Button*, EMPTYARG )
373 rtl::OUString aDocFileName = maEditDOCFileName.GetText();
374 uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
375 aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
377 uno::Reference< security::XDocumentDigitalSignatures > xD(
378 comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
379 if ( xD.is() )
380 xD->signDocumentContent( xStore, NULL );
383 return 0;
386 IMPL_LINK( MyWin, VerifyDigitalSignaturesHdl, Button*, EMPTYARG )
388 rtl::OUString aDocFileName = maEditDOCFileName.GetText();
389 uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
390 aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
392 uno::Reference< security::XDocumentDigitalSignatures > xD(
393 comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
394 if ( xD.is() )
396 uno::Sequence< security::DocumentSignatureInformation > aInfos = xD->verifyDocumentContentSignatures( xStore, NULL );
397 int nInfos = aInfos.getLength();
398 for ( int n = 0; n < nInfos; n++ )
400 security::DocumentSignatureInformation& rInf = aInfos[n];
401 String aText( RTL_CONSTASCII_USTRINGPARAM( "The document is signed by\n\n " ) );
402 aText += String( rInf.Signer->getSubjectName() );
403 aText += String( RTL_CONSTASCII_USTRINGPARAM( "\n\n The signature is " ) );
404 if ( !rInf.SignatureIsValid )
405 aText += String( RTL_CONSTASCII_USTRINGPARAM( "NOT " ) );
406 aText += String( RTL_CONSTASCII_USTRINGPARAM( "valid" ) );
407 InfoBox( this, aText ).Execute();
413 return 0;
417 #ifdef TEST_IMPLEMENTATION_DIRECTLY
419 IMPL_LINK( MyWin, DigitalSignaturesWithTokenHdl, Button*, EMPTYARG )
421 String aDocFileName = maEditDOCFileName.GetText();
422 String aTokenFileName = maEditTokenName.GetText();
424 DigitalSignaturesDialog aSignaturesDialog( this, comphelper::getProcessServiceFactory(), SignatureModeDocumentContent, false );
426 bool bInit = aSignaturesDialog.Init( aTokenFileName );
427 if ( !bInit )
429 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
430 return 0;
433 uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
434 aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
436 aSignaturesDialog.SetStorage( xStore );
438 aSignaturesDialog.Execute();
440 return 0;
443 IMPL_LINK( MyWin, SignButtonHdl, Button*, EMPTYARG )
445 String aXMLFileName = maEditXMLFileName.GetText();
446 String aBINFileName = maEditBINFileName.GetText();
447 String aSIGFileName = maEditSIGFileName.GetText();
449 String aTokenFileName;
450 if ( !maCryptoCheckBox.IsChecked() )
451 aTokenFileName = maEditTokenName.GetText();
453 XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() );
454 bool bInit = aSignatureHelper.Init( aTokenFileName );
456 if ( !bInit )
458 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
459 return 0;
462 uno::Reference< ::com::sun::star::security::XCertificate > xCertToUse;
463 CertificateChooser aChooser( this, aSignatureHelper.GetSecurityEnvironment(), SignatureInformations() );
464 if ( aChooser.Execute() )
465 xCertToUse = aChooser.GetSelectedCertificate();
467 if ( !xCertToUse.is() )
468 return 0;
471 aSignatureHelper.StartMission();
473 sal_Int32 nSecurityId = aSignatureHelper.GetNewSecurityId();
475 aSignatureHelper.SetX509Certificate( nSecurityId, xCertToUse->getIssuerName(), bigIntegerToNumericString( xCertToUse->getSerialNumber() ) );
477 aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False );
478 aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True );
480 SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_WRITE );
481 SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
482 uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes );
483 bool bDone = aSignatureHelper.CreateAndWriteSignature( xOutputStream );
485 aSignatureHelper.EndMission();
487 if ( !bDone )
489 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error creating Signature!" ) ) ).Execute();
491 else
493 rtl::OUString aInfo( String( RTL_CONSTASCII_USTRINGPARAM( "Signature successfully created!\n\n" ) ) );
494 // aInfo += getSignatureInformationmations( aSignatureHelper.getAllSignatureInformation(), aSignatureHelper.GetSecurityEnvironment() );
497 InfoBox( this, aInfo ).Execute();
500 // Check for more detailed results...
502 return 0;
505 IMPL_LINK( MyWin, VerifyButtonHdl, Button*, EMPTYARG )
507 String aXMLFileName = maEditXMLFileName.GetText();
508 String aBINFileName = maEditBINFileName.GetText();
509 String aSIGFileName = maEditSIGFileName.GetText();
511 String aTokenFileName;
512 if ( !maCryptoCheckBox.IsChecked() )
513 aTokenFileName = maEditTokenName.GetText();
515 XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() );
516 bool bInit = aSignatureHelper.Init( aTokenFileName );
518 if ( !bInit )
520 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
521 return 0;
524 aSignatureHelper.SetStartVerifySignatureHdl( LINK( this, MyWin, StartVerifySignatureHdl ) );
526 aSignatureHelper.StartMission();
528 SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_READ );
529 pStream->Seek( STREAM_SEEK_TO_END );
530 ULONG nBytes = pStream->Tell();
531 pStream->Seek( STREAM_SEEK_TO_BEGIN );
532 SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
533 uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes );
534 bool bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream );
535 xInputStream->closeInput();
537 aSignatureHelper.EndMission();
539 if ( !bDone )
540 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error in Signature!" ) ) ).Execute();
541 else
542 InfoBox( this, String( RTL_CONSTASCII_USTRINGPARAM( "Signatures verified without any problems!" ) ) ).Execute();
544 return 0;
547 IMPL_LINK( MyWin, StartVerifySignatureHdl, void*, EMPTYARG )
549 QueryBox aQueryBox( this, WB_YES_NO|WB_DEF_YES, String( RTL_CONSTASCII_USTRINGPARAM( "Found Signature - Verify?" ) ) );
550 return ( aQueryBox.Execute() == RET_YES ) ? 1 : 0;
554 #endif // #ifdef TEST_IMPLEMENTATION_DIRECTLY