|
@@ -24,12 +24,14 @@
|
|
|
#import "NCManageEndToEndEncryption.h"
|
|
|
#import "AppDelegate.h"
|
|
|
#import "CCNetworking.h"
|
|
|
+#import "TOPasscodeViewController.h"
|
|
|
|
|
|
#import "NCBridgeSwift.h"
|
|
|
|
|
|
-@interface NCManageEndToEndEncryption () <NCEndToEndInitializeDelegate>
|
|
|
+@interface NCManageEndToEndEncryption () <NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate>
|
|
|
{
|
|
|
AppDelegate *appDelegate;
|
|
|
+ NSString *passcodeType = @"";
|
|
|
}
|
|
|
@end
|
|
|
|
|
@@ -186,32 +188,7 @@
|
|
|
|
|
|
if ([[CCUtility getBlockCode] length]) {
|
|
|
|
|
|
- /*
|
|
|
- CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
|
|
|
- viewController.delegate = self;
|
|
|
- viewController.fromType = CCBKPasscodeFromStartEncryption;
|
|
|
- viewController.type = BKPasscodeViewControllerCheckPasscodeType;
|
|
|
-
|
|
|
- if ([CCUtility getSimplyBlockCode]) {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
|
|
|
- viewController.passcodeInputView.maximumLength = 6;
|
|
|
- } else {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
|
|
|
- viewController.passcodeInputView.maximumLength = 64;
|
|
|
- }
|
|
|
-
|
|
|
- BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
|
|
|
- touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
|
|
|
- viewController.touchIDManager = touchIDManager;
|
|
|
-
|
|
|
- viewController.title = NSLocalizedString(@"_e2e_settings_start_", nil);
|
|
|
- viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
|
|
|
- viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
|
|
|
-
|
|
|
- UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
|
|
|
- navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
- [self presentViewController:navigationController animated:YES completion:nil];
|
|
|
- */
|
|
|
+ [self passcodeType:@"startE2E"];
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -227,33 +204,9 @@
|
|
|
{
|
|
|
[self deselectFormRow:sender];
|
|
|
|
|
|
- /*
|
|
|
if ([[CCUtility getBlockCode] length]) {
|
|
|
|
|
|
- CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
|
|
|
- viewController.delegate = self;
|
|
|
- viewController.fromType = CCBKPasscodeFromCheckPassphrase;
|
|
|
- viewController.type = BKPasscodeViewControllerCheckPasscodeType;
|
|
|
-
|
|
|
- if ([CCUtility getSimplyBlockCode]) {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
|
|
|
- viewController.passcodeInputView.maximumLength = 6;
|
|
|
- } else {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
|
|
|
- viewController.passcodeInputView.maximumLength = 64;
|
|
|
- }
|
|
|
-
|
|
|
- BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
|
|
|
- touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
|
|
|
- viewController.touchIDManager = touchIDManager;
|
|
|
-
|
|
|
- viewController.title = NSLocalizedString(@"_e2e_settings_read_passphrase_", nil);
|
|
|
- viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
|
|
|
- viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
|
|
|
-
|
|
|
- UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
|
|
|
- navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
- [self presentViewController:navigationController animated:YES completion:nil];
|
|
|
+ [self passcodeType:@"readPassphrase"];
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -263,40 +216,15 @@
|
|
|
[alertController addAction:okAction];
|
|
|
[self presentViewController:alertController animated:YES completion:nil];
|
|
|
}
|
|
|
- */
|
|
|
}
|
|
|
|
|
|
- (void)removeLocallyEncryption:(XLFormRowDescriptor *)sender
|
|
|
{
|
|
|
[self deselectFormRow:sender];
|
|
|
|
|
|
- /*
|
|
|
if ([[CCUtility getBlockCode] length]) {
|
|
|
|
|
|
- CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
|
|
|
- viewController.delegate = self;
|
|
|
- viewController.fromType = CCBKPasscodeFromRemoveEncryption;
|
|
|
- viewController.type = BKPasscodeViewControllerCheckPasscodeType;
|
|
|
-
|
|
|
- if ([CCUtility getSimplyBlockCode]) {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
|
|
|
- viewController.passcodeInputView.maximumLength = 6;
|
|
|
- } else {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
|
|
|
- viewController.passcodeInputView.maximumLength = 64;
|
|
|
- }
|
|
|
-
|
|
|
- BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
|
|
|
- touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
|
|
|
- viewController.touchIDManager = touchIDManager;
|
|
|
-
|
|
|
- viewController.title = NSLocalizedString(@"_e2e_settings_remove_", nil);
|
|
|
- viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
|
|
|
- viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
|
|
|
-
|
|
|
- UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
|
|
|
- navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
- [self presentViewController:navigationController animated:YES completion:nil];
|
|
|
+ [self passcodeType:@"removeLocallyEncryption"];
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -306,9 +234,76 @@
|
|
|
[alertController addAction:okAction];
|
|
|
[self presentViewController:alertController animated:YES completion:nil];
|
|
|
}
|
|
|
- */
|
|
|
}
|
|
|
|
|
|
+#pragma mark - Passcode -
|
|
|
+
|
|
|
+- (void)passcodeType:(NSString *)type
|
|
|
+{
|
|
|
+ TOPasscodeViewController *passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentLight passcodeType:TOPasscodeTypeSixDigits];
|
|
|
+ if (@available(iOS 13.0, *)) {
|
|
|
+ if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
|
|
|
+ passcodeViewController.style = TOPasscodeViewStyleTranslucentDark;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ passcodeViewController.allowCancel = true;
|
|
|
+ passcodeViewController.delegate = self;
|
|
|
+ passcodeViewController.keypadButtonShowLettering = false;
|
|
|
+ passcodeType = type;
|
|
|
+
|
|
|
+ [self presentViewController:passcodeViewController animated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)didTapCancelInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
|
|
|
+{
|
|
|
+ [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+- (BOOL)passcodeViewController:(TOPasscodeViewController *)passcodeViewController isCorrectCode:(NSString *)code
|
|
|
+{
|
|
|
+ if ([code isEqualToString:[CCUtility getBlockCode]]) {
|
|
|
+
|
|
|
+ if ([passcodeType isEqualToString:@"startE2E"]) {
|
|
|
+
|
|
|
+ [self.endToEndInitialize initEndToEndEncryption];
|
|
|
+
|
|
|
+ } else if ([passcodeType isEqualToString:@"readPassphrase"]) {
|
|
|
+
|
|
|
+ NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:appDelegate.activeAccount];
|
|
|
+ NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
|
|
|
+
|
|
|
+ NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
|
|
|
+
|
|
|
+ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { }];
|
|
|
+ [alertController addAction:okAction];
|
|
|
+ [self presentViewController:alertController animated:YES completion:nil];
|
|
|
+
|
|
|
+ } else if ([passcodeType isEqualToString:@"removeLocallyEncryption"]) {
|
|
|
+
|
|
|
+ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_e2e_settings_remove_", nil) message:NSLocalizedString(@"_e2e_settings_remove_message_", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+
|
|
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
+ [CCUtility clearAllKeysEndToEnd:appDelegate.activeAccount];
|
|
|
+ [self initializeForm];
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
|
|
|
+
|
|
|
+ [alertController addAction:okAction];
|
|
|
+ [alertController addAction:cancelAction];
|
|
|
+ [self presentViewController:alertController animated:YES completion:nil];
|
|
|
+ }
|
|
|
+
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NO;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (void)deletePublicKey:(XLFormRowDescriptor *)sender
|
|
|
{
|
|
|
[self deselectFormRow:sender];
|
|
@@ -349,77 +344,4 @@
|
|
|
[self initializeForm];
|
|
|
}
|
|
|
|
|
|
-#pragma --------------------------------------------------------------------------------------------
|
|
|
-#pragma mark === BKPasscodeViewController ===
|
|
|
-#pragma --------------------------------------------------------------------------------------------
|
|
|
-
|
|
|
-/*
|
|
|
-- (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
|
|
|
-{
|
|
|
- return _failedAttempts;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
|
|
|
-{
|
|
|
- return _lockUntilDate;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)passcodeViewCloseButtonPressed:(id)sender
|
|
|
-{
|
|
|
- [self dismissViewControllerAnimated:YES completion:nil];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
|
|
|
-{
|
|
|
- if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
|
|
|
- _lockUntilDate = nil;
|
|
|
- _failedAttempts = 0;
|
|
|
- aResultHandler(YES);
|
|
|
- } else
|
|
|
- aResultHandler(NO);
|
|
|
-}
|
|
|
-
|
|
|
-- (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
|
|
|
-{
|
|
|
- [aViewController dismissViewControllerAnimated:YES completion:nil];
|
|
|
-
|
|
|
- if (aViewController.fromType == CCBKPasscodeFromStartEncryption) {
|
|
|
-
|
|
|
- [self.endToEndInitialize initEndToEndEncryption];
|
|
|
- }
|
|
|
-
|
|
|
- if (aViewController.fromType == CCBKPasscodeFromCheckPassphrase) {
|
|
|
-
|
|
|
- NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:appDelegate.activeAccount];
|
|
|
- NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
|
|
|
-
|
|
|
- NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
|
|
|
-
|
|
|
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
- }];
|
|
|
- [alertController addAction:okAction];
|
|
|
- [self presentViewController:alertController animated:YES completion:nil];
|
|
|
- }
|
|
|
-
|
|
|
- if (aViewController.fromType == CCBKPasscodeFromRemoveEncryption) {
|
|
|
-
|
|
|
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_e2e_settings_remove_", nil) message:NSLocalizedString(@"_e2e_settings_remove_message_", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
-
|
|
|
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
- [CCUtility clearAllKeysEndToEnd:appDelegate.activeAccount];
|
|
|
- [self initializeForm];
|
|
|
- }];
|
|
|
-
|
|
|
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
- NSLog(@"[LOG] Cancel action");
|
|
|
- }];
|
|
|
-
|
|
|
- [alertController addAction:okAction];
|
|
|
- [alertController addAction:cancelAction];
|
|
|
- [self presentViewController:alertController animated:YES completion:nil];
|
|
|
- }
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
@end
|