merged tag ooo/DEV300_m83
[LibreOffice.git] / xmlsecurity / workben / signaturetest.cxx
blob669d3e6705ea8500e54af9564d1d92994ece7a5c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
31 #include <sal/main.h>
32 #include <vcl/event.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/wrkwin.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <vcl/fixed.hxx>
37 #include <vcl/edit.hxx>
38 #include <vcl/button.hxx>
39 #include <vcl/lstbox.hxx>
40 #include <svtools/filectrl.hxx>
41 #include <tools/urlobj.hxx>
42 #include <osl/file.hxx>
44 #include <svtools/docpasswdrequest.hxx>
46 #include <comphelper/processfactory.hxx>
47 #include <cppuhelper/servicefactory.hxx>
48 #include <cppuhelper/bootstrap.hxx>
49 #include <unotools/streamhelper.hxx>
51 #include <ucbhelper/contentbroker.hxx>
52 #include <ucbhelper/configurationkeys.hxx>
54 // Will be in comphelper if CWS MAV09 is integrated
55 #include <comphelper/storagehelper.hxx>
57 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
59 #include <xmlsecurity/xmlsignaturehelper.hxx>
60 #include <xmlsecurity/digitalsignaturesdialog.hxx>
61 #include <xmlsecurity/certificatechooser.hxx>
62 #include <xmlsecurity/biginteger.hxx>
64 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
66 using namespace ::com::sun::star;
67 using namespace ::com::sun::star;
69 void Main();
71 #define TEXTFIELDWIDTH 80
72 #define TEXTFIELDSTARTX 10
74 #define EDITWIDTH 200
75 #define EDITHEIGHT 20
77 #define FIXEDLINEHEIGHT 15
79 #define BUTTONWIDTH 50
80 #define BUTTONHEIGHT 22
81 #define BUTTONSPACE 20
83 #define LISTBOXHEIGHT 120
85 // #define TEST_IMPLEMENTATION_DIRECTLY
88 // -----------------------------------------------------------------------
90 SAL_IMPLEMENT_MAIN()
92 uno::Reference< lang::XMultiServiceFactory > xMSF;
93 try
95 uno::Reference< uno::XComponentContext > xCtx( cppu::defaultBootstrap_InitialComponentContext() );
96 if ( !xCtx.is() )
98 DBG_ERROR( "Error creating initial component context!" );
99 return -1;
102 xMSF = uno::Reference< lang::XMultiServiceFactory >(xCtx->getServiceManager(), uno::UNO_QUERY );
104 if ( !xMSF.is() )
106 DBG_ERROR( "No service manager!" );
107 return -1;
110 // Init USB
111 uno::Sequence< uno::Any > aArgs( 2 );
112 aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL );
113 aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE );
114 sal_Bool bSuccess = ::ucb::ContentBroker::initialize( xMSF, aArgs );
115 if ( !bSuccess )
117 DBG_ERROR( "Error creating UCB!" );
118 return -1;
122 catch ( uno::Exception const & )
124 DBG_ERROR( "Exception during creation of initial component context!" );
125 return -1;
127 comphelper::setProcessServiceFactory( xMSF );
129 InitVCL( xMSF );
130 ::Main();
131 DeInitVCL();
133 return 0;
136 // -----------------------------------------------------------------------
138 class MyWin : public WorkWindow
140 private:
141 FixedLine maTokenLine;
142 CheckBox maCryptoCheckBox;
143 FixedText maFixedTextTokenName;
144 FileControl maEditTokenName;
145 FixedLine maTest1Line;
146 FixedText maFixedTextXMLFileName;
147 FileControl maEditXMLFileName;
148 FixedText maFixedTextBINFileName;
149 FileControl maEditBINFileName;
150 FixedText maFixedTextSIGFileName;
151 FileControl maEditSIGFileName;
152 PushButton maSignButton;
153 PushButton maVerifyButton;
154 FixedLine maTest2Line;
155 FixedText maFixedTextDOCFileName;
156 FileControl maEditDOCFileName;
157 PushButton maDigitalSignaturesButton;
158 PushButton maVerifyDigitalSignaturesButton;
159 FixedLine maHintLine;
160 FixedText maHintText;
162 DECL_LINK( CryptoCheckBoxHdl, CheckBox* );
163 DECL_LINK( SignButtonHdl, Button* );
164 DECL_LINK( VerifyButtonHdl, Button* );
165 DECL_LINK( DigitalSignaturesWithServiceHdl, Button* );
166 DECL_LINK( VerifyDigitalSignaturesHdl, Button* );
167 DECL_LINK( DigitalSignaturesWithTokenHdl, Button* );
168 DECL_LINK( StartVerifySignatureHdl, void* );
170 public:
171 MyWin( Window* pParent, WinBits nWinStyle );
175 // -----------------------------------------------------------------------
177 void Main()
179 MyWin aMainWin( NULL, WB_APP | WB_STDWORK | WB_3DLOOK);
180 aMainWin.Show();
182 Application::Execute();
185 // -----------------------------------------------------------------------
187 MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
188 WorkWindow( pParent, nWinStyle ),
189 maTokenLine( this ),
190 maTest1Line( this ),
191 maTest2Line( this ),
192 maHintLine( this ),
193 maFixedTextXMLFileName( this ),
194 maEditXMLFileName( this, WB_BORDER ),
195 maFixedTextBINFileName( this ),
196 maEditBINFileName( this, WB_BORDER ),
197 maFixedTextSIGFileName( this ),
198 maEditSIGFileName( this, WB_BORDER ),
199 maFixedTextTokenName( this ),
200 maEditTokenName( this, WB_BORDER ),
201 maFixedTextDOCFileName( this ),
202 maEditDOCFileName( this, WB_BORDER ),
203 maSignButton( this ),
204 maVerifyButton( this ),
205 maDigitalSignaturesButton( this ),
206 maVerifyDigitalSignaturesButton( this ),
207 maHintText( this, WB_WORDBREAK ),
208 maCryptoCheckBox( this )
211 #ifdef TEST_IMPLEMENTATION_DIRECTLY
212 Size aOutputSize( 400, 600 );
213 #else
214 Size aOutputSize( 400, 400 );
215 #endif
216 SetOutputSizePixel( aOutputSize );
217 SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML Signature Test" ) ) );
219 long nY = 15;
221 maTokenLine.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
222 maTokenLine.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Crypto Settings" ) ) );
223 maTokenLine.Show();
225 nY += EDITHEIGHT*3/2;
227 maCryptoCheckBox.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
228 maCryptoCheckBox.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use Default Token (NSS option only)" ) ) );
229 maCryptoCheckBox.Check( TRUE );
230 maEditTokenName.Disable();
231 maFixedTextTokenName.Disable();
232 maCryptoCheckBox.SetClickHdl( LINK( this, MyWin, CryptoCheckBoxHdl ) );
233 maCryptoCheckBox.Show();
235 nY += EDITHEIGHT;
237 maFixedTextTokenName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
238 maFixedTextTokenName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Crypto Token:" ) ) );
239 maFixedTextTokenName.Show();
241 maEditTokenName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
242 maEditTokenName.Show();
244 nY += EDITHEIGHT*3;
246 #ifdef TEST_IMPLEMENTATION_DIRECTLY
248 maTest1Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
249 maTest1Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test simple files" ) ) );
250 maTest1Line.Show();
252 nY += EDITHEIGHT*3/2;
254 maFixedTextXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
255 maFixedTextXMLFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML File:" ) ) );
256 maFixedTextXMLFileName.Show();
258 maEditXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
259 maEditXMLFileName.Show();
261 nY += EDITHEIGHT*3/2;
263 maFixedTextBINFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
264 maFixedTextBINFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Binary File:" ) ) );
265 maFixedTextBINFileName.Show();
267 maEditBINFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
268 maEditBINFileName.Show();
270 nY += EDITHEIGHT*3/2;
272 maFixedTextSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
273 maFixedTextSIGFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Signature File:" ) ) );
274 maFixedTextSIGFileName.Show();
276 maEditSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
277 maEditSIGFileName.Show();
279 nY += EDITHEIGHT*2;
281 maSignButton.SetPosSizePixel( TEXTFIELDSTARTX, nY, BUTTONWIDTH, BUTTONHEIGHT );
282 maSignButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Sign" ) ) );
283 maSignButton.SetClickHdl( LINK( this, MyWin, SignButtonHdl ) );
284 maSignButton.Show();
286 maVerifyButton.SetPosSizePixel( TEXTFIELDSTARTX+BUTTONWIDTH+BUTTONSPACE, nY, BUTTONWIDTH, BUTTONHEIGHT );
287 maVerifyButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Verify" ) ) );
288 maVerifyButton.SetClickHdl( LINK( this, MyWin, VerifyButtonHdl ) );
289 maVerifyButton.Show();
291 nY += EDITHEIGHT*3;
293 #endif // TEST_IMPLEMENTATION_DIRECTLY
295 maTest2Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
296 maTest2Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test Office Document" ) ) );
297 maTest2Line.Show();
299 nY += EDITHEIGHT*3/2;
302 maFixedTextDOCFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
303 maFixedTextDOCFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Office File:" ) ) );
304 maFixedTextDOCFileName.Show();
306 maEditDOCFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
307 maEditDOCFileName.Show();
309 nY += EDITHEIGHT*2;
311 maDigitalSignaturesButton.SetPosSizePixel( TEXTFIELDSTARTX, nY, BUTTONWIDTH*2, BUTTONHEIGHT );
312 maDigitalSignaturesButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Digital Signatures..." ) ) );
313 maDigitalSignaturesButton.SetClickHdl( LINK( this, MyWin, DigitalSignaturesWithServiceHdl ) );
314 maDigitalSignaturesButton.Show();
316 maVerifyDigitalSignaturesButton.SetPosSizePixel( TEXTFIELDSTARTX+BUTTONWIDTH*2+BUTTONSPACE, nY, BUTTONWIDTH*2, BUTTONHEIGHT );
317 maVerifyDigitalSignaturesButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Verify Signatures" ) ) );
318 maVerifyDigitalSignaturesButton.SetClickHdl( LINK( this, MyWin, VerifyDigitalSignaturesHdl ) );
319 maVerifyDigitalSignaturesButton.Show();
321 nY += EDITHEIGHT*2;
323 maHintLine.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
324 maHintLine.Show();
326 nY += EDITHEIGHT*2;
328 maHintText.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, aOutputSize.Height()-nY );
329 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." ) ) );
330 maHintText.Show();
332 // Help the user with some default values
333 ::rtl::OUString aTempDirURL;
334 ::osl::File::getTempDirURL( aTempDirURL );
335 INetURLObject aURLObj( aTempDirURL );
336 aURLObj.insertName( String( RTL_CONSTASCII_USTRINGPARAM( "nss" ) ), true );
337 ::rtl::OUString aNSSFolder = aURLObj.getFSysPath( INetURLObject::FSYS_DETECT );
338 String aDefaultXMLFileName( aNSSFolder );
339 maEditXMLFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.xml" ) ) );
340 maEditBINFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.gif" ) ) );
341 maEditDOCFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.sxw" ) ) );
342 maEditSIGFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-result.xml" ) ) );
343 maEditTokenName.SetText( aNSSFolder );
345 #ifdef WNT
346 maEditTokenName.SetText( String() );
347 maEditTokenName.Disable();
348 maCryptoCheckBox.Disable();
349 #endif
353 IMPL_LINK( MyWin, CryptoCheckBoxHdl, CheckBox*, EMPTYARG )
355 if ( maCryptoCheckBox.IsChecked() )
357 maEditTokenName.Disable();
358 maFixedTextTokenName.Disable();
360 else
362 maEditTokenName.Enable();
363 maFixedTextTokenName.Enable();
365 return 1;
368 IMPL_LINK( MyWin, DigitalSignaturesWithServiceHdl, Button*, EMPTYARG )
370 rtl::OUString aDocFileName = maEditDOCFileName.GetText();
371 uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
372 aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
374 uno::Reference< security::XDocumentDigitalSignatures > xD(
375 comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
376 if ( xD.is() )
377 xD->signDocumentContent( xStore, NULL );
380 return 0;
383 IMPL_LINK( MyWin, VerifyDigitalSignaturesHdl, Button*, EMPTYARG )
385 rtl::OUString aDocFileName = maEditDOCFileName.GetText();
386 uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
387 aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
389 uno::Reference< security::XDocumentDigitalSignatures > xD(
390 comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
391 if ( xD.is() )
393 uno::Sequence< security::DocumentSignatureInformation > aInfos = xD->verifyDocumentContentSignatures( xStore, NULL );
394 int nInfos = aInfos.getLength();
395 for ( int n = 0; n < nInfos; n++ )
397 security::DocumentSignatureInformation& rInf = aInfos[n];
398 String aText( RTL_CONSTASCII_USTRINGPARAM( "The document is signed by\n\n " ) );
399 aText += String( rInf.Signer->getSubjectName() );
400 aText += String( RTL_CONSTASCII_USTRINGPARAM( "\n\n The signature is " ) );
401 if ( !rInf.SignatureIsValid )
402 aText += String( RTL_CONSTASCII_USTRINGPARAM( "NOT " ) );
403 aText += String( RTL_CONSTASCII_USTRINGPARAM( "valid" ) );
404 InfoBox( this, aText ).Execute();
410 return 0;
414 #ifdef TEST_IMPLEMENTATION_DIRECTLY
416 IMPL_LINK( MyWin, DigitalSignaturesWithTokenHdl, Button*, EMPTYARG )
418 String aDocFileName = maEditDOCFileName.GetText();
419 String aTokenFileName = maEditTokenName.GetText();
421 DigitalSignaturesDialog aSignaturesDialog( this, comphelper::getProcessServiceFactory(), SignatureModeDocumentContent, false );
423 bool bInit = aSignaturesDialog.Init( aTokenFileName );
424 if ( !bInit )
426 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
427 return 0;
430 uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
431 aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
433 aSignaturesDialog.SetStorage( xStore );
435 aSignaturesDialog.Execute();
437 return 0;
440 IMPL_LINK( MyWin, SignButtonHdl, Button*, EMPTYARG )
442 String aXMLFileName = maEditXMLFileName.GetText();
443 String aBINFileName = maEditBINFileName.GetText();
444 String aSIGFileName = maEditSIGFileName.GetText();
446 String aTokenFileName;
447 if ( !maCryptoCheckBox.IsChecked() )
448 aTokenFileName = maEditTokenName.GetText();
450 XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() );
451 bool bInit = aSignatureHelper.Init( aTokenFileName );
453 if ( !bInit )
455 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
456 return 0;
459 uno::Reference< ::com::sun::star::security::XCertificate > xCertToUse;
460 CertificateChooser aChooser( this, aSignatureHelper.GetSecurityEnvironment(), SignatureInformations() );
461 if ( aChooser.Execute() )
462 xCertToUse = aChooser.GetSelectedCertificate();
464 if ( !xCertToUse.is() )
465 return 0;
468 aSignatureHelper.StartMission();
470 sal_Int32 nSecurityId = aSignatureHelper.GetNewSecurityId();
472 aSignatureHelper.SetX509Certificate( nSecurityId, xCertToUse->getIssuerName(), bigIntegerToNumericString( xCertToUse->getSerialNumber() ) );
474 aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False );
475 aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True );
477 SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_WRITE );
478 SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
479 uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes );
480 bool bDone = aSignatureHelper.CreateAndWriteSignature( xOutputStream );
482 aSignatureHelper.EndMission();
484 if ( !bDone )
486 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error creating Signature!" ) ) ).Execute();
488 else
490 rtl::OUString aInfo( String( RTL_CONSTASCII_USTRINGPARAM( "Signature successfully created!\n\n" ) ) );
491 // aInfo += getSignatureInformationmations( aSignatureHelper.getAllSignatureInformation(), aSignatureHelper.GetSecurityEnvironment() );
494 InfoBox( this, aInfo ).Execute();
497 // Check for more detailed results...
499 return 0;
502 IMPL_LINK( MyWin, VerifyButtonHdl, Button*, EMPTYARG )
504 String aXMLFileName = maEditXMLFileName.GetText();
505 String aBINFileName = maEditBINFileName.GetText();
506 String aSIGFileName = maEditSIGFileName.GetText();
508 String aTokenFileName;
509 if ( !maCryptoCheckBox.IsChecked() )
510 aTokenFileName = maEditTokenName.GetText();
512 XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() );
513 bool bInit = aSignatureHelper.Init( aTokenFileName );
515 if ( !bInit )
517 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
518 return 0;
521 aSignatureHelper.SetStartVerifySignatureHdl( LINK( this, MyWin, StartVerifySignatureHdl ) );
523 aSignatureHelper.StartMission();
525 SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_READ );
526 pStream->Seek( STREAM_SEEK_TO_END );
527 ULONG nBytes = pStream->Tell();
528 pStream->Seek( STREAM_SEEK_TO_BEGIN );
529 SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
530 uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes );
531 bool bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream );
532 xInputStream->closeInput();
534 aSignatureHelper.EndMission();
536 if ( !bDone )
537 ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error in Signature!" ) ) ).Execute();
538 else
539 InfoBox( this, String( RTL_CONSTASCII_USTRINGPARAM( "Signatures verified without any problems!" ) ) ).Execute();
541 return 0;
544 IMPL_LINK( MyWin, StartVerifySignatureHdl, void*, EMPTYARG )
546 QueryBox aQueryBox( this, WB_YES_NO|WB_DEF_YES, String( RTL_CONSTASCII_USTRINGPARAM( "Found Signature - Verify?" ) ) );
547 return ( aQueryBox.Execute() == RET_YES ) ? 1 : 0;
551 #endif // #ifdef TEST_IMPLEMENTATION_DIRECTLY