~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
21
22
#ifndef DRIZZLED_IDENTIFIER_USER_H
23
#define DRIZZLED_IDENTIFIER_USER_H
24
25
#include <string>
26
#include <boost/shared_ptr.hpp>
27
28
namespace drizzled
29
{
30
namespace identifier
31
{
32
33
/**
34
  @class User
35
  @brief A set of Session members describing the current authenticated user.
36
*/
37
38
class User {
39
public:
40
  typedef boost::shared_ptr<User> shared_ptr;
41
  typedef boost::shared_ptr<const User> const_shared_ptr;
42
  static shared_ptr make_shared();
43
44
  enum PasswordType
45
  {
46
    PLAIN_TEXT,
47
    MYSQL_HASH
48
  };
49
50
  User():
51
    password_type(PLAIN_TEXT),
52
    _user(""),
53
    _address("")
54
  { }
55
56
  const std::string& address() const
57
  {
58
    return _address;
59
  }
60
61
  void setAddress(const char *newip)
62
  {
63
    _address.assign(newip);
64
  }
65
66
  const std::string& username() const
67
  {
68
    return _user;
69
  }
70
71
  void setUser(const std::string &newuser)
72
  {
73
    _user.assign(newuser);
74
  }
75
76
  PasswordType getPasswordType(void) const
77
  {
78
    return password_type;
79
  }
80
81
  void setPasswordType(PasswordType newpassword_type)
82
  {
83
    password_type= newpassword_type;
84
  }
85
86
  const std::string& getPasswordContext() const
87
  {
88
    return password_context;
89
  }
90
91
  void setPasswordContext(const char *newpassword_context, size_t size)
92
  {
93
    password_context.assign(newpassword_context, size);
94
  }
95
96
private:
97
  PasswordType password_type;
98
  std::string _user;
99
  std::string _address;
100
  std::string password_context;
101
};
102
103
} /* namespace identifier */
104
} /* namespace drizzled */
105
106
#endif /* DRIZZLED_IDENTIFIER_USER_H */