2 * Copyright (c) 2018 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 #import "keychain/ot/OTJoiningConfiguration.h"
28 NS_ASSUME_NONNULL_BEGIN
30 @implementation OTJoiningConfiguration
32 + (BOOL)supportsSecureCoding {
36 - (instancetype)initWithProtocolType:(NSString*)protocolType
37 uniqueDeviceID:(NSString*)uniqueDeviceID
38 uniqueClientID:(NSString*)uniqueClientID
39 containerName:(NSString* _Nullable)containerName
40 contextID:(NSString*)contextID
42 isInitiator:(BOOL)isInitiator
44 return [self initWithProtocolType:protocolType
45 uniqueDeviceID:uniqueDeviceID
46 uniqueClientID:uniqueClientID
47 pairingUUID:[NSUUID UUID].UUIDString
48 containerName:containerName
51 isInitiator:isInitiator];
54 - (instancetype)initWithProtocolType:(NSString*)protocolType
55 uniqueDeviceID:(NSString*)uniqueDeviceID
56 uniqueClientID:(NSString*)uniqueClientID
57 pairingUUID:(NSString* _Nullable)pairingUUID
58 containerName:(NSString* _Nullable)containerName
59 contextID:(NSString*)contextID
61 isInitiator:(BOOL)isInitiator
65 self.protocolType = protocolType;
66 self.uniqueDeviceID = uniqueDeviceID;
67 self.uniqueClientID = uniqueClientID;
68 self.contextID = contextID;
69 self.containerName = containerName;
70 self.isInitiator = isInitiator;
71 self.pairingUUID = pairingUUID;
79 - (void)encodeWithCoder:(nonnull NSCoder *)coder {
80 [coder encodeObject:_protocolType forKey:@"protocolType"];
81 [coder encodeObject:_uniqueClientID forKey:@"uniqueClientID"];
82 [coder encodeObject:_uniqueDeviceID forKey:@"uniqueDeviceID"];
83 [coder encodeObject:_contextID forKey:@"contextID"];
84 [coder encodeObject:_containerName forKey:@"containerName"];
85 [coder encodeBool:_isInitiator forKey:@"isInitiator"];
86 [coder encodeObject:_pairingUUID forKey:@"pairingUUID"];
87 [coder encodeInt64:_epoch forKey:@"epoch"];
88 [coder encodeInt64:_timeout forKey:@"timeout"];
91 - (nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder {
94 _protocolType = [decoder decodeObjectOfClass:[NSString class] forKey:@"protocolType"];
95 _uniqueClientID = [decoder decodeObjectOfClass:[NSString class] forKey:@"uniqueClientID"];
96 _uniqueDeviceID = [decoder decodeObjectOfClass:[NSString class] forKey:@"uniqueDeviceID"];
97 _contextID = [decoder decodeObjectOfClass:[NSString class] forKey:@"contextID"];
98 _containerName = [decoder decodeObjectOfClass:[NSString class] forKey:@"containerName"];
99 _isInitiator = [decoder decodeBoolForKey:@"isInitiator"];
100 _pairingUUID = [decoder decodeObjectOfClass:[NSString class] forKey:@"pairingUUID"];
101 _epoch = [decoder decodeInt64ForKey:@"epoch"];
102 _timeout = [decoder decodeInt64ForKey:@"timeout"];
108 NS_ASSUME_NONNULL_END
110 #endif /* __OBJC2__ */