88#import " LoginRadiusSocialLoginManager.h"
99#import " LRTouchIDAuth.h"
1010#import " LRSession.h"
11+ #import " LoginRadiusEncryptor.h"
12+
1113
1214static NSString * const LoginRadiusPlistFileName = @" LoginRadius" ;
1315static NSString * const LoginRadiusAPIKey = @" apiKey" ;
1719static NSString * const LoginRadiusVerificationUrl = @" verificationUrl" ;
1820static NSString * const LoginRadiusKeychain = @" useKeychain" ;
1921static NSString * const LoginRadiusCustomDomain = @" customDomain" ;
22+ static NSString * const LoginRadiusSetEncryption = @" setEncryption" ;
23+
2024
2125
2226@interface LoginRadiusSDK ()
@@ -35,6 +39,10 @@ - (instancetype)init {
3539 NSString *siteName = values[LoginRadiusSiteName];
3640 NSString *verificationUrl = values[LoginRadiusVerificationUrl] ? values[LoginRadiusVerificationUrl] : @" https://auth.lrcontent.com/mobile/verification/index.html" ;
3741 BOOL useKeychain = values[LoginRadiusKeychain] ? [values[LoginRadiusKeychain] boolValue ] : NO ; // if nil set to false
42+
43+ BOOL setEncryption = values[LoginRadiusSetEncryption] ? [values[LoginRadiusSetEncryption] boolValue ] : NO ; // if nil set to false
44+
45+
3846 NSString *customDomain = values[LoginRadiusCustomDomain] ? values[LoginRadiusCustomDomain] : @" " ;
3947
4048 if ([apiKey isEqualToString: @" <Your LoginRadius ApiKey>" ] || [apiKey isEqualToString: @" " ]){
@@ -45,6 +53,16 @@ - (instancetype)init {
4553 NSAssert (apiKey, @" apiKey cannot be null in LoginRadius.plist" );
4654 NSAssert (siteName, @" siteName cannot be null in LoginRadius.plist" );
4755
56+ // apiKey is stored in secure enclave if setEncryption set to true in LoginRadius.plist .
57+ if (setEncryption == true ){
58+
59+ NSData *key = [apiKey dataUsingEncoding: NSUTF8StringEncoding];
60+ NSData *decr = [[LoginRadiusEncryptor sharedInstance ]EncryptDecryptText:key];
61+
62+ NSString *myString;
63+ myString = [[NSString alloc ] initWithData: decr encoding: NSASCIIStringEncoding];
64+ }
65+
4866 if (!registrationSource){
4967 registrationSource = @" iOS" ;
5068 }
@@ -62,6 +80,7 @@ - (instancetype)init {
6280 _socialLoginManager = [[LoginRadiusSocialLoginManager alloc ] init ];
6381 _touchIDManager = [[LRTouchIDAuth alloc ] init ];
6482 _customHeaders = customHeaders;
83+ _setEncryption = setEncryption;
6584 }
6685
6786 return self;
@@ -82,6 +101,7 @@ + (instancetype)instance {
82101 return [[LoginRadiusSDK alloc ] init ];
83102}
84103
104+
85105+ (BOOL ) logout {
86106
87107 BOOL is = [(LRSession *)[[self sharedInstance ] session ] logout ];
@@ -115,16 +135,23 @@ + (NSString*) customDomain {
115135+ (BOOL ) useKeychain {
116136 return [LoginRadiusSDK sharedInstance ].useKeychain ;
117137}
138+
139+
140+
118141+ (NSDictionary *) customHeaders {
119142 return [LoginRadiusSDK sharedInstance ].customHeaders ;
120143}
121144
145+ + (BOOL ) setEncryption {
146+ return [LoginRadiusSDK sharedInstance ].setEncryption ;
147+ }
122148
123149#pragma mark Application Delegate methods
124150
125151- (void )applicationLaunchedWithOptions : (NSDictionary *)launchOptions {
126152 [self .socialLoginManager applicationLaunchedWithOptions: launchOptions];
127153
154+
128155}
129156
130157- (BOOL )application : (UIApplication *)application openURL : (NSURL *)url sourceApplication : (NSString *)sourceApplication annotation : (id )annotation {
@@ -135,4 +162,5 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
135162- (void )applicationDidBecomeActive : (UIApplication *)application {
136163}
137164
165+
138166@end
0 commit comments