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 <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 } /* namespace identifier */
00123 } /* namespace drizzled */