/* -*- 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 .
*/
if (comphelper::LibreOfficeKit::isActive())
{ // Single certificate doesn't change during the lifetime of a LOK view: no need to search or // reload it.
m_xSearchBox->hide();
m_xReloadBtn->hide();
}
}
CertificateChooser::~CertificateChooser()
{
}
void CertificateChooser::BeforeRun()
{ // #i48432# // We can't check for personal certificates before raising this dialog, // because the mozilla implementation throws a NoPassword exception, // if the user pressed cancel, and also if the database does not exist! // But in the later case, the is no password query, and the user is confused // that nothing happens when pressing "Add..." in the SignatureDialog.
// PostUserLink behavior is too slow, so do it directly before Execute(). // Problem: This Dialog should be visible right now, and the parent should not be accessible. // Show, Update, DisableInput...
m_xDialog->show();
ImplInitialize();
}
short CertificateChooser::run()
{
BeforeRun(); return GenericDialogController::run();
}
void CertificateChooser::HandleOneUsageBit(OUString& string, int& bits, int bit, TranslateId pResId)
{ if (bits & bit)
{ if (!string.isEmpty())
string += ", ";
string += XsResId(pResId);
bits &= ~bit;
}
}
try
{ if (xMemCerts.count(secContext))
{
xCerts = xMemCerts[secContext];
} else
{ if (meAction == CertificateChooserUserAction::Sign || meAction == CertificateChooserUserAction::SelectSign)
{ if (comphelper::LibreOfficeKit::isActive())
{ // The LOK case takes the signing certificate from the view. if (m_pViewShell && m_pViewShell->GetSigningCertificate().m_xCertificate.is())
{
xCerts = { m_pViewShell->GetSigningCertificate().m_xCertificate };
}
} else
{ // Otherwise working from the system cert store is OK.
xCerts = secEnvironment->getPersonalCertificates();
}
} else // Currently (master 2024-07) all X.509 implementations (nss+mscrypt) give an empty list.
xCerts = secEnvironment->getAllCertificates();
for (sal_Int32 nCert = xCerts.getLength(); nCert;)
{
uno::Reference< security::XCertificate > xCert = xCerts[ --nCert ]; // Check if we have a private key for this...
tools::Long nCertificateCharacters = secEnvironment->getCertificateCharacters(xCert);
// fill list of certificates; the first entry will be selected for (constauto& xCert : xCerts)
{
std::shared_ptr<CertificateChooserUserData> userData = std::make_shared<CertificateChooserUserData>();
userData->xCertificate = xCert;
userData->xSecurityContext = secContext;
userData->xSecurityEnvironment = secEnvironment;
// Needed to keep userData alive. (reference to shared_ptr prevents delete)
mvUserData.push_back(userData);
// If we are searching and there is no match skip if (mbSearch
&& rCharClass.uppercase(sIssuer).indexOf(aSearchStr) < 0
&& !aSearchStr.isEmpty()) continue;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.