2 * Copyright (c) 2002-2004,2011,2014-2015 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #include <Security/SecIdentitySearch.h>
25 #include <Security/SecIdentitySearchPriv.h>
26 #include <Security/SecPolicyPriv.h>
27 #include <security_keychain/IdentityCursor.h>
28 #include <security_keychain/Identity.h>
30 #include "SecBridge.h"
34 SecIdentitySearchGetTypeID(void)
38 return gTypes().IdentityCursor
.typeID
;
40 END_SECAPI1(_kCFRuntimeNotATypeID
)
45 SecIdentitySearchCreate(
46 CFTypeRef keychainOrArray
,
48 SecIdentitySearchRef
*searchRef
)
54 StorageManager::KeychainList keychains
;
55 globals().storageManager
.optionalSearchList(keychainOrArray
, keychains
);
56 SecPointer
<IdentityCursor
> identityCursor(new IdentityCursor (keychains
, keyUsage
));
57 *searchRef
= identityCursor
->handle();
62 OSStatus
SecIdentitySearchCreateWithAttributes(
63 CFDictionaryRef attributes
,
64 SecIdentitySearchRef
* searchRef
)
69 // %%%TBI This function needs a new form of IdentityCursor that takes
70 // the supplied attributes as input.
73 StorageManager::KeychainList keychains
;
74 globals().storageManager
.getSearchList(keychains
);
75 SecPointer
<IdentityCursor
> identityCursor(new IdentityCursor (keychains
, 0));
76 *searchRef
= identityCursor
->handle();
81 OSStatus
SecIdentitySearchCreateWithPolicy(
85 CFTypeRef keychainOrArray
,
86 Boolean returnOnlyValidIdentities
,
87 SecIdentitySearchRef
* searchRef
)
93 StorageManager::KeychainList keychains
;
94 globals().storageManager
.optionalSearchList(keychainOrArray
, keychains
);
95 CFRef
<SecPolicyRef
> policyRef
= SecPolicyCreateItemImplInstance(policy
);
96 SecPointer
<IdentityCursorPolicyAndID
> identityCursor(new IdentityCursorPolicyAndID (keychains
, keyUsage
, idString
, policyRef
, returnOnlyValidIdentities
));
98 *searchRef
= identityCursor
->handle();
104 SecIdentitySearchCopyNext(
105 SecIdentitySearchRef searchRef
,
106 SecIdentityRef
*identityRef
)
110 RequiredParam(identityRef
);
111 SecPointer
<Identity
> identityPtr
;
112 if (!IdentityCursor::required(searchRef
)->next(identityPtr
))
113 return errSecItemNotFound
;
115 *identityRef
= identityPtr
->handle();