2 * Copyright (c) 2002 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.
18 #include <Security/SecAccess.h>
19 #include <Security/Access.h>
20 #include "SecBridge.h"
26 CFTypeID
SecAccessGetTypeID(void)
29 return gTypes().Access
.typeID
;
30 END_SECAPI1(_kCFRuntimeNotATypeID
)
38 * Create a new SecAccessRef that is set to the default configuration
39 * of a (newly created) security object.
41 OSStatus
SecAccessCreate(CFStringRef descriptor
, CFArrayRef trustedList
, SecAccessRef
*accessRef
)
45 SecPointer
<Access
> access
;
47 CFIndex length
= CFArrayGetCount(trustedList
);
48 ACL::ApplicationList trusted
;
49 for (CFIndex n
= 0; n
< length
; n
++)
50 trusted
.push_back(TrustedApplication::required(
51 SecTrustedApplicationRef(CFArrayGetValueAtIndex(trustedList
, n
))));
52 access
= new Access(cfString(descriptor
), trusted
);
54 access
= new Access(cfString(descriptor
));
56 Required(accessRef
) = access
->handle();
63 OSStatus
SecAccessCreateFromOwnerAndACL(const CSSM_ACL_OWNER_PROTOTYPE
*owner
,
64 uint32 aclCount
, const CSSM_ACL_ENTRY_INFO
*acls
,
65 SecAccessRef
*accessRef
)
68 Required(accessRef
); // preflight
69 SecPointer
<Access
> access
= new Access(Required(owner
), aclCount
, &Required(acls
));
70 *accessRef
= access
->handle();
77 OSStatus
SecAccessGetOwnerAndACL(SecAccessRef accessRef
,
78 CSSM_ACL_OWNER_PROTOTYPE_PTR
*owner
,
79 uint32
*aclCount
, CSSM_ACL_ENTRY_INFO_PTR
*acls
)
82 Access::required(accessRef
)->copyOwnerAndAcl(
83 Required(owner
), Required(aclCount
), Required(acls
));
90 OSStatus
SecAccessCopyACLList(SecAccessRef accessRef
,
94 Required(aclList
) = Access::required(accessRef
)->copySecACLs();
101 OSStatus
SecAccessCopySelectedACLList(SecAccessRef accessRef
,
102 CSSM_ACL_AUTHORIZATION_TAG action
,
106 Required(aclList
) = Access::required(accessRef
)->copySecACLs(action
);