AuthorizationDBPlist.h [plain text]
#ifndef _H_AUTHORIZATIONDBPLIST
#define _H_AUTHORIZATIONDBPLIST 1
#include <CoreFoundation/CoreFoundation.h>
#include <security_utilities/cfutilities.h>
#include <security_cdsa_utilities/AuthorizationData.h>
#include "AuthorizationRule.h"
class AuthorizationDBPlist;
namespace Authorization
{
class AuthorizationDBPlist
{
public:
AuthorizationDBPlist(const char *configFile);
void sync(CFAbsoluteTime now);
bool validateRule(string inRightName, CFDictionaryRef inRightDefinition) const;
CFDictionaryRef getRuleDefinition(string &key);
bool existRule(string &ruleName) const;
Rule getRule(const AuthItemRef &inRight) const;
void setRule(const char *inRightName, CFDictionaryRef inRuleDefinition);
void removeRule(const char *inRightName);
protected:
void load();
void save();
private:
string mFileName;
private:
enum { kTypeRight, kTypeRule };
void parseConfig(CFDictionaryRef config);
static void parseRule(const void *key, const void *value, void *context);
void addRight(CFStringRef key, CFDictionaryRef definition);
CFAbsoluteTime mLastChecked;
struct timespec mRulesFileMtimespec;
map<string,Rule> mRules;
CFRef<CFDictionaryRef> mConfig;
CFRef<CFMutableDictionaryRef> mConfigRights;
CFRef<CFMutableDictionaryRef> mConfigRules;
mutable Mutex mLock; mutable Mutex mReadWriteLock; };
};
#endif