]> git.saurik.com Git - apple/security.git/blobdiff - cdsa/cdsa_utilities/cssmcred.cpp
Security-177.tar.gz
[apple/security.git] / cdsa / cdsa_utilities / cssmcred.cpp
index d65d53715d0367c2d9f7ba7a3d4b5f2667340a45..781e47d617cb5880c62ec9c363043099e35c27a4 100644 (file)
@@ -38,6 +38,27 @@ const AccessCredentials &AccessCredentials::null =
 #endif
 
 
 #endif
 
 
+//
+// Scan a SampleGroup for samples with a given CSSM_SAMPLE_TYPE.
+// Collect all matching samples into a list (which is cleared to begin with).
+// Return true if any were found, false if none.
+// Throw if any of the samples are obviously malformed.
+//
+bool SampleGroup::collect(CSSM_SAMPLE_TYPE sampleType, list<CssmSample> &matches) const
+{
+       for (uint32 n = 0; n < length(); n++) {
+               TypedList sample = (*this)[n];
+               sample.checkProper();
+               if (sample.type() == sampleType) {
+                       sample.snip();  // skip sample type
+                       matches.push_back(sample);
+               }
+       }
+       return !matches.empty();
+}
+
+
+
 //
 // AutoCredentials self-constructing credentials structure
 //
 //
 // AutoCredentials self-constructing credentials structure
 //