00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <string>
00024 #include <boost/shared_ptr.hpp>
00025
00026 #include <drizzled/visibility.h>
00027
00028 namespace drizzled
00029 {
00030 namespace identifier
00031 {
00032
00038 class User : public Identifier
00039 {
00040 public:
00041 typedef boost::shared_ptr<User> shared_ptr;
00042 typedef boost::shared_ptr<const User> const_shared_ptr;
00043 typedef const User& const_reference;
00044 DRIZZLED_API static shared_ptr make_shared();
00045
00046 enum PasswordType
00047 {
00048 NONE,
00049 PLAIN_TEXT,
00050 MYSQL_HASH
00051 };
00052
00053 User():
00054 password_type(NONE),
00055 _user(""),
00056 _address("")
00057 { }
00058
00059 virtual void getSQLPath(std::string &arg) const;
00060
00061 bool hasPassword() const
00062 {
00063 switch (password_type)
00064 {
00065 case NONE:
00066 return false;
00067 case PLAIN_TEXT:
00068 case MYSQL_HASH:
00069 break;
00070 }
00071
00072 return true;
00073 }
00074
00075 const std::string& address() const
00076 {
00077 return _address;
00078 }
00079
00080 void setAddress(const char *newip)
00081 {
00082 _address.assign(newip);
00083 }
00084
00085 const std::string& username() const
00086 {
00087 return _user;
00088 }
00089
00090 void setUser(const std::string &newuser)
00091 {
00092 _user.assign(newuser);
00093 }
00094
00095 PasswordType getPasswordType(void) const
00096 {
00097 return password_type;
00098 }
00099
00100 void setPasswordType(PasswordType newpassword_type)
00101 {
00102 password_type= newpassword_type;
00103 }
00104
00105 const std::string& getPasswordContext() const
00106 {
00107 return password_context;
00108 }
00109
00110 void setPasswordContext(const char *newpassword_context, size_t size)
00111 {
00112 password_context.assign(newpassword_context, size);
00113 }
00114
00115 private:
00116 PasswordType password_type;
00117 std::string _user;
00118 std::string _address;
00119 std::string password_context;
00120 };
00121
00122 }
00123 }