~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/user.h

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

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
#include <drizzled/visibility.h>
 
29
 
 
30
namespace drizzled
 
31
{
 
32
namespace identifier
 
33
{
 
34
 
 
35
/**
 
36
  @class User
 
37
  @brief A set of Session members describing the current authenticated user.
 
38
*/
 
39
 
 
40
class User : public Identifier
 
41
{
 
42
public:
 
43
  typedef boost::shared_ptr<User> shared_ptr;
 
44
  typedef boost::shared_ptr<const User> const_shared_ptr;
 
45
  typedef const User& const_reference;
 
46
  DRIZZLED_API static shared_ptr make_shared();
 
47
 
 
48
  enum PasswordType
 
49
  {
 
50
    NONE,
 
51
    PLAIN_TEXT,
 
52
    MYSQL_HASH
 
53
  };
 
54
 
 
55
  User():
 
56
    password_type(NONE),
 
57
    _user(""),
 
58
    _address("")
 
59
  { }
 
60
 
 
61
  virtual void getSQLPath(std::string &arg) const;
 
62
 
 
63
  bool hasPassword() const
 
64
  {
 
65
    switch (password_type)
 
66
    {
 
67
    case NONE:
 
68
      return false;
 
69
    case PLAIN_TEXT:
 
70
    case MYSQL_HASH:
 
71
      break;
 
72
    }
 
73
 
 
74
    return true;
 
75
  }
 
76
 
 
77
  const std::string& address() const
 
78
  {
 
79
    return _address;
 
80
  }
 
81
 
 
82
  void setAddress(const char *newip)
 
83
  {
 
84
    _address.assign(newip);
 
85
  }
 
86
 
 
87
  const std::string& username() const
 
88
  {
 
89
    return _user;
 
90
  }
 
91
 
 
92
  void setUser(const std::string &newuser)
 
93
  {
 
94
    _user.assign(newuser);
 
95
  }
 
96
 
 
97
  PasswordType getPasswordType(void) const
 
98
  {
 
99
    return password_type;
 
100
  }
 
101
 
 
102
  void setPasswordType(PasswordType newpassword_type)
 
103
  {
 
104
    password_type= newpassword_type;
 
105
  }
 
106
 
 
107
  const std::string& getPasswordContext() const
 
108
  {
 
109
    return password_context;
 
110
  }
 
111
 
 
112
  void setPasswordContext(const char *newpassword_context, size_t size)
 
113
  {
 
114
    password_context.assign(newpassword_context, size);
 
115
  }
 
116
 
 
117
private:
 
118
  PasswordType password_type;
 
119
  std::string _user;
 
120
  std::string _address;
 
121
  std::string password_context;
 
122
};
 
123
 
 
124
} /* namespace identifier */
 
125
} /* namespace drizzled */
 
126
 
 
127
#endif /* DRIZZLED_IDENTIFIER_USER_H */