2 * Copyright (c) 2016 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@
25 #import <Foundation/Foundation.h>
28 #import "Analytics/SFAnalytics.h"
29 #import "keychain/ot/OTManager.h"
30 #import "keychain/ot/OTContext.h"
31 #import "keychain/ot/OTFollowup.h"
32 #import "keychain/ot/OTControlProtocol.h"
33 #import "keychain/ot/OTSOSAdapter.h"
34 #import "keychain/ot/OTAuthKitAdapter.h"
35 #import "keychain/ot/OTDeviceInformationAdapter.h"
36 #import "keychain/ot/OTCuttlefishAccountStateHolder.h"
37 #import "keychain/escrowrequest/Framework/SecEscrowRequest.h"
38 #import "keychain/ckks/CKKSAccountStateTracker.h"
39 #include <securityd/SecDbItem.h>
40 #import <CoreCDP/CDPAccount.h>
41 NS_ASSUME_NONNULL_BEGIN
44 @
class OTCuttlefishContext
;
45 @
class OTClientStateMachine
;
46 @
class CKKSLockStateTracker
;
47 @
class CKKSAccountStateTracker
;
49 @interface OTManager
: NSObject
<OTControlProtocol
>
51 @
property (nonatomic
, readonly
) NSDate
*lastPostedCoreFollowUp
;
52 @
property (nonatomic
, readonly
) CKKSLockStateTracker
* lockStateTracker
;
53 @property id
<CKKSCloudKitAccountStateTrackingProvider
> accountStateTracker
;
57 -(instancetype
) initWithContext
:(OTContext
* _Nullable
)context
58 localStore
:(OTLocalStore
* _Nullable
)localStore
59 enroll
:(OTRamp
* _Nullable
)enroll
60 restore
:(OTRamp
* _Nullable
)restore
61 cfu
:(OTRamp
* _Nullable
)cfu
62 cfuScheduler
:(CKKSNearFutureScheduler
* _Nullable
)cfuScheduler
63 sosAdapter
:(id
<OTSOSAdapter
>)sosAdapter
64 authKitAdapter
:(id
<OTAuthKitAdapter
>)authKitAdapter
65 deviceInformationAdapter
:(id
<OTDeviceInformationAdapter
>)deviceInformationAdapter
66 apsConnectionClass
:(Class
<OctagonAPSConnection
>)apsConnectionClass
67 escrowRequestClass
:(Class
<SecEscrowRequestable
>)escrowRequestClass
68 loggerClass
:(Class
<SFAnalyticsProtocol
> _Nullable
)loggerClass
69 lockStateTracker
:(CKKSLockStateTracker
* _Nullable
)lockStateTracker
70 accountStateTracker
:(id
<CKKSCloudKitAccountStateTrackingProvider
>)accountStateTracker
71 cuttlefishXPCConnection
:(id
<NSXPCProxyCreating
> _Nullable
)cuttlefishXPCConnection
72 cdpd
:(id
<OctagonFollowUpControllerProtocol
>)cdpd
;
74 // Call this to start up the state machinery
75 - (void)initializeOctagon
;
76 - (void) moveToCheckTrustedStateForContainer
:(NSString
* _Nullable
)containerName context
:(NSString
*)context
;
78 + (instancetype _Nullable
)manager
;
79 + (instancetype _Nullable
)resetManager
:(bool)reset to
:(OTManager
* _Nullable
)obj
;
80 - (void)xpc24HrNotification
:(NSString
* _Nullable
)containerName context
:(NSString
*)context skipRateLimitingCheck
:(BOOL
)skipRateLimitingCheck reply
:(void (^)(NSError
*error
))reply
;
82 -(BOOL
)scheduledCloudKitRampCheck
:(NSError
**)error
;
84 - (OTCuttlefishContext
*)contextForContainerName
:(NSString
* _Nullable
)containerName
85 contextID
:(NSString
*)contextID
86 sosAdapter
:(id
<OTSOSAdapter
>)sosAdapter
87 authKitAdapter
:(id
<OTAuthKitAdapter
>)authKitAdapter
88 lockStateTracker
:(CKKSLockStateTracker
*)lockStateTracker
89 accountStateTracker
:(id
<CKKSCloudKitAccountStateTrackingProvider
>)accountStateTracker
90 deviceInformationAdapter
:(id
<OTDeviceInformationAdapter
>)deviceInformationAdapter
;
92 - (OTCuttlefishContext
*)contextForContainerName
:(NSString
* _Nullable
)containerName
93 contextID
:(NSString
*)contextID
;
95 - (void)removeContextForContainerName
:(NSString
*)containerName
96 contextID
:(NSString
*)contextID
;
98 - (OTClientStateMachine
*)clientStateMachineForContainerName
:(NSString
* _Nullable
)containerName
99 contextID
:(NSString
*)contextID
100 clientName
:(NSString
*)clientName
;
102 -(BOOL
)ghostbustByMidEnabled
;
103 -(BOOL
)ghostbustBySerialEnabled
;
104 -(BOOL
)ghostbustByAgeEnabled
;
106 -(void)restore
:(NSString
* _Nullable
)containerName
107 contextID
:(NSString
*)contextID
108 bottleSalt
:(NSString
*)bottleSalt
109 entropy
:(NSData
*)entropy
110 bottleID
:(NSString
*)bottleID
111 reply
:(void (^)(NSError
* _Nullable
))reply
;
113 - (void)createRecoveryKey
:(NSString
* _Nullable
)containerName
114 contextID
:(NSString
*)contextID
115 recoveryKey
:(NSString
*)recoveryKey
116 reply
:(void (^)( NSError
* _Nullable
))reply
;
118 - (void)joinWithRecoveryKey
:(NSString
* _Nullable
)containerName
119 contextID
:(NSString
*)contextID
120 recoveryKey
:(NSString
*)recoveryKey
121 reply
:(void (^)(NSError
* _Nullable
))reply
;
123 - (void)allContextsHalt
;
124 - (void)allContextsDisablePendingFlags
;
125 - (bool)allContextsPause
:(uint64_t)within
;
127 - (void)waitForOctagonUpgrade
:(NSString
* _Nullable
)container
128 context
:(NSString
*)context
129 reply
:(void (^)(NSError
* _Nullable error
))reply
;
131 // Metrics and analytics
132 - (void)postCDPFollowupResult
:(BOOL
)success
133 type
:(OTCliqueCDPContextType
)type
134 error
:(NSError
* _Nullable
)error
135 containerName
:(NSString
* _Nullable
)containerName
136 contextName
:(NSString
*)contextName
137 reply
:(void (^)(NSError
*error
))reply
;
140 - (void)setSOSEnabledForPlatformFlag
:(bool) value
;
142 NS_ASSUME_NONNULL_END