blob: 3a06ac66adf538a02fb39dee423b69404c297682 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "FIRAuthTokenResult_Internal.h"
NS_ASSUME_NONNULL_BEGIN
/** @var kExpirationDateKey
@brief The key used to encode the expirationDate property for NSSecureCoding.
*/
static NSString *const kExpirationDateKey = @"expiratinDate";
/** @var kTokenKey
@brief The key used to encode the token property for NSSecureCoding.
*/
static NSString *const kTokenKey = @"token";
/** @var kAuthDateKey
@brief The key used to encode the authDate property for NSSecureCoding.
*/
static NSString *const kAuthDateKey = @"authDate";
/** @var kIssuedDateKey
@brief The key used to encode the issuedDate property for NSSecureCoding.
*/
static NSString *const kIssuedDateKey = @"issuedDate";
/** @var kSignInProviderKey
@brief The key used to encode the signInProvider property for NSSecureCoding.
*/
static NSString *const kSignInProviderKey = @"signInProvider";
/** @var kClaimsKey
@brief The key used to encode the claims property for NSSecureCoding.
*/
static NSString *const kClaimsKey = @"claims";
@implementation FIRAuthTokenResult
- (instancetype)initWithToken:(NSString *)token
expirationDate:(NSDate *)expirationDate
authDate:(NSDate *)authDate
issuedAtDate:(NSDate *)issuedAtDate
signInProvider:(NSString *)signInProvider
claims:(NSDictionary *)claims {
self = [super init];
if (self) {
_token = token;
_expirationDate = expirationDate;
_authDate = authDate;
_issuedAtDate = issuedAtDate;
_signInProvider = signInProvider;
_claims = claims;
}
return self;
}
#pragma mark - NSSecureCoding
+ (BOOL)supportsSecureCoding {
return YES;
}
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
NSString *token =
[aDecoder decodeObjectOfClass:[NSDate class] forKey:kTokenKey];
NSDate *expirationDate =
[aDecoder decodeObjectOfClass:[NSDate class] forKey:kExpirationDateKey];
NSDate *authDate =
[aDecoder decodeObjectOfClass:[NSDate class] forKey:kAuthDateKey];
NSDate *issuedAtDate =
[aDecoder decodeObjectOfClass:[NSDate class] forKey:kAuthDateKey];
NSString *signInProvider =
[aDecoder decodeObjectOfClass:[NSString class] forKey:kSignInProviderKey];
NSDictionary<NSString *, NSString *> *claims =
[aDecoder decodeObjectOfClass:[NSDictionary<NSString *, NSString *> class] forKey:kClaimsKey];
return [self initWithToken:token
expirationDate:expirationDate
authDate:authDate
issuedAtDate:issuedAtDate
signInProvider:signInProvider
claims:claims];
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:_token forKey:kTokenKey];
[aCoder encodeObject:_expirationDate forKey:kExpirationDateKey];
[aCoder encodeObject:_authDate forKey:kAuthDateKey];
[aCoder encodeObject:_issuedAtDate forKey:kIssuedDateKey];
[aCoder encodeObject:_signInProvider forKey:kSignInProviderKey];
[aCoder encodeObject:_claims forKey:kClaimsKey];
}
@end
NS_ASSUME_NONNULL_END
|