]> git.saurik.com Git - apple/security.git/blob - keychain/SecureObjectSync/CKDSimulatedStore.m
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / SecureObjectSync / CKDSimulatedStore.m
1 //
2 // CKDSimulatedStore.m
3 // Security
4 //
5
6 #import "CKDSimulatedStore.h"
7 #import "CKDKVSProxy.h"
8
9 #include "SOSCloudKeychainConstants.h"
10 #include <utilities/debugging.h>
11
12 #import "SyncedDefaults/SYDConstants.h"
13 #include <os/activity.h>
14
15 @interface CKDSimulatedStore ()
16 @property (readwrite, weak) UbiqitousKVSProxy* proxy;
17 @property (readwrite) NSMutableDictionary<NSString*, NSObject*>* data;
18 @end
19
20 @implementation CKDSimulatedStore
21
22 + (instancetype)simulatedInterface {
23 return [[CKDSimulatedStore alloc] init];
24 }
25
26 - (instancetype)init {
27 if ((self = [super init])) {
28 self.proxy = nil;
29 self.data = [NSMutableDictionary<NSString*, NSObject*> dictionary];
30 }
31 return self;
32 }
33
34 - (void) connectToProxy: (UbiqitousKVSProxy*) proxy {
35 _proxy = proxy;
36 }
37
38 - (void)setObject:(id)obj forKey:(NSString*)key {
39 [self.data setValue: obj forKey: key];
40 }
41
42 - (NSDictionary<NSString *, id>*) copyAsDictionary {
43 return self.data;
44 }
45
46 - (void)addEntriesFromDictionary:(NSDictionary<NSString*, NSObject*> *)otherDictionary {
47 [otherDictionary enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSObject * _Nonnull obj, BOOL * _Nonnull stop) {
48 [self setObject:obj forKey:key];
49 }];
50 }
51
52 - (id)objectForKey:(NSString*)key {
53 return [self.data objectForKey:key];
54 }
55
56 - (void)removeObjectForKey:(NSString*)key {
57 return [self.data removeObjectForKey:key];
58 }
59
60 - (void)removeAllObjects {
61 [self.data removeAllObjects];
62 }
63
64 - (void)pushWrites:(NSArray<NSString*>*)keys requiresForceSync:(BOOL)requiresForceSync
65 {
66 }
67
68 - (void)addOneToOutGoing{
69
70 }
71 - (BOOL) pullUpdates:(NSError **)failure
72 {
73 return true;
74 }
75
76 - (void)remoteSetObject:(id)obj forKey:(NSString*)key
77 {
78 [self.data setObject:obj forKey:key];
79
80 [self.proxy storeKeysChanged: [NSSet setWithObject:key] initial: NO];
81 }
82
83 - (void)perfCounters:(void(^)(NSDictionary *counters))callback
84 {
85 callback(@{});
86 }
87
88 @end