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_keychain - a subject type for the protected-path
21 // keychain prompt interaction model.
23 // Arguments in list form:
24 // list[1] = CssmData: Descriptive String
27 #define _CPP_ACL_KEYCHAIN
30 #include <Security/acl_keychain.h>
35 // Validate a credential set against this subject
37 bool KeychainPromptAclSubject::validate(const AclValidationContext
&,
38 const TypedList
&sample
) const
40 return interface
.validate(description
);
45 // Make a copy of this subject in CSSM_LIST form
47 CssmList
KeychainPromptAclSubject::toList(CssmAllocator
&alloc
) const
49 return TypedList(alloc
, CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT
,
50 new(alloc
) ListElement(alloc
, description
));
55 // Create a PasswordAclSubject
57 KeychainPromptAclSubject
*KeychainPromptAclSubject::Maker::make(const TypedList
&list
) const
59 ListElement
*params
[1];
60 crack(list
, 1, params
, CSSM_LIST_ELEMENT_DATUM
);
61 return new KeychainPromptAclSubject(interface
, *params
[0]);
64 KeychainPromptAclSubject
*KeychainPromptAclSubject::Maker::make(Reader
&pub
, Reader
&) const
66 char *description
; pub(description
);
67 return new KeychainPromptAclSubject(interface
, description
);
70 KeychainPromptAclSubject::KeychainPromptAclSubject(KeychainPromptInterface
&ifc
,
72 : SimpleAclSubject(CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT
, CSSM_SAMPLE_TYPE_KEYCHAIN_PROMPT
),
73 interface(ifc
), description(descr
)
79 // Export the subject to a memory blob
81 void KeychainPromptAclSubject::exportBlob(Writer::Counter
&pub
, Writer::Counter
&priv
)
83 pub(description
.size() + 1);
86 void KeychainPromptAclSubject::exportBlob(Writer
&pub
, Writer
&priv
)
88 pub(description
.c_str());