blob: f9886c0182be3aeae8b61f526ae96a66ac6a0c7f (
plain) (
blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#include <Access/Credentials.h>
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
Credentials::Credentials(const String & user_name_)
: user_name(user_name_)
{
}
const String & Credentials::getUserName() const
{
if (!isReady())
throwNotReady();
return user_name;
}
bool Credentials::isReady() const
{
return is_ready;
}
void Credentials::throwNotReady()
{
throw Exception(ErrorCodes::LOGICAL_ERROR, "Credentials are not ready");
}
AlwaysAllowCredentials::AlwaysAllowCredentials()
{
is_ready = true;
}
AlwaysAllowCredentials::AlwaysAllowCredentials(const String & user_name_)
: Credentials(user_name_)
{
is_ready = true;
}
void AlwaysAllowCredentials::setUserName(const String & user_name_)
{
user_name = user_name_;
}
SSLCertificateCredentials::SSLCertificateCredentials(const String & user_name_, const String & common_name_)
: Credentials(user_name_)
, common_name(common_name_)
{
is_ready = true;
}
const String & SSLCertificateCredentials::getCommonName() const
{
if (!isReady())
throwNotReady();
return common_name;
}
BasicCredentials::BasicCredentials()
{
is_ready = true;
}
BasicCredentials::BasicCredentials(const String & user_name_)
: Credentials(user_name_)
{
is_ready = true;
}
BasicCredentials::BasicCredentials(const String & user_name_, const String & password_)
: Credentials(user_name_)
, password(password_)
{
is_ready = true;
}
void BasicCredentials::setUserName(const String & user_name_)
{
user_name = user_name_;
}
void BasicCredentials::setPassword(const String & password_)
{
password = password_;
}
const String & BasicCredentials::getPassword() const
{
if (!isReady())
throwNotReady();
return password;
}
}
|