2 * Copyright (c) 2000-2004 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 * AuthorizationEngine.h
27 #ifndef _H_AUTHORIZATIONENGINE
28 #define _H_AUTHORIZATIONENGINE 1
30 #include <Security/Authorization.h>
31 #include <Security/AuthorizationPlugin.h>
32 #include <security_cdsa_utilities/AuthorizationData.h>
34 #include <security_utilities/threading.h>
35 #include <security_utilities/osxcode.h>
37 #include <CoreFoundation/CFDate.h>
38 #include <CoreFoundation/CFDictionary.h>
40 #include <sys/types.h>
42 #include "authority.h"
44 #include "AuthorizationRule.h"
45 #include "AuthorizationDBPlist.h"
47 namespace Authorization
50 class Error
: public CommonError
{
55 virtual int unixError() const throw();
56 virtual OSStatus
osStatus() const throw();
57 virtual const char *what () const throw();
58 static void throwMe(int err
) __attribute((noreturn
));
62 /* The engine which performs the actual authentication and authorization computations.
64 The implementation of a typical call to AuthorizationCreate would look like:
66 Get the current shared CredentialSet for this session.
67 Call authorizedRights() with inRights and the shared CredentialSet.
68 Compute the difference set between the rights requested and the rights returned from authorizedRights().
69 Call credentialIds() with the rights computed above (for which we have no credentials yet).
70 Call aquireCredentials() for the credentialIds returned from credentialIds()
71 For each credential returned place it in the session (replacing when needed) if shared() returns true.
72 The authorization returned to the user should now refer to the credentials in the session and the non shared ones returned by aquireCredentials().
74 When a call to AuthorizationCopyRights() is made, just call authorizedRights() using the union of the session credentials and the credentials tied to the authorization specified.
76 When a call to AuthorizationCopyInfo() is made, ask the Credential specified by tag for it info and return it.
78 When a call to AuthorizationFree() is made, delete all the non-shared credentials ascociated with the authorization specified. If the kAuthorizationFreeFlagDestroy is set. Also delete the shared credentials ascociated with the authorization specified.
83 Engine(const char *configFile
);
86 OSStatus
authorize(const AuthItemSet
&inRights
, const AuthItemSet
&environment
,
87 AuthorizationFlags flags
, const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
,
88 AuthItemSet
&outRights
, AuthorizationToken
&auth
);
89 OSStatus
getRule(string
&inRightName
, CFDictionaryRef
*outRuleDefinition
);
90 OSStatus
setRule(const char *inRightName
, CFDictionaryRef inRuleDefinition
, const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
, AuthorizationToken
&auth
);
91 OSStatus
removeRule(const char *inRightName
, const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
, AuthorizationToken
&auth
);
94 OSStatus
verifyModification(string inRightName
, bool remove
,
95 const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
, AuthorizationToken
&auth
);
97 AuthorizationDBPlist mAuthdb
;
101 }; // namespace Authorization
103 #endif /* ! _H_AUTHORIZATIONENGINE */