2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2010 Brian Aker
|
|
5 |
* Copyright (C) 2008 Sun Microsystems
|
|
6 |
*
|
|
7 |
* This program is free software; you can redistribute it and/or modify
|
|
8 |
* it under the terms of the GNU General Public License as published by
|
|
9 |
* the Free Software Foundation; version 2 of the License.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
20 |
||
2200
by Brian Aker
Testing pragma once for build farm. |
21 |
#pragma once
|
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
22 |
|
2252.1.10
by Olaf van der Spek
Common fwd |
23 |
#include <drizzled/common_fwd.h> |
2241.2.4
by Olaf van der Spek
Refactor |
24 |
#include <drizzled/identifier.h> |
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
25 |
|
2241.2.4
by Olaf van der Spek
Refactor |
26 |
namespace drizzled { |
27 |
namespace identifier { |
|
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
28 |
|
29 |
/**
|
|
30 |
@class User
|
|
31 |
@brief A set of Session members describing the current authenticated user.
|
|
32 |
*/
|
|
33 |
||
2041.3.15
by Brian Aker
Cleanup error usage around identifier usage. |
34 |
class User : public Identifier |
35 |
{
|
|
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
36 |
public: |
2252.1.10
by Olaf van der Spek
Common fwd |
37 |
DRIZZLED_API static user::mptr make_shared(); |
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
38 |
|
39 |
enum PasswordType |
|
40 |
{
|
|
2159.2.8
by Brian Aker
Merge in fixes for error messages with privs. |
41 |
NONE, |
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
42 |
PLAIN_TEXT, |
43 |
MYSQL_HASH
|
|
44 |
};
|
|
45 |
||
2440.2.28
by Olaf van der Spek
Refactor |
46 |
User() : |
2241.2.4
by Olaf van der Spek
Refactor |
47 |
password_type(NONE) |
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
48 |
{ } |
49 |
||
2440.2.28
by Olaf van der Spek
Refactor |
50 |
User(str_ref user_arg) : |
2241.6.2
by Brian Aker
This adds the concept of a definer to a table definition. |
51 |
password_type(NONE), |
2440.2.28
by Olaf van der Spek
Refactor |
52 |
_user(to_string(user_arg)) |
2241.6.2
by Brian Aker
This adds the concept of a definer to a table definition. |
53 |
{ } |
54 |
||
2246.4.2
by Olaf van der Spek
Refactor Identifier::getSQLPath() |
55 |
virtual std::string getSQLPath() const |
2263.2.2
by Brian Aker
Merge in owner tree. |
56 |
{
|
57 |
return _user.empty() ? "<no user>" : _user; |
|
58 |
}
|
|
2041.3.15
by Brian Aker
Cleanup error usage around identifier usage. |
59 |
|
2159.2.8
by Brian Aker
Merge in fixes for error messages with privs. |
60 |
bool hasPassword() const |
61 |
{
|
|
2241.2.5
by Olaf van der Spek
Refactor |
62 |
return password_type != NONE; |
2159.2.8
by Brian Aker
Merge in fixes for error messages with privs. |
63 |
}
|
64 |
||
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
65 |
const std::string& address() const |
66 |
{
|
|
67 |
return _address; |
|
68 |
}
|
|
69 |
||
70 |
void setAddress(const char *newip) |
|
71 |
{
|
|
2241.2.5
by Olaf van der Spek
Refactor |
72 |
_address = newip; |
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
73 |
}
|
74 |
||
75 |
const std::string& username() const |
|
76 |
{
|
|
77 |
return _user; |
|
78 |
}
|
|
79 |
||
80 |
void setUser(const std::string &newuser) |
|
81 |
{
|
|
2241.2.5
by Olaf van der Spek
Refactor |
82 |
_user = newuser; |
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
83 |
}
|
84 |
||
2241.2.5
by Olaf van der Spek
Refactor |
85 |
PasswordType getPasswordType() const |
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
86 |
{
|
87 |
return password_type; |
|
88 |
}
|
|
89 |
||
90 |
void setPasswordType(PasswordType newpassword_type) |
|
91 |
{
|
|
92 |
password_type= newpassword_type; |
|
93 |
}
|
|
94 |
||
95 |
const std::string& getPasswordContext() const |
|
96 |
{
|
|
97 |
return password_context; |
|
98 |
}
|
|
99 |
||
100 |
void setPasswordContext(const char *newpassword_context, size_t size) |
|
101 |
{
|
|
102 |
password_context.assign(newpassword_context, size); |
|
103 |
}
|
|
104 |
||
105 |
private: |
|
106 |
PasswordType password_type; |
|
107 |
std::string _user; |
|
108 |
std::string _address; |
|
109 |
std::string password_context; |
|
110 |
};
|
|
111 |
||
112 |
} /* namespace identifier */ |
|
113 |
} /* namespace drizzled */ |