~drizzle-trunk/drizzle/development

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
23
#include <string>
24
#include <boost/shared_ptr.hpp>
2252.1.10 by Olaf van der Spek
Common fwd
25
#include <drizzled/common_fwd.h>
2241.2.4 by Olaf van der Spek
Refactor
26
#include <drizzled/identifier.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
27
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
28
2241.2.4 by Olaf van der Spek
Refactor
29
namespace drizzled {
30
namespace identifier {
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
31
32
/**
33
  @class User
34
  @brief A set of Session members describing the current authenticated user.
35
*/
36
2041.3.15 by Brian Aker
Cleanup error usage around identifier usage.
37
class User : public Identifier
38
{
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
39
public:
2252.1.10 by Olaf van der Spek
Common fwd
40
  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
41
42
  enum PasswordType
43
  {
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
44
    NONE,
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
45
    PLAIN_TEXT,
46
    MYSQL_HASH
47
  };
48
49
  User():
2241.2.4 by Olaf van der Spek
Refactor
50
    password_type(NONE)
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
51
  { }
52
2246.4.2 by Olaf van der Spek
Refactor Identifier::getSQLPath()
53
  virtual std::string getSQLPath() const
54
	{
55
		return _user.empty() ? "<no user>" : _user;
56
	}
2041.3.15 by Brian Aker
Cleanup error usage around identifier usage.
57
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
58
  bool hasPassword() const
59
  {
2241.2.5 by Olaf van der Spek
Refactor
60
    return password_type != NONE;
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
61
  }
62
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
63
  const std::string& address() const
64
  {
65
    return _address;
66
  }
67
68
  void setAddress(const char *newip)
69
  {
2241.2.5 by Olaf van der Spek
Refactor
70
    _address = newip;
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
71
  }
72
73
  const std::string& username() const
74
  {
75
    return _user;
76
  }
77
78
  void setUser(const std::string &newuser)
79
  {
2241.2.5 by Olaf van der Spek
Refactor
80
    _user = newuser;
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
81
  }
82
2241.2.5 by Olaf van der Spek
Refactor
83
  PasswordType getPasswordType() const
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
84
  {
85
    return password_type;
86
  }
87
88
  void setPasswordType(PasswordType newpassword_type)
89
  {
90
    password_type= newpassword_type;
91
  }
92
93
  const std::string& getPasswordContext() const
94
  {
95
    return password_context;
96
  }
97
98
  void setPasswordContext(const char *newpassword_context, size_t size)
99
  {
100
    password_context.assign(newpassword_context, size);
101
  }
102
103
private:
104
  PasswordType password_type;
105
  std::string _user;
106
  std::string _address;
107
  std::string password_context;
108
};
109
110
} /* namespace identifier */
111
} /* namespace drizzled */