]> git.saurik.com Git - apple/security.git/blame - keychain/ckks/CKKSViewManager.h
Security-58286.1.32.tar.gz
[apple/security.git] / keychain / ckks / CKKSViewManager.h
CommitLineData
866f8763
A
1/*
2 * Copyright (c) 2016 Apple 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#import <Foundation/Foundation.h>
25#include <securityd/SecDbItem.h>
26#import "keychain/ckks/CKKS.h"
27
28#import "keychain/ckks/CKKSControlProtocol.h"
29#if OCTAGON
30#import "keychain/ckks/CloudKitDependencies.h"
31#import "keychain/ckks/CKKSAPSReceiver.h"
32#import "keychain/ckks/CKKSCKAccountStateTracker.h"
33#import "keychain/ckks/CKKSLockStateTracker.h"
34#import "keychain/ckks/CKKSRateLimiter.h"
35#import "keychain/ckks/CKKSNotifier.h"
36#import "keychain/ckks/CKKSCondition.h"
37#endif
38
39@class CKKSKeychainView, CKKSRateLimiter;
40
41#if !OCTAGON
42@interface CKKSViewManager : NSObject
43#else
44@interface CKKSViewManager : NSObject <CKKSControlProtocol>
45
46@property CKContainer* container;
47@property CKKSCKAccountStateTracker* accountTracker;
48@property CKKSLockStateTracker* lockStateTracker;
49@property bool initializeNewZones;
50
51// Signaled when SecCKKSInitialize is complete, as it's async and likes to fire after tests are complete
52@property CKKSCondition* completedSecCKKSInitialize;
53
54@property CKKSRateLimiter* globalRateLimiter;
55
56// Set this and all newly-created zones will wait to do setup until it completes.
57// this gives you a bit more control than initializedNewZones above.
58@property NSOperation* zoneStartupDependency;
59
60- (instancetype)initCloudKitWithContainerName: (NSString*) containerName usePCS:(bool)usePCS;
61- (instancetype)initWithContainerName: (NSString*) containerNamee
62 usePCS: (bool)usePCS
63 fetchRecordZoneChangesOperationClass: (Class<CKKSFetchRecordZoneChangesOperation>) fetchRecordZoneChangesOperationClass
64 modifySubscriptionsOperationClass: (Class<CKKSModifySubscriptionsOperation>) modifySubscriptionsOperationClass
65 modifyRecordZonesOperationClass: (Class<CKKSModifyRecordZonesOperation>) modifyRecordZonesOperationClass
66 apsConnectionClass: (Class<CKKSAPSConnection>) apsConnectionClass
67 nsnotificationCenterClass: (Class<CKKSNSNotificationCenter>) nsnotificationCenterClass
68 notifierClass: (Class<CKKSNotifier>) notifierClass
69 setupHold:(NSOperation*) setupHold;
70
71- (CKKSKeychainView*)findView:(NSString*)viewName;
72- (CKKSKeychainView*)findOrCreateView:(NSString*)viewName;
73+ (CKKSKeychainView*)findOrCreateView:(NSString*)viewName;
74- (void)setView: (CKKSKeychainView*) obj;
75- (void)clearView:(NSString*) viewName;
76
77- (NSDictionary<NSString *,NSString *>*)activeTLKs;
78
79// Call this to bring zones up (and to do so automatically in the future)
80- (void)initializeZones;
81
82- (NSString*)viewNameForItem: (SecDbItemRef) item;
83
84- (void) handleKeychainEventDbConnection: (SecDbConnectionRef) dbconn source:(SecDbTransactionSource)txionSource added: (SecDbItemRef) added deleted: (SecDbItemRef) deleted;
85
86-(void)setCurrentItemForAccessGroup:(SecDbItemRef)newItem
87 hash:(NSData*)newItemSHA1
88 accessGroup:(NSString*)accessGroup
89 identifier:(NSString*)identifier
90 viewHint:(NSString*)viewHint
91 replacing:(SecDbItemRef)oldItem
92 hash:(NSData*)oldItemSHA1
93 complete:(void (^) (NSError* operror)) complete;
94
95-(void)getCurrentItemForAccessGroup:(NSString*)accessGroup
96 identifier:(NSString*)identifier
97 viewHint:(NSString*)viewHint
98 fetchCloudValue:(bool)fetchCloudValue
99 complete:(void (^) (NSString* uuid, NSError* operror)) complete;
100
101- (NSString*)viewNameForAttributes: (NSDictionary*) item;
102
103- (void)registerSyncStatusCallback: (NSString*) uuid callback: (SecBoolNSErrorCallback) callback;
104
105// Cancels pending operations owned by this view manager
106- (void)cancelPendingOperations;
107
108// Use these to acquire (and set) the singleton
109+ (instancetype) manager;
110+ (instancetype) resetManager: (bool) reset setTo: (CKKSViewManager*) obj;
111
112// Called by XPC every 24 hours
113-(void)xpc24HrNotification;
114
115/* Interface to CCKS control channel */
116- (xpc_endpoint_t)xpcControlEndpoint;
117
118/* White-box testing only */
119- (CKKSKeychainView*)restartZone:(NSString*)viewName;
120
121// Returns the viewList for a CKKSViewManager
122+(NSSet*)viewList;
123
124// Notify sbd to re-backup.
125-(void)notifyNewTLKsInKeychain;
126+(void)syncBackupAndNotifyAboutSync;
127
128#endif // OCTAGON
129@end