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 // cssmaclpod - enhanced PodWrappers for ACL-related CSSM data structures
23 #define _CPP_CSSMACLPOD
26 #include <Security/cssmaclpod.h>
27 #include <Security/cssmwalkers.h>
30 AuthorizationGroup::AuthorizationGroup(const AclAuthorizationSet
&auths
,
33 NumberOfAuthTags
= auths
.size();
34 AuthTags
= alloc
.alloc
<CSSM_ACL_AUTHORIZATION_TAG
>(NumberOfAuthTags
);
35 copy(auths
.begin(), auths
.end(), AuthTags
); // happens to be sorted
38 void AuthorizationGroup::destroy(CssmAllocator
&alloc
)
43 bool AuthorizationGroup::contains(CSSM_ACL_AUTHORIZATION_TAG tag
) const
45 return find(AuthTags
, &AuthTags
[NumberOfAuthTags
], tag
) != &AuthTags
[NumberOfAuthTags
];
49 AuthorizationGroup::operator AclAuthorizationSet() const
51 return AclAuthorizationSet(AuthTags
, &AuthTags
[NumberOfAuthTags
]);
54 AclEntryPrototype::AclEntryPrototype(const AclOwnerPrototype
&proto
)
56 memset(this, 0, sizeof(*this));
57 TypedSubject
= proto
.subject(); Delegate
= proto
.delegate();
58 //@@@ set authorization to "is owner" pseudo-auth? See cssmacl.h
61 void AclEntryPrototype::tag(const char *tagString
)
63 if (tagString
== NULL
)
65 else if (strlen(tagString
) > CSSM_MODULE_STRING_SIZE
)
66 CssmError::throwMe(CSSM_ERRCODE_INVALID_ACL_ENTRY_TAG
);
67 strcpy(EntryTag
, tagString
);
71 AclOwnerPrototype
*AutoAclOwnerPrototype::make()
73 if (!mAclOwnerPrototype
) {
74 mAclOwnerPrototype
= new AclOwnerPrototype
;
75 mAclOwnerPrototype
->clearPod();
77 return mAclOwnerPrototype
;
80 AutoAclOwnerPrototype::~AutoAclOwnerPrototype()
83 DataWalkers::chunkFree(mAclOwnerPrototype
, *mAllocator
);
87 AutoAclOwnerPrototype::allocator(CssmAllocator
&allocator
)
89 mAllocator
= &allocator
;
93 AutoAclEntryInfoList::~AutoAclEntryInfoList()
97 DataWalkers::ChunkFreeWalker
w(*mAllocator
);
98 for (uint32 ix
= 0; ix
< mNumberOfAclEntries
; ix
++)
99 walk(w
, mAclEntryInfo
[ix
]);
100 //DataWalkers::chunkFree(mAclEntryInfo[ix], *mAllocator);
101 mAllocator
->free(mAclEntryInfo
);
106 AutoAclEntryInfoList::allocator(CssmAllocator
&allocator
)
108 mAllocator
= &allocator
;