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 // @@@ Default value should be internal error.
59 static void throwMe(int err
= -1) __attribute((noreturn
));
63 /* The engine which performs the actual authentication and authorization computations.
65 The implementation of a typical call to AuthorizationCreate would look like:
67 Get the current shared CredentialSet for this session.
68 Call authorizedRights() with inRights and the shared CredentialSet.
69 Compute the difference set between the rights requested and the rights returned from authorizedRights().
70 Call credentialIds() with the rights computed above (for which we have no credentials yet).
71 Call aquireCredentials() for the credentialIds returned from credentialIds()
72 For each credential returned place it in the session (replacing when needed) if shared() returns true.
73 The authorization returned to the user should now refer to the credentials in the session and the non shared ones returned by aquireCredentials().
75 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.
77 When a call to AuthorizationCopyInfo() is made, ask the Credential specified by tag for it info and return it.
79 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.
84 Engine(const char *configFile
);
87 OSStatus
authorize(const AuthItemSet
&inRights
, const AuthItemSet
&environment
,
88 AuthorizationFlags flags
, const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
,
89 AuthItemSet
&outRights
, AuthorizationToken
&auth
);
90 OSStatus
getRule(string
&inRightName
, CFDictionaryRef
*outRuleDefinition
);
91 OSStatus
setRule(const char *inRightName
, CFDictionaryRef inRuleDefinition
, const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
, AuthorizationToken
&auth
);
92 OSStatus
removeRule(const char *inRightName
, const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
, AuthorizationToken
&auth
);
95 OSStatus
verifyModification(string inRightName
, bool remove
,
96 const CredentialSet
*inCredentials
, CredentialSet
*outCredentials
, AuthorizationToken
&auth
);
98 AuthorizationDBPlist mAuthdb
;
102 }; // namespace Authorization
104 #endif /* ! _H_AUTHORIZATIONENGINE */