]>
git.saurik.com Git - apple/security.git/blob - Keychain/PolicyCursor.cpp
576aefed20b7e2ea8e01611a0db2563792a2237a
2 * Copyright (c) 2002 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.
21 #include <Security/PolicyCursor.h>
22 #include <Security/oidsalg.h>
23 #include <Security/tpclient.h>
25 using namespace KeychainCore
;
26 using namespace CssmClient
;
30 // This preliminary implementation bypasses MDS and uses
31 // a fixed set of policies known to exist in the one known TP.
33 struct TheOneTP
: public TP
{
34 TheOneTP() : TP(gGuidAppleX509TP
) { }
37 static ModuleNexus
<TheOneTP
> theOneTP
;
38 static const CssmOid
*theOidList
[] = {
39 static_cast<const CssmOid
*>(&CSSMOID_APPLE_ISIGN
),
40 static_cast<const CssmOid
*>(&CSSMOID_APPLE_X509_BASIC
),
41 static_cast<const CssmOid
*>(&CSSMOID_APPLE_TP_SSL
),
47 // Canonical Construction
49 PolicyCursor::PolicyCursor(const CSSM_OID
* oid
, const CSSM_DATA
* value
)
50 : mOid(CssmAllocator::standard()), mOidGiven(false)
53 mOid
= CssmOid::required(oid
);
63 PolicyCursor::~PolicyCursor()
71 bool PolicyCursor::next(RefPointer
<Policy
> &policy
)
73 while (theOidList
[mSearchPos
]) {
74 if (mOidGiven
&& mOid
!= *theOidList
[mSearchPos
]) {
76 continue; // no oid match
78 // ignoring mValue - not used by current TP
79 policy
= new Policy(theOneTP(), *theOidList
[mSearchPos
]);
80 mSearchPos
++; // advance cursor
81 return true; // return next match
83 return false; // end of table, no more matches