NetIQ Mobile SDK for iOS  2.0
Access Manager iOS Framework for OAuth & OIDC
MFSimpleKeychain.h
1 //
2 // MFSimpleKeychain.h
3 // MFAuthLib
4 //
5 // Created by MicroFocus on 4/4/17.
6 // Copyright © 2017 Microfocus. All rights reserved.
7 //
8 //
9 // Copyright (c) 2014 Auth0 (http://auth0.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a copy
12 // of this software and associated documentation files (the "Software"), to deal
13 // in the Software without restriction, including without limitation the rights
14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 // copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included in
19 // all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 // THE SOFTWARE.
28 
29 #import <Foundation/Foundation.h>
30 
34 
38 typedef NS_ENUM(NSInteger, MFSimpleKeychainItemAccessible) {
42  MFSimpleKeychainItemAccessibleWhenUnlocked = 0,
46  MFSimpleKeychainItemAccessibleAfterFirstUnlock,
50  MFSimpleKeychainItemAccessibleAlways,
54  MFSimpleKeychainItemAccessibleWhenPasscodeSetThisDeviceOnly,
58  MFSimpleKeychainItemAccessibleWhenUnlockedThisDeviceOnly,
62  MFSimpleKeychainItemAccessibleAfterFirstUnlockThisDeviceOnly,
66  MFSimpleKeychainItemAccessibleAlwaysThisDeviceOnly
67 };
68 
69 #define MFKeychainErrorDomain @"com.mf.simplekeychain"
70 
74 typedef NS_ENUM(NSInteger, MFSimpleKeychainError) {
78  MFSimpleKeychainErrorNoError = 0,
82  MFSimpleKeychainErrorUnimplemented = -4,
86  MFSimpleKeychainErrorWrongParameter = -50,
90  MFSimpleKeychainErrorAllocation = -108,
94  MFSimpleKeychainErrorNotAvailable = -25291,
98  MFSimpleKeychainErrorAuthFailed = -25293,
102  MFSimpleKeychainErrorDuplicateItem = -25299,
106  MFSimpleKeychainErrorItemNotFound = -25300,
110  MFSimpleKeychainErrorInteractionNotAllowed = -25308,
114  MFSimpleKeychainErrorDecode = -26275
115 };
116 
117 NS_ASSUME_NONNULL_BEGIN
118 
125 @interface MFSimpleKeychain : NSObject
126 
130 @property (readonly, nonatomic) NSString *service;
131 
135 @property (readonly, nullable, nonatomic) NSString *accessGroup;
136 
142 @property (assign, nonatomic) MFSimpleKeychainItemAccessible defaultAccessiblity;
143 
148 @property (assign, nonatomic) BOOL useAccessControl;
149 
153 
159 - (instancetype)init;
160 
168 - (instancetype)initWithService:(NSString *)service;
169 
178 - (instancetype)initWithService:(NSString *)service accessGroup:(nullable NSString *)accessGroup;
179 
183 
192 - (BOOL)setString:(NSString *)string forKey:(NSString *)key;
193 
202 - (BOOL)setData:(NSData *)data forKey:(NSString *)key;
203 
213 - (BOOL)setString:(NSString *)string forKey:(NSString *)key promptMessage:(nullable NSString *)message;
214 
224 - (BOOL)setData:(NSData *)data forKey:(NSString *)key promptMessage:(nullable NSString *)message;
225 
229 
237 - (BOOL)deleteEntryForKey:(NSString *)key;
238 
242 - (void)clearAll;
243 
247 
255 - (nullable NSString *)stringForKey:(NSString *)key;
256 
264 - (nullable NSData *)dataForKey:(NSString *)key;
265 
274 - (nullable NSString *)stringForKey:(NSString *)key promptMessage:(nullable NSString *)message;
275 
284 - (nullable NSData *)dataForKey:(NSString *)key promptMessage:(nullable NSString *)message;
285 
296 - (nullable NSData *)dataForKey:(NSString *)key promptMessage:(nullable NSString *)message error:(NSError **)err;
297 
305 - (BOOL)hasValueForKey:(NSString *)key;
306 
310 
317 
325 + (MFSimpleKeychain *)keychainWithService:(NSString *)service;
326 
335 + (MFSimpleKeychain *)keychainWithService:(NSString *)service accessGroup:(NSString *)accessGroup;
336 
337 @end
338 
339 NS_ASSUME_NONNULL_END
void clearAll()
Definition: MFSimpleKeychain.m:172
NSString * accessGroup
Definition: MFSimpleKeychain.h:135
MFSimpleKeychainItemAccessible defaultAccessiblity
Definition: MFSimpleKeychain.h:142
BOOL useAccessControl
Definition: MFSimpleKeychain.h:148
Definition: MFSimpleKeychain.h:125
NSString * service
Definition: MFSimpleKeychain.h:130
instancetype init()
Definition: MFSimpleKeychain.m:38
typedef NS_ENUM(NSInteger, OIDErrorCode)
The various error codes returned from the AppAuth library.
Definition: OIDError.h:96
MFSimpleKeychain * keychain()
Definition: MFSimpleKeychain.m:201