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 * CLCachedEntry.h - classes representing cached certs and CRLs.
22 * Created 9/1/2000 by Doug Mitchell.
23 * Copyright (c) 2000 by Apple Computer.
26 #ifndef _APPLE_X509_CL_CACHED_ENTRY_H_
27 #define _APPLE_X509_CL_CACHED_ENTRY_H_
29 #include <Security/cssmtype.h>
30 #include <Security/utilities.h>
31 #include <Security/cssmdata.h>
32 #include "DecodedCert.h"
33 #include "DecodedCrl.h"
36 * There is one of these per active cached object (cert or CRL).
37 * AppleX509CLSession keeps a map of these in cacheMap.
43 virtual ~CLCachedEntry() { }
44 CSSM_HANDLE
handle() { return mHandle
; }
49 class CLCachedCert
: public CLCachedEntry
53 DecodedCert
&c
) : mCert(c
) { }
55 DecodedCert
&cert() { return mCert
; }
57 /* decoded NSS format */
61 class CLCachedCRL
: public CLCachedEntry
65 DecodedCrl
&c
) : mCrl(c
) { }
67 DecodedCrl
&crl() { return mCrl
; }
69 /* decoded NSS format */
74 * An active query, always associated with a CLCachedEntry.
75 * AppleX509CLSession keeps a map of these in queryMap.
77 * In the case of a CLCachedEntry created by an explicit {Cert,CRL}Cache op,
78 * there can be multiple queries active for a given cached cert. In
79 * the *GetFirst*FieldValue case, there is a one-to-one relationship between
80 * the CLQUery and its associated cached object.
82 * Out of paranoia in the {Cert,CRL}Cache case, we store the handle of
83 * the associated cached object, not a ref to the object, in case the
84 * cached object has been deleted via *AbortCache. We could ref count,
85 * but that would require a lock in CLCachedEntry...looking up an object
86 * in the session's cache map should not be too expensive.
102 CSSM_HANDLE cachedObj
);
107 * Accessors - all member variables are invariant after creation, except
108 * for nextIndex which can only increment
110 CLQueryType
queryType() { return mQueryType
; }
111 const CssmOid
&fieldId() { return mFieldId
; }
112 unsigned nextIndex() { return mNextIndex
; }
113 void incrementIndex(){ mNextIndex
++; }
114 unsigned numFields() { return mNumFields
; }
115 bool fromCache() { return mFromCache
; }
116 CSSM_HANDLE
cachedObject() { return mCachedObject
; }
117 CSSM_HANDLE
handle() { return mHandle
;}
120 CLQueryType mQueryType
;
121 CssmAutoData mFieldId
; // thing we're searching for - may be empty
122 unsigned mNextIndex
; // index of next find op
123 unsigned mNumFields
; // total available
124 bool mFromCache
; // true : via CertGetFirstCachedFieldValue
125 // false : via CertGetFirstFieldValue
126 CSSM_HANDLE mCachedObject
; // of our associated cached cert/CRL
127 CSSM_HANDLE mHandle
; // ours
130 #endif /* _APPLE_X509_CL_CACHED_ENTRY_H_ */