00001 /* Copyright (c) 2006, Gennady Bystritsky <bystr@mac.com> 00002 * 00003 * Distributed under the MIT Licence. 00004 * This is free software. See 'LICENSE' for details. 00005 * You must read and accept the license prior to use. 00006 */ 00007 00008 #ifndef _SK_SYS_USER_ 00009 #define _SK_SYS_USER_ 00010 00011 #include <sk/util/Object.h> 00012 #include <sk/util/Holder.hxx> 00013 #include <sk/util/Processor.h> 00014 #include <sk/util/String.h> 00015 #include <sk/rt/Scope.h> 00016 00017 struct passwd; 00018 00019 namespace sk { 00020 namespace sys { 00021 class User 00022 : public virtual sk::util::Object 00023 { 00024 public: 00025 // Default copy constructor is sufficient for now. 00026 // User(const User& other); 00027 virtual ~User(); 00028 00029 const sk::util::String getName() const; 00030 const sk::util::String getComment() const; 00031 const sk::util::String getHome() const; 00032 const sk::util::String getShell() const; 00033 int getUid() const; 00034 int getGid() const; 00035 bool authenticate(const sk::util::String& password) const; 00036 00037 // sk::util::Object re-implementation. 00038 const sk::util::Class getClass() const; 00039 00040 static const User find(const sk::util::String& name); 00041 static bool find(const sk::util::String& name, sk::util::Holder<sk::sys::User>& holder); 00042 static void forEach(const sk::util::Processor<const sk::sys::User>& processor); 00043 00044 private: 00045 User(const struct passwd& entry); 00046 User& operator = (const User& other); 00047 00048 const sk::rt::Scope _scope; 00049 sk::util::String _name; 00050 sk::util::String _home; 00051 sk::util::String _shell; 00052 sk::util::String _comment; 00053 int _uid; 00054 int _gid; 00055 }; 00056 } 00057 } 00058 00059 #endif /* _SK_SYS_USER_ */