#include <Security/utilities.h>
#include <Security/cssmlist.h>
#include <Security/cssmalloc.h>
+#include <list>
-#ifdef _CPP_CSSMCRED
-#pragma export on
-#endif
+namespace Security {
-namespace Security
-{
//
// PodWrappers for samples and sample groups
public:
CssmSample(const TypedList &list)
{ TypedSample = list; Verifier = NULL; }
- CssmSample(TypedList &list, const CssmSubserviceUid &ver)
+ CssmSample(const TypedList &list, const CssmSubserviceUid &ver)
{ TypedSample = list; Verifier = &ver; }
TypedList &value() { return TypedList::overlay(TypedSample); }
const CssmSample &operator [] (uint32 n) const
{ assert(n < length()); return CssmSample::overlay(Samples[n]); }
+
+public:
+ // extract all samples of a given sample type. return true if any found
+ // note that you get a shallow copy of the sample structures for temporary use ONLY
+ bool collect(CSSM_SAMPLE_TYPE sampleType, list<CssmSample> &samples) const;
};
//
class AccessCredentials : public PodWrapper<AccessCredentials, CSSM_ACCESS_CREDENTIALS> {
public:
- AccessCredentials() { memset(this, 0, sizeof(*this)); }
+ AccessCredentials() { clearPod(); }
const char *tag() const { return EntryTag; }
public:
static const AccessCredentials &null; // all null credential
+
+ // turn NULL into a null credential if needed
+ static const AccessCredentials *needed(const CSSM_ACCESS_CREDENTIALS *cred)
+ { return cred ? overlay(cred) : &null; }
};
template <class Action>
void walk(Action &operate, CssmSample &sample)
{
+ operate(sample);
walk(operate, sample.value());
if (sample.verifier())
walk(operate, sample.verifier());
template <class Action>
void walk(Action &operate, SampleGroup &samples)
{
- operate(samples.Samples, samples.length() * sizeof(CssmSample));
+ operate(samples);
+ operate.blob(const_cast<CSSM_SAMPLE * &>(samples.Samples),
+ samples.length() * sizeof(CSSM_SAMPLE));
for (uint32 n = 0; n < samples.length(); n++)
walk(operate, samples[n]);
}
CSSM_ACCESS_CREDENTIALS *walk(Action &operate, CSSM_ACCESS_CREDENTIALS * &cred)
{ return walk(operate, AccessCredentials::overlayVar(cred)); }
+template <class Action>
+AutoCredentials *walk(Action &operate, AutoCredentials * &cred)
+{ return (AutoCredentials *)walk(operate, (AccessCredentials * &)cred); }
-} // end namespace DataWalkers
+} // end namespace DataWalkers
} // end namespace Security
-#ifdef _CPP_CSSMCRED
-#pragma export off
-#endif
-
#endif //_CSSMCRED