~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/user.h

  • Committer: Stewart Smith
  • Date: 2011-01-14 05:18:23 UTC
  • mto: (2086.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2087.
  • Revision ID: stewart@flamingspork.com-20110114051823-14fyn2kvg8pc5a15
\r and trailing whitespace removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 : public Identifier
 
39
{
 
40
public:
 
41
  typedef boost::shared_ptr<User> shared_ptr;
 
42
  typedef boost::shared_ptr<const User> const_shared_ptr;
 
43
  typedef const User& const_reference;
 
44
  static shared_ptr make_shared();
 
45
 
 
46
  enum PasswordType
 
47
  {
 
48
    PLAIN_TEXT,
 
49
    MYSQL_HASH
 
50
  };
 
51
 
 
52
  User():
 
53
    password_type(PLAIN_TEXT),
 
54
    _user(""),
 
55
    _address("")
 
56
  { }
 
57
 
 
58
  virtual void getSQLPath(std::string &arg) const;
 
59
 
 
60
  const std::string& address() const
 
61
  {
 
62
    return _address;
 
63
  }
 
64
 
 
65
  void setAddress(const char *newip)
 
66
  {
 
67
    _address.assign(newip);
 
68
  }
 
69
 
 
70
  const std::string& username() const
 
71
  {
 
72
    return _user;
 
73
  }
 
74
 
 
75
  void setUser(const std::string &newuser)
 
76
  {
 
77
    _user.assign(newuser);
 
78
  }
 
79
 
 
80
  PasswordType getPasswordType(void) const
 
81
  {
 
82
    return password_type;
 
83
  }
 
84
 
 
85
  void setPasswordType(PasswordType newpassword_type)
 
86
  {
 
87
    password_type= newpassword_type;
 
88
  }
 
89
 
 
90
  const std::string& getPasswordContext() const
 
91
  {
 
92
    return password_context;
 
93
  }
 
94
 
 
95
  void setPasswordContext(const char *newpassword_context, size_t size)
 
96
  {
 
97
    password_context.assign(newpassword_context, size);
 
98
  }
 
99
 
 
100
private:
 
101
  PasswordType password_type;
 
102
  std::string _user;
 
103
  std::string _address;
 
104
  std::string password_context;
 
105
};
 
106
 
 
107
} /* namespace identifier */
 
108
} /* namespace drizzled */
 
109
 
 
110
#endif /* DRIZZLED_IDENTIFIER_USER_H */