2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // authority - authorization manager
25 #include "securityserver.h"
26 #include "AuthorizationEngine.h"
28 using Authorization::Credential
;
29 using Authorization::CredentialSet
;
30 using Authorization::RightSet
;
31 using Authorization::MutableRightSet
;
32 using Authorization::AuthItemSet
;
38 class AuthorizationToken
{
40 AuthorizationToken(Session
&ssn
, const CredentialSet
&base
);
41 ~AuthorizationToken();
45 const AuthorizationBlob
&handle() const { return mHandle
; }
46 const CredentialSet
&baseCreds() const { return mBaseCreds
; }
47 CredentialSet
effectiveCreds() const;
49 typedef CredentialSet::iterator iterator
;
50 iterator
begin() { return mBaseCreds
.begin(); }
51 iterator
end() { return mBaseCreds
.end(); }
53 // add more credential dependencies
54 void mergeCredentials(const CredentialSet
&more
);
56 // maintain process-owning links
57 void addProcess(Process
&proc
);
58 bool endProcess(Process
&proc
);
60 // access control for external representations
61 bool mayExternalize(Process
&proc
) const;
62 bool mayInternalize(Process
&proc
, bool countIt
= true);
64 uid_t
creatorUid() const { return mCreatorUid
; }
65 CodeSigning::OSXCode
*creatorCode() const { return mCreatorCode
; }
67 AuthorizationItemSet
&infoSet();
68 void setInfoSet(AuthorizationItemSet
&newInfoSet
);
69 void setCredentialInfo(const Credential
&inCred
);
72 static AuthorizationToken
&find(const AuthorizationBlob
&blob
);
76 Deleter(const AuthorizationBlob
&blob
);
79 operator AuthorizationToken
&() const { return *mAuth
; }
82 AuthorizationToken
*mAuth
;
87 Mutex mLock
; // object lock
88 AuthorizationBlob mHandle
; // official randomized blob marker
89 CredentialSet mBaseCreds
; // credentials we're based on
91 unsigned int mTransferCount
; // number of internalizations remaining
93 typedef set
<Process
*> ProcessSet
;
94 ProcessSet mUsingProcesses
; // set of process objects using this token
96 uid_t mCreatorUid
; // Uid of proccess that created this authorization
97 RefPointer
<OSXCode
> mCreatorCode
; // code id of creator
99 AuthorizationItemSet
*mInfoSet
; // Side band info gathered from evaluations in this session
102 typedef map
<AuthorizationBlob
, AuthorizationToken
*> AuthMap
;
103 static AuthMap authMap
; // set of extant authorizations
104 static Mutex authMapLock
; // lock for mAuthorizations (only)
109 // The authority itself. You will usually only have one of these.
111 class Authority
: public Authorization::Engine
{
113 Authority(const char *configFile
);
118 #endif //_H_AUTHORITY