-
Notifications
You must be signed in to change notification settings - Fork 67
SDK- 5154: New Encryption Level High #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 3 commits
377310d
f263a47
2573f5c
311f67a
8ae7886
5bace36
a5c2315
728e8de
ca87908
3d2ef3b
823564f
6fdebc8
72c5bf0
440db06
4553883
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2033,21 +2033,60 @@ - (void)inflateQueuesAsync { | |
| } | ||
|
|
||
| - (void)inflateEventsQueue { | ||
| self.eventsQueue = (NSMutableArray *)[CTPreferences unarchiveFromFile:[self eventsFileName] ofType:[NSMutableArray class] removeFile:YES]; | ||
| if (!self.eventsQueue || [self isMuted]) { | ||
| // If the previous encryption level was 2/high, decrypt the object | ||
| BOOL wasEncrypted = (self.config.cryptManager.previousEncryptionLevel == CleverTapEncryptionHigh); | ||
|
|
||
| if (wasEncrypted) { | ||
| // File was encrypted, so decrypt when reading | ||
| self.eventsQueue = (NSMutableArray *)[self.config.cryptManager decryptObject: | ||
| [CTPreferences unarchiveFromFile:[self eventsFileName] | ||
| ofType:[NSMutableArray class] | ||
| removeFile:YES]]; | ||
| } else { | ||
| // File was stored raw | ||
| self.eventsQueue = (NSMutableArray *)[CTPreferences unarchiveFromFile: | ||
| [self eventsFileName] ofType:[NSMutableArray class] removeFile:YES]; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Queue Decryption Fails Due to Incorrect Type HandlingThe Additional Locations (2) |
||
|
|
||
| // fallback incase decryption fails | ||
| if (!self.eventsQueue || ![self.eventsQueue isKindOfClass:[NSMutableArray class]] || [self isMuted]) { | ||
| self.eventsQueue = [NSMutableArray array]; | ||
| } | ||
| } | ||
|
|
||
| - (void)inflateProfileQueue { | ||
| self.profileQueue = (NSMutableArray *)[CTPreferences unarchiveFromFile:[self profileEventsFileName] ofType:[NSMutableArray class] removeFile:YES]; | ||
| // If the previous encryption level was 2/high, decrypt the object | ||
| BOOL wasEncrypted = (self.config.cryptManager.previousEncryptionLevel == CleverTapEncryptionHigh); | ||
|
|
||
| if (wasEncrypted) { | ||
| // File was encrypted, so decrypt when reading | ||
| self.profileQueue = (NSMutableArray *)[self.config.cryptManager decryptObject: | ||
| [CTPreferences unarchiveFromFile:[self profileEventsFileName] | ||
| ofType:[NSMutableArray class] | ||
| removeFile:YES]]; | ||
| } else { | ||
| // File was stored raw | ||
| self.profileQueue = (NSMutableArray *)[CTPreferences unarchiveFromFile:[self profileEventsFileName] ofType:[NSMutableArray class] removeFile:YES]; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Queue Initialization Fails Without Type CheckThe Additional Locations (1) |
||
| if (!self.profileQueue || [self isMuted]) { | ||
| self.profileQueue = [NSMutableArray array]; | ||
| } | ||
| } | ||
|
|
||
| - (void)inflateNotificationsQueue { | ||
| self.notificationsQueue = (NSMutableArray *)[CTPreferences unarchiveFromFile:[self notificationsFileName] ofType:[NSMutableArray class] removeFile:YES]; | ||
| // If the previous encryption level was 2/high, decrypt the object | ||
| BOOL wasEncrypted = (self.config.cryptManager.previousEncryptionLevel == CleverTapEncryptionHigh); | ||
|
|
||
| if (wasEncrypted) { | ||
| // File was encrypted, so decrypt when reading | ||
| self.notificationsQueue = (NSMutableArray *)[self.config.cryptManager decryptObject: | ||
| [CTPreferences unarchiveFromFile:[self notificationsFileName] | ||
| ofType:[NSMutableArray class] | ||
| removeFile:YES]]; | ||
| } else { | ||
| // File was stored raw | ||
| self.notificationsQueue = (NSMutableArray *)[CTPreferences unarchiveFromFile:[self notificationsFileName] ofType:[NSMutableArray class] removeFile:YES]; | ||
| } | ||
| if (!self.notificationsQueue || [self isMuted]) { | ||
| self.notificationsQueue = [NSMutableArray array]; | ||
| } | ||
|
|
@@ -2078,6 +2117,7 @@ - (void)persistOrClearQueues { | |
| if ([self isMuted]) { | ||
| [self clearQueues]; | ||
| } else { | ||
| // encrypt if level has been changed to 2/high | ||
| [self persistProfileQueue]; | ||
| [self persistEventsQueue]; | ||
| [self persistNotificationsQueue]; | ||
|
|
@@ -2086,27 +2126,36 @@ - (void)persistOrClearQueues { | |
|
|
||
| - (void)persistEventsQueue { | ||
| NSString *fileName = [self eventsFileName]; | ||
| NSMutableArray *eventsCopy; | ||
| id eventsCopy; | ||
| @synchronized (self) { | ||
| eventsCopy = [NSMutableArray arrayWithArray:[self.eventsQueue copy]]; | ||
| if (self.config.encryptionLevel == CleverTapEncryptionHigh) { | ||
| eventsCopy = [self.config.cryptManager encryptObject:eventsCopy]; | ||
| } | ||
| } | ||
| [CTPreferences archiveObject:eventsCopy forFileName:fileName config:_config]; | ||
| } | ||
|
|
||
| - (void)persistProfileQueue { | ||
| NSString *fileName = [self profileEventsFileName]; | ||
| NSMutableArray *profileEventsCopy; | ||
| id profileEventsCopy; | ||
| @synchronized (self) { | ||
| profileEventsCopy = [NSMutableArray arrayWithArray:[self.profileQueue copy]]; | ||
| if (self.config.encryptionLevel == CleverTapEncryptionHigh) { | ||
| profileEventsCopy = [self.config.cryptManager encryptObject:profileEventsCopy]; | ||
| } | ||
| } | ||
| [CTPreferences archiveObject:profileEventsCopy forFileName:fileName config:_config]; | ||
| } | ||
|
|
||
| - (void)persistNotificationsQueue { | ||
| NSString *fileName = [self notificationsFileName]; | ||
| NSMutableArray *notificationsCopy; | ||
| id notificationsCopy; | ||
| @synchronized (self) { | ||
| notificationsCopy = [NSMutableArray arrayWithArray:[self.notificationsQueue copy]]; | ||
| if (self.config.encryptionLevel == CleverTapEncryptionHigh) { | ||
| notificationsCopy = [self.config.cryptManager encryptObject:notificationsCopy]; | ||
| } | ||
| } | ||
| [CTPreferences archiveObject:notificationsCopy forFileName:fileName config:_config]; | ||
| } | ||
|
|
@@ -3652,7 +3701,7 @@ - (void)initializeInboxWithCallback:(CleverTapInboxSuccessBlock)callback { | |
| return; | ||
| } | ||
| if (self.deviceInfo.deviceId) { | ||
| self.inboxController = [[CTInboxController alloc] initWithAccountId: [self.config.accountId copy] guid: [self.deviceInfo.deviceId copy]]; | ||
| self.inboxController = [[CTInboxController alloc] initWithAccountId: [self.config.accountId copy] guid: [self.deviceInfo.deviceId copy] encryptionLevel:self.config.encryptionLevel previousEncryptionLevel:self.config.cryptManager.previousEncryptionLevel encryptionManager:self.config.cryptManager]; | ||
| self.inboxController.delegate = self; | ||
| [CTUtils runSyncMainQueue: ^{ | ||
| callback(self.inboxController.isInitialized); | ||
|
|
@@ -3807,7 +3856,7 @@ - (void)dismissAppInbox { | |
|
|
||
| - (void)_resetInbox { | ||
| if (self.inboxController && self.inboxController.isInitialized && self.deviceInfo.deviceId) { | ||
| self.inboxController = [[CTInboxController alloc] initWithAccountId: [self.config.accountId copy] guid: [self.deviceInfo.deviceId copy]]; | ||
| self.inboxController = [[CTInboxController alloc] initWithAccountId: [self.config.accountId copy] guid: [self.deviceInfo.deviceId copy] encryptionLevel:self.config.encryptionLevel previousEncryptionLevel:self.config.cryptManager.previousEncryptionLevel encryptionManager:self.config.cryptManager]; | ||
| self.inboxController.delegate = self; | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.