Kaydet (Commit) 9c5d3e5c authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt

tdf#118581 Correctly display issuer name in signature line

Move the xmlsec helper methods to comphelper so that we can use them in cui

Change-Id: If9b10cfff5f5abd6b16e48f043af7959edbb1142
Reviewed-on: https://gerrit.libreoffice.org/63198
Tested-by: Jenkins
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 3d885f20
......@@ -143,6 +143,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
comphelper/source/misc/types \
comphelper/source/misc/weak \
comphelper/source/misc/weakeventlistener \
comphelper/source/misc/xmlsechelper \
comphelper/source/officeinstdir/officeinstallationdirectories \
comphelper/source/processfactory/processfactory \
comphelper/source/property/ChainablePropertySet \
......
......@@ -18,7 +18,7 @@
*/
#include <resourcemanager.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <vcl/svapp.hxx>
#include <vcl/fixed.hxx>
......@@ -30,34 +30,10 @@
using namespace std;
namespace XmlSec
namespace comphelper
{
namespace xmlsec
{
const LocaleDataWrapper& GetLocaleData()
{
static SvtSysLocale ourSysLocale;
return ourSysLocale.GetLocaleData();
}
DateTime GetDateTime( const css::util::DateTime& _rDT )
{
return DateTime(_rDT);
}
OUString GetDateTimeString( const css::util::DateTime& _rDT )
{
// String with date and time information (#i20172#)
DateTime aDT( GetDateTime( _rDT ) );
const LocaleDataWrapper& rLoDa = GetLocaleData();
return rLoDa.getDate( aDT ) + " " + rLoDa.getTime( aDT );
}
OUString GetDateString( const css::util::DateTime& _rDT )
{
return GetLocaleData().getDate( GetDateTime( _rDT ) );
}
OUString GetCertificateKind( const css::security::CertificateKind &rKind )
{
switch (rKind)
......@@ -354,5 +330,6 @@ vector< pair< OUString, OUString> > parseDN(const OUString& rRawString)
return aStr.makeStringAndClear();
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -16,6 +16,7 @@
#include <strings.hrc>
#include <comphelper/processfactory.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <tools/stream.hxx>
#include <unotools/localedatawrapper.hxx>
#include <unotools/streamwrap.hxx>
......@@ -40,6 +41,7 @@
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
using namespace comphelper;
using namespace css;
using namespace css::uno;
using namespace css::beans;
......@@ -138,7 +140,8 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, chooseCertificate, weld::Button&, void)
if (xSignCertificate.is())
{
m_xSelectedCertifate = xSignCertificate;
m_xBtnChooseCertificate->set_label(xSignCertificate->getIssuerName());
m_xBtnChooseCertificate->set_label(
xmlsec::GetContentPart(xSignCertificate->getIssuerName()));
}
ValidateFields();
}
......@@ -175,8 +178,9 @@ SignSignatureLineDialog::getSignedGraphic(bool bValid)
aSvgImage = aSvgImage.replaceAll("[SIGNER_TITLE]", getCDataString(m_aSuggestedSignerTitle));
aSvgImage = aSvgImage.replaceAll("[SIGNATURE]", getCDataString(m_xEditName->get_text()));
OUString aIssuerLine = CuiResId(RID_SVXSTR_SIGNATURELINE_SIGNED_BY)
.replaceFirst("%1", m_xSelectedCertifate->getIssuerName());
OUString aIssuerLine
= CuiResId(RID_SVXSTR_SIGNATURELINE_SIGNED_BY)
.replaceFirst("%1", xmlsec::GetContentPart(m_xSelectedCertifate->getIssuerName()));
aSvgImage = aSvgImage.replaceAll("[SIGNED_BY]", getCDataString(aIssuerLine));
if (bValid)
aSvgImage = aSvgImage.replaceAll("[INVALID_SIGNATURE]", "");
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_COMPHELPER_XMLSECHELPER_HXX
#define INCLUDED_COMPHELPER_XMLSECHELPER_HXX
#include <comphelper/comphelperdllapi.h>
#include <com/sun/star/security/CertificateKind.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <vector>
namespace comphelper
{
namespace xmlsec
{
COMPHELPER_DLLPUBLIC OUString GetCertificateKind(const css::security::CertificateKind& rKind);
COMPHELPER_DLLPUBLIC std::vector<std::pair<OUString, OUString>> parseDN(const OUString& rRawString);
COMPHELPER_DLLPUBLIC std::pair<OUString, OUString>
GetDNForCertDetailsView(const OUString& rRawString);
COMPHELPER_DLLPUBLIC OUString GetContentPart(const OUString& _rRawString);
COMPHELPER_DLLPUBLIC OUString GetHexString(const css::uno::Sequence<sal_Int8>& _rSeq,
const char* _pSep, sal_uInt16 _nLineBreak = 0xFFFF);
}
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -31,9 +31,14 @@ namespace com { namespace sun { namespace star { namespace util { struct Time; }
class Date;
class DateTime;
class LocaleDataWrapper;
namespace utl
{
UNOTOOLS_DLLPUBLIC const LocaleDataWrapper& GetLocaleData();
UNOTOOLS_DLLPUBLIC DateTime GetDateTime(const css::util::DateTime& _rDT);
UNOTOOLS_DLLPUBLIC OUString GetDateTimeString(const css::util::DateTime& _rDT);
UNOTOOLS_DLLPUBLIC OUString GetDateString(const css::util::DateTime& _rDT);
UNOTOOLS_DLLPUBLIC void typeConvert(const Date& _rDate, css::util::Date& _rOut);
UNOTOOLS_DLLPUBLIC void typeConvert(const css::util::Date& _rDate, Date& _rOut);
......
......@@ -1651,6 +1651,7 @@ comphelper/source/misc/threadpool.cxx
comphelper/source/misc/types.cxx
comphelper/source/misc/weak.cxx
comphelper/source/misc/weakeventlistener.cxx
comphelper/source/misc/xmlsechelper.cxx
comphelper/source/officeinstdir/officeinstallationdirectories.cxx
comphelper/source/officeinstdir/officeinstallationdirectories.hxx
comphelper/source/processfactory/processfactory.cxx
......@@ -19444,7 +19445,6 @@ xmlsecurity/inc/pch/precompiled_xsec_gpg.cxx
xmlsecurity/inc/pch/precompiled_xsec_gpg.hxx
xmlsecurity/inc/pch/precompiled_xsec_xmlsec.cxx
xmlsecurity/inc/pch/precompiled_xsec_xmlsec.hxx
xmlsecurity/inc/resourcemanager.hxx
xmlsecurity/inc/xmlsec-wrapper.h
xmlsecurity/inc/xmlsec/errorcallback.hxx
xmlsecurity/inc/xmlsec/saxhelper.hxx
......@@ -19469,7 +19469,6 @@ xmlsecurity/source/dialogs/certificatechooser.cxx
xmlsecurity/source/dialogs/certificateviewer.cxx
xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
xmlsecurity/source/dialogs/macrosecurity.cxx
xmlsecurity/source/dialogs/resourcemanager.cxx
xmlsecurity/source/framework/buffernode.cxx
xmlsecurity/source/framework/buffernode.hxx
xmlsecurity/source/framework/elementcollector.cxx
......
......@@ -18,12 +18,14 @@
*/
#include <unotools/datetime.hxx>
#include <unotools/syslocale.hxx>
#include <tools/date.hxx>
#include <tools/time.hxx>
#include <tools/datetime.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
#include <sstream>
namespace
......@@ -193,6 +195,27 @@ namespace
namespace utl
{
const LocaleDataWrapper& GetLocaleData()
{
static SvtSysLocale ourSysLocale;
return ourSysLocale.GetLocaleData();
}
DateTime GetDateTime(const css::util::DateTime& _rDT) { return DateTime(_rDT); }
OUString GetDateTimeString(const css::util::DateTime& _rDT)
{
// String with date and time information (#i20172#)
DateTime aDT(GetDateTime(_rDT));
const LocaleDataWrapper& rLoDa = GetLocaleData();
return rLoDa.getDate(aDT) + " " + rLoDa.getTime(aDT);
}
OUString GetDateString(const css::util::DateTime& _rDT)
{
return GetLocaleData().getDate(GetDateTime(_rDT));
}
void typeConvert(const Date& _rDate, css::util::Date& _rOut)
{
......
......@@ -51,7 +51,6 @@ $(eval $(call gb_Library_add_exception_objects,xmlsecurity,\
xmlsecurity/source/dialogs/certificateviewer \
xmlsecurity/source/dialogs/digitalsignaturesdialog \
xmlsecurity/source/dialogs/macrosecurity \
xmlsecurity/source/dialogs/resourcemanager \
xmlsecurity/source/framework/buffernode \
xmlsecurity/source/framework/elementcollector \
xmlsecurity/source/framework/elementmark \
......
......@@ -21,38 +21,8 @@
#define INCLUDED_XMLSECURITY_SOURCE_DIALOGS_RESOURCEMANAGER_HXX
#include <unotools/resmgr.hxx>
#include <tools/datetime.hxx>
#include <com/sun/star/security/CertificateKind.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <vector>
class FixedImage;
class Control;
class LocaleDataWrapper;
namespace XmlSec
{
const LocaleDataWrapper& GetLocaleData();
DateTime GetDateTime( const css::util::DateTime& _rDT );
OUString GetDateTimeString( const css::util::DateTime& _rDT );
OUString GetDateString( const css::util::DateTime& _rDT );
OUString GetCertificateKind( const css::security::CertificateKind& rKind );
std::vector< std::pair< OUString, OUString> >
parseDN(const OUString& rRawString);
std::pair< OUString, OUString> GetDNForCertDetailsView(
const OUString & rRawString);
OUString GetContentPart( const OUString& _rRawString );
OUString GetHexString( const css::uno::Sequence< sal_Int8 >& _rSeq, const char* _pSep, sal_uInt16 _nLineBreak = 0xFFFF );
}
inline OUString XsResId(const char* pId)
{
return Translate::get(pId, Translate::Create("xsc"));
}
inline OUString XsResId(const char* pId) { return Translate::get(pId, Translate::Create("xsc")); }
#endif
......
......@@ -46,6 +46,7 @@
#include <comphelper/documentconstants.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <sal/log.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
......
......@@ -23,14 +23,16 @@
#include <biginteger.hxx>
#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
#include <comphelper/sequence.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <com/sun/star/security/NoPasswordException.hpp>
#include <com/sun/star/security/CertificateCharacters.hpp>
#include <resourcemanager.hxx>
#include <vcl/treelistentry.hxx>
#include <unotools/datetime.hxx>
#include <unotools/useroptions.hxx>
using namespace comphelper;
using namespace css;
CertificateChooser::CertificateChooser(vcl::Window* _pParent,
......@@ -229,11 +231,11 @@ void CertificateChooser::ImplInitialize()
userData->xSecurityEnvironment = secEnvironment;
mvUserData.push_back(userData);
OUString sIssuer = XmlSec::GetContentPart( xCerts[ nC ]->getIssuerName() );
SvTreeListEntry* pEntry = m_pCertLB->InsertEntry( XmlSec::GetContentPart( xCerts[ nC ]->getSubjectName() )
OUString sIssuer = xmlsec::GetContentPart( xCerts[ nC ]->getIssuerName() );
SvTreeListEntry* pEntry = m_pCertLB->InsertEntry( xmlsec::GetContentPart( xCerts[ nC ]->getSubjectName() )
+ "\t" + sIssuer
+ "\t" + XmlSec::GetCertificateKind( xCerts[ nC ]->getCertificateKind() )
+ "\t" + XmlSec::GetDateString( xCerts[ nC ]->getNotValidAfter() )
+ "\t" + xmlsec::GetCertificateKind( xCerts[ nC ]->getCertificateKind() )
+ "\t" + utl::GetDateString( xCerts[ nC ]->getNotValidAfter() )
+ "\t" + UsageInClearText( xCerts[ nC ]->getCertificateUsage() ) );
pEntry->SetUserData( userData.get() );
......
......@@ -31,11 +31,14 @@
#include <strings.hrc>
#include <resourcemanager.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <svtools/controldims.hxx>
#include <tools/datetime.hxx>
#include <bitmaps.hlst>
#include <vcl/settings.hxx>
using namespace comphelper;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
......@@ -128,12 +131,12 @@ CertificateViewerGeneralTP::CertificateViewerGeneralTP( vcl::Window* _pParent, C
// insert data
css::uno::Reference< css::security::XCertificate > xCert = mpDlg->mxCert;
OUString sSubjectName(XmlSec::GetContentPart(xCert->getSubjectName()));
OUString sSubjectName(xmlsec::GetContentPart(xCert->getSubjectName()));
if (!sSubjectName.isEmpty())
m_pIssuedToFT->SetText(sSubjectName);
else
m_pIssuedToLabelFT->Hide();
OUString sIssuerName(XmlSec::GetContentPart(xCert->getIssuerName()));
OUString sIssuerName(xmlsec::GetContentPart(xCert->getIssuerName()));
if (!sIssuerName.isEmpty())
m_pIssuedByFT->SetText(sIssuerName);
else
......@@ -263,12 +266,12 @@ CertificateViewerDetailsTP::CertificateViewerDetailsTP( vcl::Window* _pParent, C
aLBEntry = "V" + OUString::number( xCert->getVersion() + 1 );
InsertElement( XsResId( STR_VERSION ), aLBEntry, aLBEntry );
Sequence< sal_Int8 > aSeq = xCert->getSerialNumber();
aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
aLBEntry = xmlsec::GetHexString( aSeq, pHexSep );
aDetails = xmlsec::GetHexString( aSeq, pHexSep, nLineBreak );
InsertElement( XsResId( STR_SERIALNUM ), aLBEntry, aDetails, true );
std::pair< OUString, OUString> pairIssuer =
XmlSec::GetDNForCertDetailsView(xCert->getIssuerName());
xmlsec::GetDNForCertDetailsView(xCert->getIssuerName());
aLBEntry = pairIssuer.first;
aDetails = pairIssuer.second;
InsertElement( XsResId( STR_ISSUER ), aLBEntry, aDetails );
......@@ -286,7 +289,7 @@ CertificateViewerDetailsTP::CertificateViewerDetailsTP( vcl::Window* _pParent, C
InsertElement( XsResId( STR_VALIDTO ), aLBEntry, aLBEntry );
std::pair< OUString, OUString > pairSubject =
XmlSec::GetDNForCertDetailsView(xCert->getSubjectName());
xmlsec::GetDNForCertDetailsView(xCert->getSubjectName());
aLBEntry = pairSubject.first;
aDetails = pairSubject.second;
InsertElement( XsResId( STR_SUBJECT ), aLBEntry, aDetails );
......@@ -294,8 +297,8 @@ CertificateViewerDetailsTP::CertificateViewerDetailsTP( vcl::Window* _pParent, C
aLBEntry = aDetails = xCert->getSubjectPublicKeyAlgorithm();
InsertElement( XsResId( STR_SUBJECT_PUBKEY_ALGO ), aLBEntry, aDetails );
aSeq = xCert->getSubjectPublicKeyValue();
aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
aLBEntry = xmlsec::GetHexString( aSeq, pHexSep );
aDetails = xmlsec::GetHexString( aSeq, pHexSep, nLineBreak );
InsertElement( XsResId( STR_SUBJECT_PUBKEY_VAL ), aLBEntry, aDetails, true );
aLBEntry = aDetails = xCert->getSignatureAlgorithm();
......@@ -309,13 +312,13 @@ CertificateViewerDetailsTP::CertificateViewerDetailsTP( vcl::Window* _pParent, C
}
aSeq = xCert->getSHA1Thumbprint();
aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
aLBEntry = xmlsec::GetHexString( aSeq, pHexSep );
aDetails = xmlsec::GetHexString( aSeq, pHexSep, nLineBreak );
InsertElement( XsResId( STR_THUMBPRINT_SHA1 ), aLBEntry, aDetails, true );
aSeq = xCert->getMD5Thumbprint();
aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
aLBEntry = xmlsec::GetHexString( aSeq, pHexSep );
aDetails = xmlsec::GetHexString( aSeq, pHexSep, nLineBreak );
InsertElement( XsResId( STR_THUMBPRINT_MD5 ), aLBEntry, aDetails, true );
m_pElementsLB->SetSelectHdl( LINK( this, CertificateViewerDetailsTP, ElementSelectHdl ) );
......@@ -426,7 +429,7 @@ void CertificateViewerCertPathTP::ActivatePage()
for (i = nCnt-1; i >= 0; i--)
{
const Reference< security::XCertificate > rCert = pCertPath[ i ];
OUString sName = XmlSec::GetContentPart( rCert->getSubjectName() );
OUString sName = xmlsec::GetContentPart( rCert->getSubjectName() );
//Verify the certificate
sal_Int32 certStatus = mpDlg->mxSecurityEnvironment->verifyCertificate(rCert,
Sequence<Reference<css::security::XCertificate> >());
......
......@@ -48,14 +48,17 @@
#include <tools/date.hxx>
#include <tools/time.hxx>
#include <unotools/datetime.hxx>
#include <vcl/treelistentry.hxx>
#include <strings.hrc>
#include <resourcemanager.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <vcl/weld.hxx>
#include <unotools/configitem.hxx>
using namespace comphelper;
using namespace css::security;
using namespace css::uno;
using namespace css;
......@@ -587,8 +590,8 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox()
bCertValid = false;
}
aSubject = XmlSec::GetContentPart( xCert->getSubjectName() );
aIssuer = XmlSec::GetContentPart( xCert->getIssuerName() );
aSubject = xmlsec::GetContentPart( xCert->getSubjectName() );
aIssuer = xmlsec::GetContentPart( xCert->getIssuerName() );
}
else if (!rInfo.ouGpgCertificate.isEmpty())
{
......@@ -596,7 +599,7 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox()
aIssuer = rInfo.ouGpgOwner;
}
aDateTimeStr = XmlSec::GetDateTimeString( rInfo.stDateTime );
aDateTimeStr = utl::GetDateTimeString( rInfo.stDateTime );
aDescription = rInfo.ouDescription;
// Decide type string.
......
......@@ -33,16 +33,18 @@
#include <comphelper/sequence.hxx>
#include <sfx2/filedlghelper.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <tools/urlobj.hxx>
#include <unotools/datetime.hxx>
#include <vcl/treelistentry.hxx>
#include <strings.hrc>
#include <resourcemanager.hxx>
using namespace comphelper;
using namespace ::com::sun::star;
......@@ -328,9 +330,9 @@ void MacroSecurityTrustedSourcesTP::FillCertLB()
// create from RawData
xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rEntry[ 2 ] );
SvTreeListEntry* pLBEntry = m_pTrustCertLB->InsertEntry( XmlSec::GetContentPart( xCert->getSubjectName() ) );
m_pTrustCertLB->SetEntryText( XmlSec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 );
m_pTrustCertLB->SetEntryText( XmlSec::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 );
SvTreeListEntry* pLBEntry = m_pTrustCertLB->InsertEntry( xmlsec::GetContentPart( xCert->getSubjectName() ) );
m_pTrustCertLB->SetEntryText( xmlsec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 );
m_pTrustCertLB->SetEntryText( utl::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 );
pLBEntry->SetUserData( reinterpret_cast<void*>(nEntry) ); // misuse user data as index
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment