Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2019 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
 
17
#import <Foundation/Foundation.h>
18
 
19
NS_ASSUME_NONNULL_BEGIN
20
 
21
FOUNDATION_EXPORT NSString *const kGULKeychainUtilsErrorDomain;
22
 
23
/// Helper functions to access Keychain.
24
@interface GULKeychainUtils : NSObject
25
 
26
/** Fetches a keychain item data matching to the provided query.
27
 *  @param query A dictionary with Keychain query parameters. See docs for `SecItemCopyMatching` for
28
 * details.
29
 *  @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be
30
 * assigned with an error if there is.
31
 *  @returns Data for the first Keychain Item matching the provided query or `nil` if there is not
32
 * such an item (`outError` will be `nil` in this case) or an error occurred.
33
 */
34
+ (nullable NSData *)getItemWithQuery:(NSDictionary *)query
35
                                error:(NSError *_Nullable *_Nullable)outError;
36
 
37
/** Stores data to a Keychain Item matching to the provided query. An existing Keychain Item
38
 * matching the query parameters will be updated or a new will be created.
39
 *  @param item A Keychain Item data to store.
40
 *  @param query A dictionary with Keychain query parameters. See docs for `SecItemAdd` and
41
 * `SecItemUpdate` for details.
42
 *  @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be
43
 * assigned with an error if there is.
44
 *  @returns `YES` when data was successfully stored, `NO` otherwise.
45
 */
46
+ (BOOL)setItem:(NSData *)item
47
      withQuery:(NSDictionary *)query
48
          error:(NSError *_Nullable *_Nullable)outError;
49
 
50
/** Removes a Keychain Item matching to the provided query.
51
 *  @param query A dictionary with Keychain query parameters. See docs for `SecItemDelete` for
52
 * details.
53
 *  @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be
54
 * assigned with an error if there is.
55
 *  @returns `YES` if the item was removed successfully or doesn't exist, `NO` otherwise.
56
 */
57
+ (BOOL)removeItemWithQuery:(NSDictionary *)query error:(NSError *_Nullable *_Nullable)outError;
58
 
59
@end
60
 
61
NS_ASSUME_NONNULL_END