]> git.saurik.com Git - apple/security.git/blob - sec/SOSCircle/CKBridge/SOSCloudKeychainClient.h
Security-55471.tar.gz
[apple/security.git] / sec / SOSCircle / CKBridge / SOSCloudKeychainClient.h
1 /*
2 * Copyright (c) 2012 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25 /*
26 * SOSCloudKeychainClient.h - Implementation of the transport layer from CKBridge to SOSAccount/SOSCircle
27 */
28
29 /*!
30 @header SOSCloudKeychainClient
31 The functions provided in SOSCloudTransport.h provide an interface
32 from CKBridge to SOSAccount/SOSCircle
33 */
34
35 #ifndef _SOSCLOUDKEYCHAINCLIENT_H_
36 #define _SOSCLOUDKEYCHAINCLIENT_H_
37
38 #include <CoreFoundation/CFArray.h>
39 #include <CoreFoundation/CFDictionary.h>
40 #include <CoreFoundation/CFError.h>
41 #include <dispatch/dispatch.h>
42
43 __BEGIN_DECLS
44
45
46 // MARK: ---------- SOSCloudTransport ----------
47
48 enum
49 {
50 kSOSObjectMallocFailed = 1,
51 kAddDuplicateEntry,
52 kSOSObjectNotFoundError = 1,
53 kSOSObjectCantBeConvertedToXPCObject,
54 kSOSOUnexpectedConnectionEvent,
55 kSOSOXPCErrorEvent,
56 kSOSOUnexpectedXPCEvent,
57 kSOSConnectionNotOpen
58 };
59
60 typedef void (^CloudItemsChangedBlock)(CFDictionaryRef values);
61 typedef void (^CloudKeychainReplyBlock)(CFDictionaryRef returnedValues, CFErrorRef error);
62
63 /* SOSCloudTransport protocol. */
64 typedef struct SOSCloudTransport *SOSCloudTransportRef;
65 struct SOSCloudTransport
66 {
67 void (*put)(SOSCloudTransportRef transport, CFDictionaryRef valuesToPut, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
68 void (*registerKeys)(SOSCloudTransportRef transport, CFArrayRef keysToGet, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock, CloudItemsChangedBlock notificationBlock);
69 bool (*updateKeys)(SOSCloudTransportRef transport, bool getNewKeysOnly, CFArrayRef alwaysKeys, CFArrayRef afterFirstUnlockKeys, CFArrayRef unlockedKeys, CFErrorRef *error);
70
71 void (*unregisterKeys)(SOSCloudTransportRef transport, CFArrayRef keysToUnregister, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
72
73 // Debug calls
74 void (*get)(SOSCloudTransportRef transport, CFArrayRef keysToGet, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
75 void (*getAll)(SOSCloudTransportRef transport, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
76 void (*synchronize)(SOSCloudTransportRef transport, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
77 void (*synchronizeAndWait)(SOSCloudTransportRef transport, CFArrayRef keysToGet, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
78
79 void (*clearAll)(SOSCloudTransportRef transport, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
80 void (*removeObjectForKey)(SOSCloudTransportRef transport, CFStringRef keyToRemove, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
81 void (*localNotification)(SOSCloudTransportRef transport, CFStringRef messageToUser, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
82 void (*setParams)(SOSCloudTransportRef transport, CFDictionaryRef paramsDict, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
83 void (*requestSyncWithAllPeers)(SOSCloudTransportRef transport, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
84
85 const void *itemsChangedBlock;
86 };
87
88 /* Call this function before calling any other function in this header to provide
89 an alternate transport, the default transport talks to CloudKeychainProxy via xpc. */
90 void SOSCloudKeychainSetTransport(SOSCloudTransportRef transport);
91
92
93 /*!
94 @function SOSCloudKeychainRegisterKeysAndGet
95 @abstract Register a set of keys-of-interest and optionally return their current values
96 @param keysToGet An array of CFStringRef keys to get/register
97 @param processQueue The replyBlock will be called via dispatch_async on this queue
98 @param replyBlock This will be called via dispatch_async
99 @discussion The replyBlock will be called asynchronously with the current values of
100 the registered keys. If an error occured, the error parameter to the replyBlock will
101 be filled in with an error. The caller should call CFRetain on the returned dictionary.
102 */
103 void SOSCloudKeychainRegisterKeysAndGet(CFArrayRef keysToGet, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock, CloudItemsChangedBlock notificationBlock);
104 bool SOSCloudKeychainUpdateKeys(bool getNewKeysOnly,
105 CFArrayRef alwaysKeys,
106 CFArrayRef afterFirstUnlockKeys,
107 CFArrayRef unlockedKeys,
108 CFErrorRef *error);
109 void SOSCloudKeychainUnRegisterKeys(CFArrayRef keysToUnregister, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
110
111 void SOSCloudKeychainPutObjectsInCloud(CFDictionaryRef objects, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
112
113 void SOSCloudKeychainSetItemsChangedBlock(CloudItemsChangedBlock itemsChangedBlock);
114
115 void SOSCloudKeychainUserNotification(CFStringRef messageToUser, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
116
117 void SOSCloudKeychainHandleUpdate(CFDictionaryRef update);
118 void SOSCloudKeychainSynchronizeAndWait(CFArrayRef keysToGet, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
119
120 // Debug only?
121
122 void SOSCloudKeychainGetObjectsFromCloud(CFArrayRef keysToGet, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
123 void SOSCloudKeychainSynchronize(dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
124 void SOSCloudKeychainClearAll(dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
125 void SOSCloudKeychainRemoveObjectForKey(CFStringRef keyToRemove, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
126 void SOSCloudKeychainGetAllObjectsFromCloud(dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
127
128 void SOSCloudKeychainSetParams(CFDictionaryRef paramsDict, dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
129 void SOSCloudKeychainRequestSyncWithAllPeers(dispatch_queue_t processQueue, CloudKeychainReplyBlock replyBlock);
130
131 void SOSCloudKeychainSetCallbackMethodXPC(void);
132
133 __END_DECLS
134
135 #endif /* !_SOSCLOUDKEYCHAINCLIENT_H_ */
136