summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGökçen Eraslan <gokcen.eraslan@gmail.com>2012-07-07 23:10:30 +0300
committerGökçen Eraslan <gokcen.eraslan@gmail.com>2012-07-07 23:10:30 +0300
commit5f995a0d8ffea95bf6eecf5215da8178159be0ca (patch)
treea0f5cf465a3ecdb8151b25f1008e6d8dbc68897f
parentbb1ba4f3b784b1ad8776319d6336dba97e484d59 (diff)
Add password edit and pass XCertificate to PDFWriter code in VCL.
Now, we have the password of private key and the certificate to sign. Ready to use NSS and create necessary PKCS7 object using these. Change-Id: Id69487e92283059fcd558d33cf6a6128df0f50d9
-rw-r--r--filter/source/pdf/impdialog.cxx26
-rw-r--r--filter/source/pdf/impdialog.hrc16
-rw-r--r--filter/source/pdf/impdialog.hxx5
-rw-r--r--filter/source/pdf/impdialog.src32
-rw-r--r--filter/source/pdf/pdfexport.cxx6
-rw-r--r--filter/source/pdf/pdfexport.hxx2
-rw-r--r--vcl/inc/vcl/pdfwriter.hxx6
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx2
8 files changed, 72 insertions, 23 deletions
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index dd9c429f5a5f..f6f9b158864f 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -249,9 +249,6 @@ ImpPDFTabDialog::ImpPDFTabDialog( Window* pParent,
//prepare values for digital signatures
mbSignPDF = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignPDF" ) ), sal_False );
- //msSignLocation = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureLocation" ) ), "" );
- //msSignContact = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureContactInfo" ) ), "" );
- //msSignReason = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureReason" ) ), "" );
//queue the tab pages for later creation (created when first shown)
AddTabPage( RID_PDF_TAB_SIGNING, ImpPDFTabSigningPage::Create, 0 );
@@ -416,7 +413,7 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
Sequence< PropertyValue > aRet( maConfigItem.GetFilterData() );
- int nElementAdded = 9;
+ int nElementAdded = 11;
aRet.realloc( aRet.getLength() + nElementAdded );
@@ -472,6 +469,14 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
aRet[ nLength - nElementAdded ].Value <<= msSignContact;
nElementAdded--;
+ aRet[ nLength - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SignaturePassword" ) );
+ aRet[ nLength - nElementAdded ].Value <<= msSignPassword;
+ nElementAdded--;
+
+ aRet[ nLength - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureCertificate" ) );
+ aRet[ nLength - nElementAdded ].Value <<= maSignCertificate;
+ nElementAdded--;
+
return aRet;
}
@@ -1678,13 +1683,16 @@ ImpPDFTabSigningPage::ImpPDFTabSigningPage( Window* pParent,
SfxTabPage( pParent, PDFFilterResId( RID_PDF_TAB_SIGNING ), rCoreSet ),
maCbSignPDF( this, PDFFilterResId( CB_SIGN_PDF ) ),
+ maFtSignPassword( this, PDFFilterResId( FT_SIGN_PASSWORD ) ),
+ maEdSignPassword( this, PDFFilterResId( ED_SIGN_PASSWORD ) ),
maFtSignLocation( this, PDFFilterResId( FT_SIGN_LOCATION ) ),
maEdSignLocation( this, PDFFilterResId( ED_SIGN_LOCATION ) ),
maFtSignContactInfo( this, PDFFilterResId( FT_SIGN_CONTACT ) ),
maEdSignContactInfo( this, PDFFilterResId( ED_SIGN_CONTACT ) ),
maFtSignReason( this, PDFFilterResId( FT_SIGN_REASON ) ),
maEdSignReason( this, PDFFilterResId( ED_SIGN_REASON ) ),
- maPbSignSelectCert( this, PDFFilterResId( BTN_SIGN_SELECT_CERT ) )
+ maPbSignSelectCert( this, PDFFilterResId( BTN_SIGN_SELECT_CERT ) ),
+ maSignCertificate()
{
FreeResource();
@@ -1711,7 +1719,7 @@ IMPL_LINK_NOARG( ImpPDFTabSigningPage, ClickmaPbSignSelectCert )
if ( !xSigner.is() )
return 0;
- Reference< security::XCertificate > xCert = xSigner->chooseCertificate();
+ maSignCertificate = xSigner->chooseCertificate();
return 0;
}
@@ -1728,8 +1736,10 @@ void ImpPDFTabSigningPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
{
paParent->mbSignPDF = maCbSignPDF.IsChecked();
paParent->msSignLocation = maEdSignLocation.GetText();
+ paParent->msSignPassword = maEdSignPassword.GetText();
paParent->msSignContact = maEdSignContactInfo.GetText();
paParent->msSignReason = maEdSignReason.GetText();
+ paParent->maSignCertificate = maSignCertificate;
}
@@ -1739,6 +1749,7 @@ void ImpPDFTabSigningPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent
maCbSignPDF.SetToggleHdl( LINK( this, ImpPDFTabSigningPage, ToggleSignPDFHdl ) );
maEdSignLocation.Enable( false );
+ maEdSignPassword.Enable( false );
maEdSignContactInfo.Enable( false );
maEdSignReason.Enable( false );
maPbSignSelectCert.Enable( false );
@@ -1746,15 +1757,18 @@ void ImpPDFTabSigningPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent
if (paParent->mbSignPDF)
{
maCbSignPDF.Check();
+ maEdSignPassword.SetText(paParent->msSignPassword);
maEdSignLocation.SetText(paParent->msSignLocation);
maEdSignContactInfo.SetText(paParent->msSignContact);
maEdSignReason.SetText(paParent->msSignReason);
+ maSignCertificate = paParent->maSignCertificate;
}
}
// -----------------------------------------------------------------------------
IMPL_LINK_NOARG(ImpPDFTabSigningPage, ToggleSignPDFHdl)
{
+ maEdSignPassword.Enable( maCbSignPDF.IsChecked() );
maEdSignLocation.Enable( maCbSignPDF.IsChecked() );
maEdSignContactInfo.Enable( maCbSignPDF.IsChecked() );
maEdSignReason.Enable( maCbSignPDF.IsChecked() );
diff --git a/filter/source/pdf/impdialog.hrc b/filter/source/pdf/impdialog.hrc
index e44630210b30..9fede12bb507 100644
--- a/filter/source/pdf/impdialog.hrc
+++ b/filter/source/pdf/impdialog.hrc
@@ -202,10 +202,12 @@
//controls for digital signatures tab page
#define CB_SIGN_PDF 170
-#define FT_SIGN_LOCATION 171
-#define ED_SIGN_LOCATION 172
-#define FT_SIGN_CONTACT 173
-#define ED_SIGN_CONTACT 174
-#define FT_SIGN_REASON 175
-#define ED_SIGN_REASON 176
-#define BTN_SIGN_SELECT_CERT 177
+#define FT_SIGN_PASSWORD 171
+#define ED_SIGN_PASSWORD 172
+#define FT_SIGN_LOCATION 173
+#define ED_SIGN_LOCATION 174
+#define FT_SIGN_CONTACT 175
+#define ED_SIGN_CONTACT 176
+#define FT_SIGN_REASON 177
+#define ED_SIGN_REASON 178
+#define BTN_SIGN_SELECT_CERT 179
diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx
index b83343b04412..335aadb8f7a7 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -151,9 +151,11 @@ protected:
sal_Bool mbExportBmkToPDFDestination;
sal_Bool mbSignPDF;
+ ::rtl::OUString msSignPassword;
::rtl::OUString msSignLocation;
::rtl::OUString msSignContact;
::rtl::OUString msSignReason;
+ com::sun::star::uno::Reference< com::sun::star::security::XCertificate > maSignCertificate;
::rtl::OUString maWatermarkText;
@@ -441,6 +443,8 @@ public:
class ImpPDFTabSigningPage : public SfxTabPage
{
CheckBox maCbSignPDF;
+ FixedText maFtSignPassword;
+ Edit maEdSignPassword;
FixedText maFtSignLocation;
Edit maEdSignLocation;
FixedText maFtSignContactInfo;
@@ -448,6 +452,7 @@ class ImpPDFTabSigningPage : public SfxTabPage
FixedText maFtSignReason;
Edit maEdSignReason;
PushButton maPbSignSelectCert;
+ com::sun::star::uno::Reference< com::sun::star::security::XCertificate > maSignCertificate;
DECL_LINK( ToggleSignPDFHdl, void* );
DECL_LINK( ClickmaPbSignSelectCert, void* );
diff --git a/filter/source/pdf/impdialog.src b/filter/source/pdf/impdialog.src
index b099a53949a1..afae67e7eab1 100644
--- a/filter/source/pdf/impdialog.src
+++ b/filter/source/pdf/impdialog.src
@@ -843,23 +843,37 @@ TabPage RID_PDF_TAB_SIGNING
Text[ en-US ] = "Select c~ertificate...";
};
- FixedText FT_SIGN_LOCATION
+ FixedText FT_SIGN_PASSWORD
{
Pos = MAP_APPFONT( 12, 35 );
Size = MAP_APPFONT( 109, 10 );
+ Text[ en-US ] = "Certificate Password";
+ };
+
+ Edit ED_SIGN_PASSWORD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 102, 35 ) ;
+ Size = MAP_APPFONT ( 68 , 12 ) ;
+ };
+
+ FixedText FT_SIGN_LOCATION
+ {
+ Pos = MAP_APPFONT( 12, 48 );
+ Size = MAP_APPFONT( 109, 10 );
Text[ en-US ] = "Location";
};
Edit ED_SIGN_LOCATION
{
Border = TRUE ;
- Pos = MAP_APPFONT ( 122, 35 ) ;
- Size = MAP_APPFONT ( 48 , 12 ) ;
+ Pos = MAP_APPFONT ( 102, 48 ) ;
+ Size = MAP_APPFONT ( 68 , 12 ) ;
};
FixedText FT_SIGN_CONTACT
{
- Pos = MAP_APPFONT( 12, 48 );
+ Pos = MAP_APPFONT( 12, 61 );
Size = MAP_APPFONT( 109, 10 );
Text[ en-US ] = "Contact Information";
};
@@ -867,13 +881,13 @@ TabPage RID_PDF_TAB_SIGNING
Edit ED_SIGN_CONTACT
{
Border = TRUE ;
- Pos = MAP_APPFONT ( 122, 48 ) ;
- Size = MAP_APPFONT ( 48 , 12 ) ;
+ Pos = MAP_APPFONT ( 102, 61 ) ;
+ Size = MAP_APPFONT ( 68 , 12 ) ;
};
FixedText FT_SIGN_REASON
{
- Pos = MAP_APPFONT( 12, 61 );
+ Pos = MAP_APPFONT( 12, 74 );
Size = MAP_APPFONT( 109, 10 );
Text[ en-US ] = "Reason";
};
@@ -881,8 +895,8 @@ TabPage RID_PDF_TAB_SIGNING
Edit ED_SIGN_REASON
{
Border = TRUE ;
- Pos = MAP_APPFONT ( 122, 61 ) ;
- Size = MAP_APPFONT ( 48 , 12 ) ;
+ Pos = MAP_APPFONT ( 102, 74 ) ;
+ Size = MAP_APPFONT ( 68 , 12 ) ;
};
};
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index a137ceefb719..30727c6773f1 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -562,6 +562,10 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue
rFilterData[ nData ].Value >>= msSignReason;
else if ( rFilterData[ nData ].Name == "SignatureContactInfo" )
rFilterData[ nData ].Value >>= msSignContact;
+ else if ( rFilterData[ nData ].Name == "SignaturePassword" )
+ rFilterData[ nData ].Value >>= msSignPassword;
+ else if ( rFilterData[ nData ].Name == "SignatureCertificate" )
+ rFilterData[ nData ].Value >>= maSignCertificate;
}
aContext.URL = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
@@ -794,6 +798,8 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue
aContext.SignLocation = msSignLocation;
aContext.SignContact = msSignContact;
aContext.SignReason = msSignReason;
+ aContext.SignPassword = msSignPassword;
+ aContext.SignCertificate = maSignCertificate;
// all context data set, time to create the printing device
PDFWriter* pPDFWriter = new PDFWriter( aContext, xEnc );
diff --git a/filter/source/pdf/pdfexport.hxx b/filter/source/pdf/pdfexport.hxx
index baa996ec81e8..3962d1e5b804 100644
--- a/filter/source/pdf/pdfexport.hxx
+++ b/filter/source/pdf/pdfexport.hxx
@@ -122,6 +122,8 @@ private:
OUString msSignLocation;
OUString msSignContact;
OUString msSignReason;
+ OUString msSignPassword;
+ Reference< security::XCertificate > maSignCertificate;
void ImplWriteWatermark( ::vcl::PDFWriter& rWriter, const Size& rPageSize );
public:
diff --git a/vcl/inc/vcl/pdfwriter.hxx b/vcl/inc/vcl/pdfwriter.hxx
index 535c2b39034c..0e93cdd9c6a1 100644
--- a/vcl/inc/vcl/pdfwriter.hxx
+++ b/vcl/inc/vcl/pdfwriter.hxx
@@ -41,6 +41,7 @@
#include "com/sun/star/io/XOutputStream.hpp"
#include "com/sun/star/beans/XMaterialHolder.hpp"
+#include "com/sun/star/security/XCertificate.hpp"
#include "com/sun/star/lang/Locale.hpp"
#include <boost/scoped_ptr.hpp>
@@ -631,8 +632,10 @@ The following structure describes the permissions used in PDF security
bool SignPDF;
rtl::OUString SignLocation;
+ rtl::OUString SignPassword;
rtl::OUString SignReason;
rtl::OUString SignContact;
+ com::sun::star::uno::Reference< com::sun::star::security::XCertificate> SignCertificate;
com::sun::star::lang::Locale DocumentLocale; // defines the document default language
sal_uInt32 DPIx, DPIy; // how to handle MapMode( MAP_PIXEL )
@@ -668,7 +671,8 @@ The following structure describes the permissions used in PDF security
SignPDF( false ),
DPIx( 0 ),
DPIy( 0 ),
- ColorMode( PDFWriter::DrawColor )
+ ColorMode( PDFWriter::DrawColor ),
+ SignCertificate( 0 )
{}
};
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 64382716ab0a..16f2a0de08dd 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -6175,6 +6175,8 @@ bool PDFWriterImpl::finalizeSignature()
}
// 3- create the PKCS#7 object using NSS
+ // use m_aContext.SignCertificate and m_aContext.SignPassword as certificate and private key password
+ // SignCertificate->getEncoded is DER encoded certificate
// 4- overwrite the PKCS7 content to the m_nSignatureContentOffset
CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, m_nSignatureContentOffset ) ) );