]> git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/cssmaclpod.cpp
b97b5da14b33b8893e1e5cb65fd6c6435f896282
[apple/security.git] / cdsa / cdsa_utilities / cssmaclpod.cpp
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 //
20 // cssmaclpod - enhanced PodWrappers for ACL-related CSSM data structures
21 //
22 #ifdef __MWERKS__
23 #define _CPP_CSSMACLPOD
24 #endif
25
26 #include <Security/cssmaclpod.h>
27 #include <Security/cssmwalkers.h>
28
29
30 AuthorizationGroup::AuthorizationGroup(const AclAuthorizationSet &auths, CssmAllocator &alloc)
31 {
32 NumberOfAuthTags = auths.size();
33 AuthTags = alloc.alloc<CSSM_ACL_AUTHORIZATION_TAG>(NumberOfAuthTags);
34 copy(auths.begin(), auths.end(), AuthTags); // happens to be sorted
35 }
36
37 bool AuthorizationGroup::contains(CSSM_ACL_AUTHORIZATION_TAG tag) const
38 {
39 return find(AuthTags, &AuthTags[NumberOfAuthTags], tag) != &AuthTags[NumberOfAuthTags];
40 }
41
42
43 AuthorizationGroup::operator AclAuthorizationSet() const
44 {
45 return AclAuthorizationSet(AuthTags, &AuthTags[NumberOfAuthTags]);
46 }
47
48 AclEntryPrototype::AclEntryPrototype(const AclOwnerPrototype &proto)
49 {
50 memset(this, 0, sizeof(*this));
51 TypedSubject = proto.subject(); Delegate = proto.delegate();
52 //@@@ set authorization to "is owner" pseudo-auth? See cssmacl.h
53 }
54
55
56 AutoAclOwnerPrototype::~AutoAclOwnerPrototype()
57 {
58 if (mAllocator)
59 DataWalkers::chunkFree(mAclOwnerPrototype, *mAllocator);
60 }
61
62 void
63 AutoAclOwnerPrototype::allocator(CssmAllocator &allocator)
64 {
65 mAllocator = &allocator;
66 }
67
68
69 AutoAclEntryInfoList::~AutoAclEntryInfoList()
70 {
71 if (mAllocator)
72 {
73 DataWalkers::ChunkFreeWalker w(*mAllocator);
74 for (uint32 ix = 0; ix < mNumberOfAclEntries; ix++)
75 walk(w, mAclEntryInfo[ix]);
76 //DataWalkers::chunkFree(mAclEntryInfo[ix], *mAllocator);
77 mAllocator->free(mAclEntryInfo);
78 }
79 }
80
81 void
82 AutoAclEntryInfoList::allocator(CssmAllocator &allocator)
83 {
84 mAllocator = &allocator;
85 }