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 <drizzled/common_fwd.h>
00024 #include <drizzled/identifier.h>
00025
00026 namespace drizzled {
00027 namespace identifier {
00028
00034 class User : public Identifier
00035 {
00036 public:
00037 DRIZZLED_API static user::mptr make_shared();
00038
00039 enum PasswordType
00040 {
00041 NONE,
00042 PLAIN_TEXT,
00043 MYSQL_HASH
00044 };
00045
00046 User() :
00047 password_type(NONE)
00048 { }
00049
00050 User(str_ref user_arg) :
00051 password_type(NONE),
00052 _user(to_string(user_arg))
00053 { }
00054
00055 virtual std::string getSQLPath() const
00056 {
00057 return _user.empty() ? "<no user>" : _user;
00058 }
00059
00060 bool hasPassword() const
00061 {
00062 return password_type != NONE;
00063 }
00064
00065 const std::string& address() const
00066 {
00067 return _address;
00068 }
00069
00070 void setAddress(const char *newip)
00071 {
00072 _address = newip;
00073 }
00074
00075 const std::string& username() const
00076 {
00077 return _user;
00078 }
00079
00080 void setUser(const std::string &newuser)
00081 {
00082 _user = newuser;
00083 }
00084
00085 PasswordType getPasswordType() const
00086 {
00087 return password_type;
00088 }
00089
00090 void setPasswordType(PasswordType newpassword_type)
00091 {
00092 password_type= newpassword_type;
00093 }
00094
00095 const std::string& getPasswordContext() const
00096 {
00097 return password_context;
00098 }
00099
00100 void setPasswordContext(const char *newpassword_context, size_t size)
00101 {
00102 password_context.assign(newpassword_context, size);
00103 }
00104
00105 private:
00106 PasswordType password_type;
00107 std::string _user;
00108 std::string _address;
00109 std::string password_context;
00110 };
00111
00112 }
00113 }