2 * Copyright (c) 2003-2004 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 * AuthorizationDBPlist.h
29 #ifndef _H_AUTHORIZATIONDBPLIST
30 #define _H_AUTHORIZATIONDBPLIST 1
32 #include <CoreFoundation/CoreFoundation.h>
33 #include <security_utilities/cfutilities.h>
35 #include <security_cdsa_utilities/AuthorizationData.h>
36 #include "AuthorizationRule.h"
38 class AuthorizationDBPlist
; // @@@ the ordering sucks here, maybe engine should include all these and other should only include it
40 namespace Authorization
43 class AuthorizationDBPlist
/* : public AuthorizationDB */
46 AuthorizationDBPlist(const char *configFile
= "/etc/authorization");
48 void sync(CFAbsoluteTime now
);
49 bool validateRule(string inRightName
, CFDictionaryRef inRightDefinition
) const;
50 CFDictionaryRef
getRuleDefinition(string
&key
);
52 bool existRule(string
&ruleName
) const;
53 Rule
getRule(const AuthItemRef
&inRight
) const;
55 void setRule(const char *inRightName
, CFDictionaryRef inRuleDefinition
);
56 void removeRule(const char *inRightName
);
59 void load(CFTimeInterval now
);
66 enum { kTypeRight
, kTypeRule
};
67 void parseConfig(CFDictionaryRef config
);
68 static void parseRule(const void *key
, const void *value
, void *context
);
69 void addRight(CFStringRef key
, CFDictionaryRef definition
);
71 CFAbsoluteTime mLastChecked
;
72 struct timespec mRulesFileMtimespec
;
74 map
<string
,Rule
> mRules
;
75 CFRef
<CFDictionaryRef
> mConfig
;
76 CFRef
<CFMutableDictionaryRef
> mConfigRights
;
77 CFRef
<CFMutableDictionaryRef
> mConfigRules
;
79 mutable Mutex mLock
; // rule map lock
80 mutable Mutex mReadWriteLock
; // file operation lock
83 }; /* namespace Authorization */
85 #endif /* ! _H_AUTHORIZATIONDBPLIST */