]> git.saurik.com Git - apple/security.git/blame - cdsa/cdsa_utilities/acl_comment.h
Security-30.1.tar.gz
[apple/security.git] / cdsa / cdsa_utilities / acl_comment.h
CommitLineData
bac41a7b
A
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// acl_comment - "ignore" ACL subject type
21//
22// This subject will never match anything - its presence is effectively ignored.
23// Its usefulness lies in the fact that COMMENT type ACL subjects are valid ACL
24// subjects that preserve their contents as uninterpreted data blobs. This allows
25// you to keep information in an ACL that can be retrieved later. In particular,
26// you can "prefix" any external ACL subject representation with an ACL_COMMENT
27// header, which turns it into an inactive comment until you remove the prefix.
28//
29// Notes:
30// (1) All contents of a comment ACL are public.
31// (2) While there is a COMMENT sample type, it is in no way related to this subject
32// type. Validation of a COMMENT acl subject never examines any samples.
33//
34#ifndef _ACL_COMMENT
35#define _ACL_COMMENT
36
37#include <Security/cssmacl.h>
38
39
40namespace Security
41{
42
43//
44// The ANY subject simply matches everything. No sweat.
45//
46class CommentAclSubject : public AclSubject {
47public:
48 CommentAclSubject::CommentAclSubject(CSSM_LIST *list, uint32 size)
49 : AclSubject(CSSM_ACL_SUBJECT_TYPE_COMMENT), mComment(list), mSize(size) { }
50 ~CommentAclSubject() { CssmAllocator::standard().free(mComment); }
51
52 bool validate(const AclValidationContext &ctx) const;
53 CssmList toList(CssmAllocator &alloc) const;
54
55 void exportBlob(Writer::Counter &pub, Writer::Counter &priv);
56 void exportBlob(Writer &pub, Writer &priv);
57
58 class Maker : public AclSubject::Maker {
59 public:
60 Maker() : AclSubject::Maker(CSSM_ACL_SUBJECT_TYPE_COMMENT) { }
61 CommentAclSubject *make(const TypedList &list) const;
62 CommentAclSubject *make(Reader &pub, Reader &priv) const;
63 };
64
65private:
66 CSSM_LIST *mComment; // list form preserved
67 uint32 mSize; // size of mComment blob
68};
69
70} // end namespace Security
71
72
73#endif //_ACL_COMMENT