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 pairingUUID:(NSString* _Nullable)pairingUUID
40 containerName:(NSString* _Nullable)containerName
41 contextID:(NSString*)contextID
43 isInitiator:(BOOL)isInitiator
45 if ((self = [super init])) {
46 self.protocolType = protocolType;
47 self.uniqueDeviceID = uniqueDeviceID;
48 self.uniqueClientID = uniqueClientID;
49 self.contextID = contextID;
50 self.containerName = containerName;
51 self.isInitiator = isInitiator;
52 self.pairingUUID = pairingUUID;
60 - (void)encodeWithCoder:(nonnull NSCoder *)coder {
61 [coder encodeObject:_protocolType forKey:@"protocolType"];
62 [coder encodeObject:_uniqueClientID forKey:@"uniqueClientID"];
63 [coder encodeObject:_uniqueDeviceID forKey:@"uniqueDeviceID"];
64 [coder encodeObject:_contextID forKey:@"contextID"];
65 [coder encodeObject:_containerName forKey:@"containerName"];
66 [coder encodeBool:_isInitiator forKey:@"isInitiator"];
67 [coder encodeObject:_pairingUUID forKey:@"pairingUUID"];
68 [coder encodeInt64:_epoch forKey:@"epoch"];
69 [coder encodeInt64:_timeout forKey:@"timeout"];
72 - (nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder {
73 if ((self = [super init])) {
74 _protocolType = [decoder decodeObjectOfClass:[NSString class] forKey:@"protocolType"];
75 _uniqueClientID = [decoder decodeObjectOfClass:[NSString class] forKey:@"uniqueClientID"];
76 _uniqueDeviceID = [decoder decodeObjectOfClass:[NSString class] forKey:@"uniqueDeviceID"];
77 _contextID = [decoder decodeObjectOfClass:[NSString class] forKey:@"contextID"];
78 _containerName = [decoder decodeObjectOfClass:[NSString class] forKey:@"containerName"];
79 _isInitiator = [decoder decodeBoolForKey:@"isInitiator"];
80 _pairingUUID = [decoder decodeObjectOfClass:[NSString class] forKey:@"pairingUUID"];
81 _epoch = [decoder decodeInt64ForKey:@"epoch"];
82 _timeout = [decoder decodeInt64ForKey:@"timeout"];
90 #endif /* __OBJC2__ */