Commit c4e98668 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Rewrite configuration of directory services for X.509

Adds support for using service running on the users' Active Directory
and for other new X.509 keyserver options added to GnuPG 2.2.18.

GnuPG-bug-id: 5465
parent 49c1ed8a
......@@ -86,10 +86,6 @@ target_sources(KF5Libkleo PRIVATE # make this a separate lib.
ui/keyselectioncombo.cpp
)
ki18n_wrap_ui(KF5Libkleo
ui/directoryserviceswidget.ui
)
target_link_libraries(KF5Libkleo PUBLIC QGpgme Gpgmepp PRIVATE Qt::Widgets
KF5::I18n
......
......@@ -13,6 +13,8 @@
#include "kdhorizontalline.h"
#include "filenamerequester.h"
#include "kleo/keyserverconfig.h"
#include <qgpgme/cryptoconfig.h>
#include <KLineEdit>
......@@ -902,19 +904,23 @@ void Kleo::CryptoConfigEntryLDAPURL::slotOpenDialog()
// I'm a bad boy and I do it all on the stack. Enough classes already :)
// This is just a simple dialog around the directory-services-widget
QDialog dialog(mPushButton->parentWidget());
dialog.setWindowTitle(i18nc("@title:window", "Configure LDAP Servers"));
dialog.setWindowTitle(i18nc("@title:window", "Configure Directory Services"));
auto dirserv = new DirectoryServicesWidget(&dialog);
prepareURLCfgDialog(&dialog, dirserv, mEntry->isReadOnly());
dirserv->setX509ReadOnly(mEntry->isReadOnly());
dirserv->setAllowedSchemes(DirectoryServicesWidget::LDAP);
dirserv->setAllowedProtocols(DirectoryServicesWidget::X509Protocol);
dirserv->addX509Services(mURLList);
dirserv->setReadOnly(mEntry->isReadOnly());
std::vector<KeyserverConfig> servers;
std::transform(std::cbegin(mURLList), std::cend(mURLList), std::back_inserter(servers), [](const auto &url) { return KeyserverConfig::fromUrl(url); });
dirserv->setKeyservers(servers);
if (dialog.exec()) {
setURLList(dirserv->x509Services());
QList<QUrl> urls;
const auto servers = dirserv->keyservers();
std::transform(std::begin(servers), std::end(servers), std::back_inserter(urls), [](const auto &server) { return server.toUrl(); });
setURLList(urls);
slotChanged();
}
}
......
This diff is collapsed.
/*
directoryserviceswidget.h
ui/directoryserviceswidget.h
This file is part of Kleopatra, the KDE keymanager
This file is part of libkleopatra, the KDE keymanagement library
SPDX-FileCopyrightText: 2001, 2002, 2004 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -10,53 +12,27 @@
#pragma once
#include "kleo_export.h"
#include <QUrl>
#include <QWidget>
#include <memory>
#include <vector>
namespace Kleo
{
class KeyserverConfig;
class KLEO_EXPORT DirectoryServicesWidget : public QWidget
{
Q_OBJECT
public:
explicit DirectoryServicesWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {});
~DirectoryServicesWidget();
enum Scheme {
NoScheme = 0,
HKP = 1,
HTTP = 2,
FTP = 4,
LDAP = 8,
AllSchemes = HKP | HTTP | FTP | LDAP
};
Q_DECLARE_FLAGS(Schemes, Scheme)
enum Protocol {
NoProtocol = 0,
X509Protocol = 1,
AllProtocols = X509Protocol
};
Q_DECLARE_FLAGS(Protocols, Protocol)
void setAllowedSchemes(Schemes schemes);
Schemes allowedSchemes() const;
void setAllowedProtocols(Protocols protocols);
Protocols allowedProtocols() const;
void setX509Allowed(bool allowed);
explicit DirectoryServicesWidget(QWidget *parent = nullptr);
~DirectoryServicesWidget() override;
void setReadOnlyProtocols(Protocols protocols);
Protocols readOnlyProtocols() const;
void setKeyservers(const std::vector<KeyserverConfig> &keyservers);
std::vector<KeyserverConfig> keyservers() const;
void setX509ReadOnly(bool ro);
void addX509Services(const QList<QUrl> &urls);
QList<QUrl> x509Services() const;
void setReadOnly(bool readOnly);
public Q_SLOTS:
void clear();
......@@ -66,30 +42,7 @@ Q_SIGNALS:
private:
class Private;
Private *const d;
Q_PRIVATE_SLOT(d, void slotNewX509Clicked())
Q_PRIVATE_SLOT(d, void slotDeleteClicked())
Q_PRIVATE_SLOT(d, void slotSelectionChanged())
Q_PRIVATE_SLOT(d, void slotShowUserAndPasswordToggled(bool))
const std::unique_ptr<Private> d;
};
}
inline void Kleo::DirectoryServicesWidget::setX509Allowed(bool allowed)
{
if (allowed) {
setAllowedProtocols(allowedProtocols() | X509Protocol);
} else {
setAllowedProtocols(allowedProtocols() & ~X509Protocol);
}
}
inline void Kleo::DirectoryServicesWidget::setX509ReadOnly(bool ro)
{
if (ro) {
setReadOnlyProtocols(readOnlyProtocols() | X509Protocol);
} else {
setReadOnlyProtocols(readOnlyProtocols() & ~X509Protocol);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DirectoryServicesWidget</class>
<widget class="QWidget" name="DirectoryServicesWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>363</height>
</rect>
</property>
<property name="windowTitle">
<string>Directory Services Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="x500LA">
<property name="title">
<string>X509 Directory services:</string>
</property>
<layout class="QVBoxLayout" name="grpVbox">
<item>
<layout class="QHBoxLayout" name="grpVboxhorizontalLayout">
<item>
<widget class="QTreeView" name="treeView">
<property name="whatsThis">
<string>This is a list of all directory services that are configured for use with X.509.</string>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="vlay">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="newTB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Click to add a service</string>
</property>
<property name="whatsThis">
<string>Click this button to create a new directory service entry as a clone of the currently selected one (or with default values, if no other is selected). You can then configure details in the table on the left hand.</string>
</property>
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="deleteTB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Click to remove the currently selected service</string>
</property>
<property name="whatsThis">
<string>Click this button to remove the currently selected directory service. The change will only take effect once you acknowledge the main configuration dialog.</string>
</property>
<property name="text">
<string>Delete</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>51</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="showUserAndPasswordCB">
<property name="whatsThis">
<string>Use this option to switch display of username and password information on or off in the above table.</string>
</property>
<property name="text">
<string>Show user and password information</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>newTB</sender>
<signal>clicked()</signal>
<receiver>DirectoryServicesWidget</receiver>
<slot>slotNewX509Clicked()</slot>
<hints>
<hint type="sourcelabel">
<x>535</x>
<y>57</y>
</hint>
<hint type="destinationlabel">
<x>571</x>
<y>55</y>
</hint>
</hints>
</connection>
<connection>
<sender>deleteTB</sender>
<signal>clicked()</signal>
<receiver>DirectoryServicesWidget</receiver>
<slot>slotDeleteClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>537</x>
<y>95</y>
</hint>
<hint type="destinationlabel">
<x>575</x>
<y>95</y>
</hint>
</hints>
</connection>
<connection>
<sender>showUserAndPasswordCB</sender>
<signal>toggled(bool)</signal>
<receiver>DirectoryServicesWidget</receiver>
<slot>slotShowUserAndPasswordToggled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>314</x>
<y>341</y>
</hint>
<hint type="destinationlabel">
<x>342</x>
<y>357</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slotNewX509Clicked()</slot>
<slot>slotDeleteClicked()</slot>
<slot>slotShowUserAndPasswordToggled(bool)</slot>
</slots>
</ui>
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