From c1cb92bc30256171bfafb22cf8512142afee97cf Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 15 Aug 2009 15:07:41 +0200 Subject: =?UTF-8?q?UserConfigBackendKrb5=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserConfigBackendKrb5/UserConfigBackendKrb5.h | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h (limited to 'src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h') 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 + * + * 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 . + */ + +#ifndef MAD_MODULES_USERCONFIGBACKENDKRB5_USERCONFIGBACKENDKRB5_H_ +#define MAD_MODULES_USERCONFIGBACKENDKRB5_USERCONFIGBACKENDKRB5_H_ + +#include +#include + +#include +#include + +#define USE_KADM5_API_VERSION 2 +#include + +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_ */ -- cgit v1.2.3