Drizzled Public API Documentation

user.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
00005  *  Copyright (C) 2008 Sun Microsystems
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; version 2 of the License.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
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 } /* namespace identifier */
00113 } /* namespace drizzled */