summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorThomas Arnhold <thomas@arnhold.org>2011-03-01 23:11:22 +0100
committerThomas Arnhold <thomas@arnhold.org>2011-03-02 08:21:01 +0100
commit4a177c01c81c2277f1a83d1560eb865a557ec78f (patch)
treeb4a70fa4b557fb23b028f8325e366cbf57dd179e /xmlsecurity
parenta71b066d80d67edefd8f1bfb68863f2f781f0470 (diff)
Remove TEST_IMPLEMENTATION_DIRECTLY
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/workben/signaturetest.cxx196
1 files changed, 0 insertions, 196 deletions
diff --git a/xmlsecurity/workben/signaturetest.cxx b/xmlsecurity/workben/signaturetest.cxx
index 0e3c6a066..40f63297d 100644
--- a/xmlsecurity/workben/signaturetest.cxx
+++ b/xmlsecurity/workben/signaturetest.cxx
@@ -83,9 +83,6 @@ void Main();
#define LISTBOXHEIGHT 120
-// #define TEST_IMPLEMENTATION_DIRECTLY
-
-
// -----------------------------------------------------------------------
SAL_IMPLEMENT_MAIN()
@@ -209,11 +206,7 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
maCryptoCheckBox( this )
{
-#ifdef TEST_IMPLEMENTATION_DIRECTLY
- Size aOutputSize( 400, 600 );
-#else
Size aOutputSize( 400, 400 );
-#endif
SetOutputSizePixel( aOutputSize );
SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML Signature Test" ) ) );
@@ -244,55 +237,6 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
nY += EDITHEIGHT*3;
-#ifdef TEST_IMPLEMENTATION_DIRECTLY
-
- maTest1Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
- maTest1Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test simple files" ) ) );
- maTest1Line.Show();
-
- nY += EDITHEIGHT*3/2;
-
- maFixedTextXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
- maFixedTextXMLFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML File:" ) ) );
- maFixedTextXMLFileName.Show();
-
- maEditXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
- maEditXMLFileName.Show();
-
- nY += EDITHEIGHT*3/2;
-
- maFixedTextBINFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
- maFixedTextBINFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Binary File:" ) ) );
- maFixedTextBINFileName.Show();
-
- maEditBINFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
- maEditBINFileName.Show();
-
- nY += EDITHEIGHT*3/2;
-
- maFixedTextSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
- maFixedTextSIGFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Signature File:" ) ) );
- maFixedTextSIGFileName.Show();
-
- maEditSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT );
- maEditSIGFileName.Show();
-
- nY += EDITHEIGHT*2;
-
- maSignButton.SetPosSizePixel( TEXTFIELDSTARTX, nY, BUTTONWIDTH, BUTTONHEIGHT );
- maSignButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Sign" ) ) );
- maSignButton.SetClickHdl( LINK( this, MyWin, SignButtonHdl ) );
- maSignButton.Show();
-
- maVerifyButton.SetPosSizePixel( TEXTFIELDSTARTX+BUTTONWIDTH+BUTTONSPACE, nY, BUTTONWIDTH, BUTTONHEIGHT );
- maVerifyButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Verify" ) ) );
- maVerifyButton.SetClickHdl( LINK( this, MyWin, VerifyButtonHdl ) );
- maVerifyButton.Show();
-
- nY += EDITHEIGHT*3;
-
-#endif // TEST_IMPLEMENTATION_DIRECTLY
-
maTest2Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
maTest2Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test Office Document" ) ) );
maTest2Line.Show();
@@ -411,144 +355,4 @@ IMPL_LINK( MyWin, VerifyDigitalSignaturesHdl, Button*, EMPTYARG )
return 0;
}
-
-#ifdef TEST_IMPLEMENTATION_DIRECTLY
-
-IMPL_LINK( MyWin, DigitalSignaturesWithTokenHdl, Button*, EMPTYARG )
-{
- String aDocFileName = maEditDOCFileName.GetText();
- String aTokenFileName = maEditTokenName.GetText();
-
- DigitalSignaturesDialog aSignaturesDialog( this, comphelper::getProcessServiceFactory(), SignatureModeDocumentContent, false );
-
- bool bInit = aSignaturesDialog.Init( aTokenFileName );
- if ( !bInit )
- {
- ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
- return 0;
- }
-
- uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
- aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
-
- aSignaturesDialog.SetStorage( xStore );
-
- aSignaturesDialog.Execute();
-
- return 0;
-}
-
-IMPL_LINK( MyWin, SignButtonHdl, Button*, EMPTYARG )
-{
- String aXMLFileName = maEditXMLFileName.GetText();
- String aBINFileName = maEditBINFileName.GetText();
- String aSIGFileName = maEditSIGFileName.GetText();
-
- String aTokenFileName;
- if ( !maCryptoCheckBox.IsChecked() )
- aTokenFileName = maEditTokenName.GetText();
-
- XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() );
- bool bInit = aSignatureHelper.Init( aTokenFileName );
-
- if ( !bInit )
- {
- ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
- return 0;
- }
-
- uno::Reference< ::com::sun::star::security::XCertificate > xCertToUse;
- CertificateChooser aChooser( this, aSignatureHelper.GetSecurityEnvironment(), SignatureInformations() );
- if ( aChooser.Execute() )
- xCertToUse = aChooser.GetSelectedCertificate();
-
- if ( !xCertToUse.is() )
- return 0;
-
-
- aSignatureHelper.StartMission();
-
- sal_Int32 nSecurityId = aSignatureHelper.GetNewSecurityId();
-
- aSignatureHelper.SetX509Certificate( nSecurityId, xCertToUse->getIssuerName(), bigIntegerToNumericString( xCertToUse->getSerialNumber() ) );
-
- aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False );
- aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True );
-
- SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_WRITE );
- SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
- uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes );
- bool bDone = aSignatureHelper.CreateAndWriteSignature( xOutputStream );
-
- aSignatureHelper.EndMission();
-
- if ( !bDone )
- {
- ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error creating Signature!" ) ) ).Execute();
- }
- else
- {
- rtl::OUString aInfo( String( RTL_CONSTASCII_USTRINGPARAM( "Signature successfully created!\n\n" ) ) );
- // aInfo += getSignatureInformationmations( aSignatureHelper.getAllSignatureInformation(), aSignatureHelper.GetSecurityEnvironment() );
-
-
- InfoBox( this, aInfo ).Execute();
- }
-
- // Check for more detailed results...
-
- return 0;
-}
-
-IMPL_LINK( MyWin, VerifyButtonHdl, Button*, EMPTYARG )
-{
- String aXMLFileName = maEditXMLFileName.GetText();
- String aBINFileName = maEditBINFileName.GetText();
- String aSIGFileName = maEditSIGFileName.GetText();
-
- String aTokenFileName;
- if ( !maCryptoCheckBox.IsChecked() )
- aTokenFileName = maEditTokenName.GetText();
-
- XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() );
- bool bInit = aSignatureHelper.Init( aTokenFileName );
-
- if ( !bInit )
- {
- ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
- return 0;
- }
-
- aSignatureHelper.SetStartVerifySignatureHdl( LINK( this, MyWin, StartVerifySignatureHdl ) );
-
- aSignatureHelper.StartMission();
-
- SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_READ );
- pStream->Seek( STREAM_SEEK_TO_END );
- ULONG nBytes = pStream->Tell();
- pStream->Seek( STREAM_SEEK_TO_BEGIN );
- SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
- uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes );
- bool bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream );
- xInputStream->closeInput();
-
- aSignatureHelper.EndMission();
-
- if ( !bDone )
- ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error in Signature!" ) ) ).Execute();
- else
- InfoBox( this, String( RTL_CONSTASCII_USTRINGPARAM( "Signatures verified without any problems!" ) ) ).Execute();
-
- return 0;
-}
-
-IMPL_LINK( MyWin, StartVerifySignatureHdl, void*, EMPTYARG )
-{
- QueryBox aQueryBox( this, WB_YES_NO|WB_DEF_YES, String( RTL_CONSTASCII_USTRINGPARAM( "Found Signature - Verify?" ) ) );
- return ( aQueryBox.Execute() == RET_YES ) ? 1 : 0;
-}
-
-
-#endif // #ifdef TEST_IMPLEMENTATION_DIRECTLY
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */