File: smbauthenticator.h

package info (click to toggle)
kio-extras 4%3A22.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,768 kB
  • sloc: cpp: 26,898; ansic: 4,443; perl: 1,058; xml: 97; sh: 69; python: 28; makefile: 9
file content (51 lines) | stat: -rw-r--r-- 1,331 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
    SPDX-License-Identifier: GPL-2.0-or-later
    SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
*/

#pragma once

#include <QString>

namespace KIO {
class AuthInfo;
}

// Abstracts WorkerBase API so Authenticator may be used without
// a WorkerBase for the KDirNotify implementation)
class SMBAbstractFrontend
{
public:
    virtual ~SMBAbstractFrontend() = default;
    virtual bool checkCachedAuthentication(KIO::AuthInfo &info) = 0;
};

// Base class for SMBC management + basic authentication
class SMBAuthenticator
{
public:
    SMBAuthenticator(SMBAbstractFrontend &frontend);

    QString defaultWorkgroup() const;
    void setDefaultWorkgroup(const QString &workGroup);

    // (Re)loads default values from configuration
    void loadConfiguration();

    // Callback for authentication requests.
    void auth(const char *server, const char *share,
              char *workgroup, int wgmaxlen,
              char *username, int unmaxlen,
              char *password, int pwmaxlen);

private:
    // Frontend for authentication requests.
    SMBAbstractFrontend &m_frontend;

    QString m_defaultUser;
    QString m_defaultPassword;
    QString m_defaultEncoding;
    QString m_defaultWorkgroup = QStringLiteral("WORKGROUP"); // overwritten with value from smbc

    Q_DISABLE_COPY(SMBAuthenticator)
};