00001
00002
00003
00004 #ifndef DMLITE_CPP_AUTHN_H
00005 #define DMLITE_CPP_AUTHN_H
00006
00007 #include <string>
00008 #include <vector>
00009 #include "base.h"
00010 #include "exceptions.h"
00011 #include "utils/extensible.h"
00012
00013 namespace dmlite {
00014
00015
00016 class PluginManager;
00017 class StackInstance;
00018
00019
00020 struct SecurityCredentials: public Extensible {
00021 std::string mech;
00022 std::string clientName;
00023 std::string remoteAddress;
00024 std::string sessionId;
00025
00026 std::vector<std::string> fqans;
00027
00028 bool operator == (const SecurityCredentials&) const;
00029 bool operator != (const SecurityCredentials&) const;
00030 bool operator < (const SecurityCredentials&) const;
00031 bool operator > (const SecurityCredentials&) const;
00032 };
00033
00034
00035
00036
00037
00038
00039
00040 struct UserInfo: public Extensible {
00041 std::string name;
00042
00043 bool operator == (const UserInfo&) const;
00044 bool operator != (const UserInfo&) const;
00045 bool operator < (const UserInfo&) const;
00046 bool operator > (const UserInfo&) const;
00047 };
00048
00049
00050
00051 struct GroupInfo: public Extensible {
00052 std::string name;
00053
00054 bool operator == (const GroupInfo&) const;
00055 bool operator != (const GroupInfo&) const;
00056 bool operator < (const GroupInfo&) const;
00057 bool operator > (const GroupInfo&) const;
00058 };
00059
00060
00061
00062 struct SecurityContext {
00063 SecurityContext() {}
00064
00065 SecurityContext(const SecurityCredentials& c,
00066 const UserInfo& u,
00067 std::vector<GroupInfo>& g):
00068 credentials(c), user(u), groups(g) {}
00069
00070 SecurityCredentials credentials;
00071
00072 UserInfo user;
00073 std::vector<GroupInfo> groups;
00074
00075 bool operator == (const SecurityContext&) const;
00076 bool operator != (const SecurityContext&) const;
00077 bool operator < (const SecurityContext&) const;
00078 bool operator > (const SecurityContext&) const;
00079 };
00080
00081
00082
00083
00084
00085 class Authn {
00086 public:
00087
00088 virtual ~Authn();
00089
00090
00091 virtual std::string getImplId(void) const throw() = 0;
00092
00093
00094
00095
00096 virtual SecurityContext* createSecurityContext(const SecurityCredentials& cred) throw (DmException) = 0;
00097
00098
00099
00100
00101 virtual GroupInfo newGroup(const std::string& groupName) throw (DmException) = 0;
00102
00103
00104
00105
00106 virtual GroupInfo getGroup(const std::string& groupName) throw (DmException) = 0;
00107
00108
00109
00110
00111
00112
00113
00114 virtual GroupInfo getGroup(const std::string& key,
00115 const boost::any& value) throw (DmException) = 0;
00116
00117
00118 virtual std::vector<GroupInfo> getGroups(void) throw (DmException) = 0;
00119
00120
00121
00122 virtual void updateGroup(const GroupInfo& group) throw (DmException) = 0;
00123
00124
00125 virtual void deleteGroup(const std::string& groupName) throw (DmException) = 0;
00126
00127
00128
00129
00130 virtual UserInfo newUser(const std::string& userName) throw (DmException) = 0;
00131
00132
00133
00134
00135 virtual UserInfo getUser(const std::string& userName) throw (DmException) = 0;
00136
00137
00138
00139
00140
00141
00142
00143 virtual UserInfo getUser(const std::string& key,
00144 const boost::any& value) throw (DmException) = 0;
00145
00146
00147 virtual std::vector<UserInfo> getUsers(void) throw (DmException) = 0;
00148
00149
00150
00151 virtual void updateUser(const UserInfo& user) throw (DmException) = 0;
00152
00153
00154 virtual void deleteUser(const std::string& userName) throw (DmException) = 0;
00155
00156
00157
00158
00159
00160
00161
00162
00163 virtual void getIdMap(const std::string& userName,
00164 const std::vector<std::string>& groupNames,
00165 UserInfo* user,
00166 std::vector<GroupInfo>* groups) throw (DmException) = 0;
00167 };
00168
00169
00170
00171 class AuthnFactory: public virtual BaseFactory {
00172 public:
00173
00174 virtual ~AuthnFactory();
00175
00176 protected:
00177
00178 friend class StackInstance;
00179
00180
00181 static Authn* createAuthn(AuthnFactory* factory,
00182 PluginManager* pm) throw (DmException);
00183
00184
00185 virtual Authn* createAuthn(PluginManager* pm) throw (DmException) = 0;
00186 };
00187
00188 };
00189
00190 #endif // DMLITE_CPP_AUTH_H