]> git.saurik.com Git - apple/security.git/blob - SecurityServer/Authorization/AuthorizationDBPlist.h
Security-179.tar.gz
[apple/security.git] / SecurityServer / Authorization / AuthorizationDBPlist.h
1 /*
2 * AuthorizationDBPlist.h
3 * Security
4 *
5 * Created by Conrad Sauerwald on Tue Mar 18 2003.
6 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
7 *
8 */
9 #ifndef _H_AUTHORIZATIONDBPLIST
10 #define _H_AUTHORIZATIONDBPLIST 1
11
12 #include <CoreFoundation/CoreFoundation.h>
13 #include "AuthorizationData.h"
14 #include "AuthorizationRule.h"
15
16 namespace Authorization
17 {
18
19 class AuthorizationDBPlist /* : public AuthorizationDB */
20 {
21 public:
22 AuthorizationDBPlist(const char *configFile = "/etc/authorization");
23 //~AuthorizationDBPlist();
24
25 void sync(CFAbsoluteTime now);
26 bool validateRule(string inRightName, CFDictionaryRef inRightDefinition) const;
27 CFDictionaryRef getRuleDefinition(string &key);
28
29 bool existRule(string &ruleName) const;
30 Rule getRule(const AuthItemRef &inRight) const;
31
32 void setRule(const char *inRightName, CFDictionaryRef inRuleDefinition);
33 void removeRule(const char *inRightName);
34
35 protected:
36 void load(CFTimeInterval now);
37 void save() const;
38
39 private:
40 string mFileName;
41
42 private:
43 enum { kTypeRight, kTypeRule };
44 void parseConfig(CFDictionaryRef config);
45 static void parseRule(const void *key, const void *value, void *context);
46 void addRight(CFStringRef key, CFDictionaryRef definition);
47
48 CFAbsoluteTime mLastChecked;
49 struct timespec mRulesFileMtimespec;
50
51 map<string,Rule> mRules;
52 CFRef<CFDictionaryRef> mConfig;
53 CFRef<CFMutableDictionaryRef> mConfigRights;
54 CFRef<CFMutableDictionaryRef> mConfigRules;
55
56 mutable Mutex mLock; // rule map lock
57 mutable Mutex mReadWriteLock; // file operation lock
58 };
59
60 }; /* namespace Authorization */
61
62 #endif /* ! _H_AUTHORIZATIONDBPLIST */