drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled/identifier/user.h
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
21#pragma once
22
23#include <drizzled/common_fwd.h>
24#include <drizzled/identifier.h>
25
26namespace drizzled {
27namespace identifier {
28
33
34class User : public Identifier
35{
36public:
37 DRIZZLED_API static user::mptr make_shared();
38
39 enum PasswordType
40 {
41 NONE,
42 PLAIN_TEXT,
43 MYSQL_HASH
44 };
45
46 User() :
47 password_type(NONE)
48 { }
49
50 User(str_ref user_arg) :
51 password_type(NONE),
52 _user(to_string(user_arg))
53 { }
54
55 virtual std::string getSQLPath() const
56 {
57 return _user.empty() ? "<no user>" : _user;
58 }
59
60 bool hasPassword() const
61 {
62 return password_type != NONE;
63 }
64
65 const std::string& address() const
66 {
67 return _address;
68 }
69
70 void setAddress(const char *newip)
71 {
72 _address = newip;
73 }
74
75 const std::string& username() const
76 {
77 return _user;
78 }
79
80 void setUser(const std::string &newuser)
81 {
82 _user = newuser;
83 }
84
85 PasswordType getPasswordType() const
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
105private:
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 */
TODO: Rename this file - func.h is stupid.
#define DRIZZLED_API
Definition visibility.h:38