File: smbauthenticator.h

package info (click to toggle)
kio-extras 4%3A25.04.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 31,928 kB
  • sloc: cpp: 28,852; ansic: 3,084; perl: 1,048; xml: 116; sh: 92; python: 28; makefile: 9
file content (49 lines) | stat: -rw-r--r-- 1,254 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
/*
    SPDX-License-Identifier: GPL-2.0-or-later
    SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
*/

#pragma once

#include "smbcontext.h"

#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);

    // Callback for authentication requests.
    void
    auth(SMBCCTX *context, 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)
};