]> git.saurik.com Git - apple/security.git/blob - keychain/ot/OTJoiningConfiguration.m
Security-59754.80.3.tar.gz
[apple/security.git] / keychain / ot / OTJoiningConfiguration.m
1 /*
2 * Copyright (c) 2018 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 "keychain/ot/OTJoiningConfiguration.h"
25
26 #if __OBJC2__
27
28 NS_ASSUME_NONNULL_BEGIN
29
30 @implementation OTJoiningConfiguration
31
32 + (BOOL)supportsSecureCoding {
33 return YES;
34 }
35
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
42 epoch:(uint64_t)epoch
43 isInitiator:(BOOL)isInitiator
44 {
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;
53 self.epoch = epoch;
54
55 _timeout = 0;
56 }
57 return self;
58 }
59
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"];
70 }
71
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"];
83 }
84 return self;
85 }
86
87 @end
88 NS_ASSUME_NONNULL_END
89
90 #endif /* __OBJC2__ */