暂无描述

FIRAuthKeychain.h 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2017 Google
  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 <Foundation/Foundation.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. @brief The protocol for permanant data storage.
  20. */
  21. @protocol FIRAuthStorage <NSObject>
  22. /** @fn initWithService:
  23. @brief Initialize a @c FIRAuthStorage instance.
  24. @param service The name of the storage service to use.
  25. @return An initialized @c FIRAuthStorage instance for the specified service.
  26. */
  27. - (id<FIRAuthStorage>)initWithService:(NSString *)service;
  28. /** @fn dataForKey:error:
  29. @brief Gets the data for @c key in the storage. The key is set for the attribute
  30. @c kSecAttrAccount of a generic password query.
  31. @param key The key to use.
  32. @param error The address to store any error that occurs during the process, if not NULL.
  33. If the operation was successful, its content is set to @c nil .
  34. @return The data stored in the storage for @c key, if any.
  35. */
  36. - (nullable NSData *)dataForKey:(NSString *)key error:(NSError **_Nullable)error;
  37. /** @fn setData:forKey:error:
  38. @brief Sets the data for @c key in the storage. The key is set for the attribute
  39. @c kSecAttrAccount of a generic password query.
  40. @param data The data to store.
  41. @param key The key to use.
  42. @param error The address to store any error that occurs during the process, if not NULL.
  43. @return Whether the operation succeeded or not.
  44. */
  45. - (BOOL)setData:(NSData *)data forKey:(NSString *)key error:(NSError **_Nullable)error;
  46. /** @fn removeDataForKey:error:
  47. @brief Removes the data for @c key in the storage. The key is set for the attribute
  48. @c kSecAttrAccount of a generic password query.
  49. @param key The key to use.
  50. @param error The address to store any error that occurs during the process, if not NULL.
  51. @return Whether the operation succeeded or not.
  52. */
  53. - (BOOL)removeDataForKey:(NSString *)key error:(NSError **_Nullable)error;
  54. @end
  55. /** @class FIRAuthKeychain
  56. @brief The utility class to manipulate data in iOS Keychain.
  57. */
  58. @interface FIRAuthKeychain : NSObject <FIRAuthStorage>
  59. @end
  60. NS_ASSUME_NONNULL_END