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/Policies.h>
23 #include <Security/oidsalg.h>
24 #include <Security/tpclient.h>
26 using namespace KeychainCore
;
27 using namespace CssmClient
;
31 // This preliminary implementation bypasses MDS and uses
32 // a fixed set of policies known to exist in the one known TP.
34 struct TheOneTP
: public TP
{
35 TheOneTP() : TP(gGuidAppleX509TP
) { }
38 static ModuleNexus
<TheOneTP
> theOneTP
;
39 static const CssmOid
*theOidList
[] = {
40 static_cast<const CssmOid
*>(&CSSMOID_APPLE_ISIGN
),
41 static_cast<const CssmOid
*>(&CSSMOID_APPLE_X509_BASIC
),
42 static_cast<const CssmOid
*>(&CSSMOID_APPLE_TP_SSL
),
43 static_cast<const CssmOid
*>(&CSSMOID_APPLE_TP_SMIME
),
44 static_cast<const CssmOid
*>(&CSSMOID_APPLE_TP_EAP
),
45 static_cast<const CssmOid
*>(&CSSMOID_APPLE_TP_REVOCATION_CRL
),
51 // Canonical Construction
53 PolicyCursor::PolicyCursor(const CSSM_OID
* oid
, const CSSM_DATA
* value
)
54 : mOid(CssmAllocator::standard()), mOidGiven(false)
57 mOid
= CssmOid::required(oid
);
67 PolicyCursor::~PolicyCursor() throw()
75 bool PolicyCursor::next(SecPointer
<Policy
> &policy
)
77 while (theOidList
[mSearchPos
]) {
78 if (mOidGiven
&& mOid
!= *theOidList
[mSearchPos
]) {
80 continue; // no oid match
82 // ignoring mValue - not used by current TP
83 policy
= new Policy(theOneTP(), *theOidList
[mSearchPos
]);
84 mSearchPos
++; // advance cursor
85 return true; // return next match
87 return false; // end of table, no more matches