FIRAppCheckToken.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2020 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. @implementation FIRAppCheckToken
  19. - (instancetype)initWithToken:(NSString *)token
  20. expirationDate:(NSDate *)expirationDate
  21. receivedAtDate:(NSDate *)receivedAtDate {
  22. self = [super init];
  23. if (self) {
  24. _token = [token copy];
  25. _expirationDate = expirationDate;
  26. _receivedAtDate = receivedAtDate;
  27. }
  28. return self;
  29. }
  30. - (instancetype)initWithToken:(NSString *)token expirationDate:(NSDate *)expirationDate {
  31. return [self initWithToken:token expirationDate:expirationDate receivedAtDate:[NSDate date]];
  32. }
  33. - (instancetype)initWithInternalToken:(GACAppCheckToken *)token {
  34. return [self initWithToken:token.token
  35. expirationDate:token.expirationDate
  36. receivedAtDate:token.receivedAtDate];
  37. }
  38. - (GACAppCheckToken *)internalToken {
  39. return [[GACAppCheckToken alloc] initWithToken:self.token
  40. expirationDate:self.expirationDate
  41. receivedAtDate:self.receivedAtDate];
  42. }
  43. @end
  44. NS_ASSUME_NONNULL_END