summaryrefslogtreecommitdiffstats
path: root/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h')
-rw-r--r--src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h
new file mode 100644
index 0000000..afb7663
--- /dev/null
+++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h
@@ -0,0 +1,97 @@
+/*
+ * UserConfigBackendKrb5.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_MODULES_USERCONFIGBACKENDKRB5_USERCONFIGBACKENDKRB5_H_
+#define MAD_MODULES_USERCONFIGBACKENDKRB5_USERCONFIGBACKENDKRB5_H_
+
+#include <Common/UserConfigBackend.h>
+#include <Common/Application.h>
+
+#include <Core/Configurable.h>
+#include <Core/ConfigManager.h>
+
+#define USE_KADM5_API_VERSION 2
+#include <kadm5/admin.h>
+
+namespace Mad {
+namespace Modules {
+namespace UserConfigBackendKrb5 {
+
+class UserConfigBackendKrb5 : public Common::UserConfigBackend, private Core::Configurable, private boost::noncopyable {
+ private:
+ Common::Application *application;
+
+ std::string realm, principal, server;
+ std::string password, keytab;
+
+ krb5_context context;
+ void *handle;
+
+ bool connect();
+
+ protected:
+ virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
+
+ virtual void configFinished() {
+ connect();
+ }
+
+ virtual void checkUserInfo(const Common::UserInfo &userInfo) throw(Core::Exception);
+
+ virtual void addUser(const Common::UserInfo &userInfo) throw(Core::Exception);
+ virtual void updateUser(const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo) throw(Core::Exception);
+ virtual void deleteUser(const Common::UserInfo &userInfo) throw(Core::Exception);
+
+ public:
+ UserConfigBackendKrb5(Common::Application *application0) : application(application0), handle(0) {
+ krb5_error_code err = krb5_init_context(&context);
+ if(err) {
+ context = 0;
+ return;
+ }
+
+ char *defaultRealm;
+
+ krb5_get_default_realm(context, &defaultRealm);
+ if(defaultRealm) {
+ realm = defaultRealm;
+ free(defaultRealm);
+ }
+
+ application->getConfigManager()->registerConfigurable(this);
+ }
+
+ virtual ~UserConfigBackendKrb5() {
+ if(!context)
+ return;
+
+ application->getConfigManager()->unregisterConfigurable(this);
+
+ if(handle)
+ kadm5_destroy(handle);
+
+ krb5_free_context(context);
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_MODULES_USERCONFIGBACKENDKRB5_USERCONFIGBACKENDKRB5_H_ */