11#include "ldap_core_debug.h"
13using namespace KLDAPCore;
15class Q_DECL_HIDDEN
LdapServer::LdapServerPrivate
34 QString mTLSCACertFile;
35 TLSRequireCertificate mTLSRequireCertificate;
37 int mCompletionWeight = -1;
38 QStringList mActivities;
39 bool mEnablePlasmaActivities =
false;
43 : d(new LdapServerPrivate)
49 : d(new LdapServerPrivate)
57 : d(new LdapServerPrivate)
85 d->mTLSRequireCertificate = TLSReqCertDefault;
86 d->mTLSCACertFile.clear();
89 d->mSizeLimit = d->mTimeLimit = d->mPageSize = 0;
90 d->mCompletionWeight = -1;
91 d->mActivities.clear();
92 d->mEnablePlasmaActivities =
false;
142 return d->mTimeLimit;
147 return d->mSizeLimit;
172 return d->mTLSRequireCertificate;
177 return d->mTLSCACertFile;
227 d->mTimeLimit = timelimit;
232 d->mSizeLimit = sizelimit;
237 d->mPageSize = pagesize;
267 d->mTLSRequireCertificate = reqCert;
272 d->mTLSCACertFile = caCertFile;
287 bool critical =
true;
289 d->mHost =
url.host();
296 d->mBaseDn =
url.dn();
297 d->mScope =
url.scope();
299 d->mFilter =
url.filter();
302 if (
url.scheme() ==
"ldaps"_L1) {
304 }
else if (
url.hasExtension(QStringLiteral(
"x-tls"))) {
307 qCDebug(LDAP_CORE_LOG) <<
"security:" << d->mSecurity;
312 if (
url.hasExtension(QStringLiteral(
"x-sasl"))) {
314 if (
url.hasExtension(QStringLiteral(
"x-mech"))) {
315 d->mMech =
url.extension(QStringLiteral(
"x-mech"), critical);
317 if (
url.hasExtension(QStringLiteral(
"x-realm"))) {
318 d->mRealm =
url.extension(QStringLiteral(
"x-realm"), critical);
320 if (
url.hasExtension(QStringLiteral(
"bindname"))) {
321 d->mBindDn =
url.extension(QStringLiteral(
"bindname"), critical);
323 d->mUser =
url.userName();
324 }
else if (
url.hasExtension(QStringLiteral(
"bindname"))) {
326 d->mBindDn =
url.extension(QStringLiteral(
"bindname"), critical);
329 if (
user.isEmpty()) {
330 d->mAuth = Anonymous;
336 d->mPassword =
url.password();
337 if (
url.hasExtension(QStringLiteral(
"x-version"))) {
338 d->mVersion =
url.extension(QStringLiteral(
"x-version"), critical).toInt();
343 if (
url.hasExtension(QStringLiteral(
"x-timeout"))) {
344 d->mTimeout =
url.extension(QStringLiteral(
"x-timeout"), critical).toInt();
349 if (
url.hasExtension(QStringLiteral(
"x-timelimit"))) {
350 d->mTimeLimit =
url.extension(QStringLiteral(
"x-timelimit"), critical).toInt();
355 if (
url.hasExtension(QStringLiteral(
"x-sizelimit"))) {
356 d->mSizeLimit =
url.extension(QStringLiteral(
"x-sizelimit"), critical).toInt();
361 if (
url.hasExtension(QStringLiteral(
"x-pagesize"))) {
362 d->mPageSize =
url.extension(QStringLiteral(
"x-pagesize"), critical).toInt();
371 url.setScheme(d->mSecurity == SSL ? QStringLiteral(
"ldaps") : QStringLiteral(
"ldap"));
372 url.setPort(d->mPort);
373 url.setHost(d->mHost);
374 url.setDn(d->mBaseDn);
375 url.setFilter(d->mFilter);
376 url.setScope(d->mScope);
377 if (d->mAuth == SASL) {
378 url.setUserName(d->mUser);
379 url.setPassword(d->mPassword);
380 url.setExtension(QStringLiteral(
"bindname"), d->mBindDn,
true);
381 url.setExtension(QStringLiteral(
"x-sasl"),
QString());
382 if (!d->mMech.isEmpty()) {
383 url.setExtension(QStringLiteral(
"x-mech"), d->mMech);
385 if (!d->mRealm.isEmpty()) {
386 url.setExtension(QStringLiteral(
"x-realm"), d->mRealm);
388 }
else if (d->mAuth == Simple) {
389 url.setUserName(d->mBindDn);
390 url.setPassword(d->mPassword);
392 if (d->mVersion == 2) {
393 url.setExtension(QStringLiteral(
"x-version"), d->mVersion);
396 url.setExtension(QStringLiteral(
"x-timeout"), d->mTimeout);
398 if (d->mTimeLimit != 0) {
399 url.setExtension(QStringLiteral(
"x-timelimit"), d->mTimeLimit);
401 if (d->mSizeLimit != 0) {
402 url.setExtension(QStringLiteral(
"x-sizelimit"), d->mSizeLimit);
404 if (d->mPageSize != 0) {
405 url.setExtension(QStringLiteral(
"x-pagesize"), d->mPageSize);
407 if (d->mSecurity == TLS) {
408 url.setExtension(QStringLiteral(
"x-tls"), 1,
true);
413void LdapServer::setCompletionWeight(
int value)
415 d->mCompletionWeight = value;
418int LdapServer::completionWeight()
const
420 return d->mCompletionWeight;
423void LdapServer::setActivities(
const QStringList &lst)
425 d->mActivities = lst;
428QStringList LdapServer::activities()
const
430 return d->mActivities;
433void LdapServer::setEnablePlasmaActivities(
bool enabled)
435 d->mEnablePlasmaActivities = enabled;
438bool LdapServer::enablePlasmaActivities()
const
440 return d->mEnablePlasmaActivities;
443QDebug
operator<<(QDebug d,
const KLDAPCore::LdapServer &t)
445 d <<
"port " << t.
port();
446 d <<
"host " << t.
host();
447 d <<
"user " << t.
user();
448 d <<
"bindDn " << t.
bindDn();
449 d <<
"mech " << t.
mech();
451 d <<
"auth " << t.
auth();
454 d <<
"version " << t.
version();
455 d <<
"completionWeight " << t.completionWeight();
456 d <<
"timeout " << t.
timeout();
459 d <<
"activities " << t.activities();
460 d <<
"enablePlasmaActivities " << t.enablePlasmaActivities();
A class that contains LDAP server connection settings.
QString realm() const
Returns the realm of the LDAP connection.
void setHost(const QString &host)
Sets the host of the LDAP connection.
void setTimeout(int timeout)
Sets the timeout of the LDAP connection.
enum { None, TLS, SSL } Security
Describes the encryption settings that can be used for the LDAP connection.
void setMech(const QString &mech)
Sets the mech of the LDAP connection.
Security security() const
Returns the security mode of the LDAP connection.
void setSecurity(Security mode)
Sets the security mode of the LDAP connection.
void setSizeLimit(int sizelimit)
Sets the size limit of the LDAP connection.
LdapServer()
Creates an empty LDAP server object.
void setTLSCACertFile(const QString &caCertFile)
Sets the CA certificate file for TLS/SSL connections.
enum { TLSReqCertDefault, TLSReqCertNever, TLSReqCertDemand, TLSReqCertAllow, TLSReqCertTry, TLSReqCertHard, } TLSRequireCertificate
Describes the certificate request and check behaviour for TLS/SSL connections.
void setTLSRequireCertificate(TLSRequireCertificate reqCert)
Sets the certificate require mode for TLS/SSL connections.
LdapUrl url() const
Returns the server parameters as an RFC2255 compliant LDAP Url.
QString filter() const
Returns the filter string of the LDAP connection.
void setVersion(int version)
Sets the protocol version of the LDAP connection.
LdapDN baseDn() const
Returns the baseDn of the LDAP connection.
int timeout() const
Returns the timeout of the LDAP connection.
enum { Anonymous, Simple, SASL } Auth
Describes the authentication method that can be used for the LDAP connection.
void setPassword(const QString &password)
Sets the password of the LDAP connection.
void setScope(LdapUrl::Scope scope)
Sets the search scope of the LDAP connection.
int timeLimit() const
Returns the time limit of the LDAP connection.
void setUser(const QString &user)
Sets the user of the LDAP connection.
QString password() const
Returns the password of the LDAP connection.
QString bindDn() const
Returns the bindDn of the LDAP connection.
void setTimeLimit(int limit)
Sets the time limit of the LDAP connection.
~LdapServer()
Destroys the LDAP server object.
void setRealm(const QString &realm)
Sets the realm of the LDAP connection.
int version() const
Returns the protocol version of the LDAP connection.
void setUrl(const LdapUrl &url)
Sets the server parameters from an RFC2255 compliant LDAP url.
void setAuth(Auth authentication)
Sets the authentication method of the LDAP connection.
QString tlsCACertFile() const
Returns the CA certificate file used for TLS/SSL connections.
int port() const
Returns the port of the LDAP connection.
int sizeLimit() const
Returns the size limit of the LDAP connection.
void setPageSize(int size)
Sets the page size of the LDAP connection.
QString host() const
Returns the host of the LDAP connection.
int pageSize() const
Returns the page size of the LDAP connection.
void setBindDn(const QString &bindDn)
Sets the bindDn of the LDAP connection.
void setBaseDn(const LdapDN &baseDn)
Sets the baseDn of the LDAP connection.
QString user() const
Returns the user of the LDAP connection.
LdapServer & operator=(const LdapServer &other)
Overwrites the values of the LDAP server object with the values from an other object.
Auth auth() const
Returns the authentication method of the LDAP connection.
void clear()
Clears all server settings.
void setPort(int port)
Sets the port of the LDAP connection.
QString mech() const
Returns the mech of the LDAP connection.
LdapUrl::Scope scope() const
Returns the search scope of the LDAP connection.
void setFilter(const QString &filter)
Sets the filter string of the LDAP connection.
TLSRequireCertificate tlsRequireCertificate() const
Returns the certificate require mode for TLS/SSL connections.
A special url class for LDAP.
enum { Base, One, Sub } Scope
Describes the scope of the LDAP url.
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)