]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/acl_comment.cpp
   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 // acl_comment - "ignore" ACL subject type 
  22 #include <Security/acl_comment.h> 
  23 #include <Security/cssmwalkers.h> 
  24 #include <Security/cssmlist.h> 
  27 using namespace DataWalkers
; 
  31 // The COMMENT subject matches nothing, no matter how pretty. 
  33 bool CommentAclSubject::validate(const AclValidationContext 
&) const 
  40 // The toList function simply returns a copy of the preserved list. 
  41 // The interface convention requires that we chunkCopy here. 
  43 CssmList 
CommentAclSubject::toList(CssmAllocator 
&alloc
) const 
  45         CssmList result 
= CssmList::overlay(*mComment
); 
  46         ChunkCopyWalker 
w(alloc
); 
  53 // Construct-from-list makes a unified copy of the list. 
  55 CommentAclSubject 
*CommentAclSubject::Maker::make(const TypedList 
&list
) const 
  57         const CSSM_LIST 
*baseList 
= &list
; 
  58         size_t commentSize 
= size(baseList
); 
  59         CSSM_LIST 
*comment 
= copy(baseList
, CssmAllocator::standard(), commentSize
); 
  60         return new CommentAclSubject(comment
, commentSize
); 
  63 CommentAclSubject 
*CommentAclSubject::Maker::make(Version
, Reader 
&pub
, Reader 
&) const 
  65         CSSM_LIST 
*base
; pub(base
);     // get original pointer base 
  66         const void *data
; uint32 length
; pub
.countedData(data
, length
); // data blob 
  68         // copy the input blob into writable memory 
  69         CSSM_LIST 
*list 
= CssmAllocator::standard().malloc
<CSSM_LIST
>(length
); 
  70         memcpy(list
, data
, length
); 
  72         // relocate it based on the base pointer we stored 
  76     return new CommentAclSubject(list
, length
); 
  81 // Export to blob form. 
  82 // Since we store the list in unified form, this isn't very hard. Do try to figure 
  83 // out how walkers work before messing with this code. 
  85 void CommentAclSubject::exportBlob(Writer::Counter 
&pub
, Writer::Counter 
&) 
  87         pub(mComment
);  // yes, the pointer itself 
  88         pub
.countedData(mComment
, mSize
); 
  91 void CommentAclSubject::exportBlob(Writer 
&pub
, Writer 
&) 
  94         pub
.countedData(mComment
, mSize
);