NCManageEndToEndEncryption.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. //
  2. // NCManageEndToEndEncryption.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 13/10/17.
  6. // Copyright © 2017 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "NCManageEndToEndEncryption.h"
  24. #import "AppDelegate.h"
  25. #import "CCNetworking.h"
  26. #import "NCBridgeSwift.h"
  27. @interface NCManageEndToEndEncryption () <NCEndToEndInitializeDelegate>
  28. {
  29. AppDelegate *appDelegate;
  30. NSUInteger _failedAttempts;
  31. NSDate *_lockUntilDate;
  32. }
  33. @end
  34. @implementation NCManageEndToEndEncryption
  35. - (id)initWithCoder:(NSCoder *)aDecoder
  36. {
  37. self = [super initWithCoder:aDecoder];
  38. if (self) {
  39. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  40. [self initializeForm];
  41. }
  42. return self;
  43. }
  44. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  45. {
  46. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  47. if (self) {
  48. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  49. [self initializeForm];
  50. }
  51. return self;
  52. }
  53. - (void)initializeForm
  54. {
  55. XLFormDescriptor *form ;
  56. XLFormSectionDescriptor *section;
  57. XLFormRowDescriptor *row;
  58. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_e2e_settings_", nil)];
  59. tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
  60. if (capabilities.endToEndEncryption == NO) {
  61. // Section SERVICE NOT AVAILABLE -------------------------------------------------
  62. section = [XLFormSectionDescriptor formSection];
  63. [form addFormSection:section];
  64. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"serviceActivated" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_e2e_settings_not_available_", nil)];
  65. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  66. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"closeCircle"] width:50 height:50 color:[UIColor redColor]] forKey:@"imageView.image"];
  67. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  68. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  69. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  70. [section addFormRow:row];
  71. self.form = form;
  72. return;
  73. }
  74. if ([CCUtility isEndToEndEnabled:appDelegate.activeAccount]) {
  75. // Section SERVICE ACTIVATED -------------------------------------------------
  76. section = [XLFormSectionDescriptor formSection];
  77. [form addFormSection:section];
  78. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"serviceActivated" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_e2e_settings_activated_", nil)];
  79. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  80. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"selectFull"] width:50 height:50 color:[UIColor greenColor]] forKey:@"imageView.image"];
  81. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  82. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  83. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  84. [section addFormRow:row];
  85. // Section PASSPHRASE -------------------------------------------------
  86. section = [XLFormSectionDescriptor formSection];
  87. [form addFormSection:section];
  88. // Read Passphrase
  89. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"readPassphrase" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_read_passphrase_", nil)];
  90. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  91. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"e2eReadPassphrase"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  92. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  93. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  94. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  95. row.action.formSelector = @selector(readPassphrase:);
  96. [section addFormRow:row];
  97. // Section DELETE -------------------------------------------------
  98. section = [XLFormSectionDescriptor formSection];
  99. [form addFormSection:section];
  100. // remove locally Encryption
  101. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removeLocallyEncryption" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_remove_", nil)];
  102. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  103. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"lock"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  104. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  105. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  106. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  107. row.action.formSelector = @selector(removeLocallyEncryption:);
  108. [section addFormRow:row];
  109. } else {
  110. // Section START E2E -------------------------------------------------
  111. section = [XLFormSectionDescriptor formSection];
  112. [form addFormSection:section];
  113. // Start e2e
  114. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"startE2E" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_start_", nil)];
  115. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  116. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  117. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  118. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  119. row.action.formSelector = @selector(startE2E:);
  120. [section addFormRow:row];
  121. }
  122. #ifdef DEBUG
  123. // Section DELETE KEYS -------------------------------------------------
  124. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"Delete server keys ", nil)];
  125. [form addFormSection:section];
  126. // Delete publicKey
  127. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deletePublicKey" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"Delete PublicKey", nil)];
  128. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  129. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  130. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  131. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  132. row.action.formSelector = @selector(deletePublicKey:);
  133. [section addFormRow:row];
  134. // Delete privateKey
  135. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deletePrivateKey" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"Delete PrivateKey", nil)];
  136. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  137. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  138. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  139. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  140. row.action.formSelector = @selector(deletePrivateKey:);
  141. [section addFormRow:row];
  142. #endif
  143. self.form = form;
  144. }
  145. - (void)viewDidLoad
  146. {
  147. [super viewDidLoad];
  148. // E2EE
  149. self.endToEndInitialize = [NCEndToEndInitialize new];
  150. self.endToEndInitialize.delegate = self;
  151. }
  152. - (void)viewWillAppear:(BOOL)animated
  153. {
  154. [super viewWillAppear:animated];
  155. self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
  156. self.tableView.showsVerticalScrollIndicator = NO;
  157. self.tableView.separatorColor = NCBrandColor.sharedInstance.separator;
  158. [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
  159. [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
  160. }
  161. #pragma --------------------------------------------------------------------------------------------
  162. #pragma mark === Action ===
  163. #pragma --------------------------------------------------------------------------------------------
  164. - (void)startE2E:(XLFormRowDescriptor *)sender
  165. {
  166. [self deselectFormRow:sender];
  167. if ([[CCUtility getBlockCode] length]) {
  168. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  169. viewController.delegate = self;
  170. viewController.fromType = CCBKPasscodeFromStartEncryption;
  171. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  172. if ([CCUtility getSimplyBlockCode]) {
  173. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  174. viewController.passcodeInputView.maximumLength = 6;
  175. } else {
  176. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  177. viewController.passcodeInputView.maximumLength = 64;
  178. }
  179. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  180. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  181. viewController.touchIDManager = touchIDManager;
  182. viewController.title = NSLocalizedString(@"_e2e_settings_start_", nil);
  183. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  184. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  185. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  186. navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
  187. [self presentViewController:navigationController animated:YES completion:nil];
  188. } else {
  189. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  190. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  191. }];
  192. [alertController addAction:okAction];
  193. [self presentViewController:alertController animated:YES completion:nil];
  194. }
  195. }
  196. - (void)readPassphrase:(XLFormRowDescriptor *)sender
  197. {
  198. [self deselectFormRow:sender];
  199. if ([[CCUtility getBlockCode] length]) {
  200. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  201. viewController.delegate = self;
  202. viewController.fromType = CCBKPasscodeFromCheckPassphrase;
  203. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  204. if ([CCUtility getSimplyBlockCode]) {
  205. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  206. viewController.passcodeInputView.maximumLength = 6;
  207. } else {
  208. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  209. viewController.passcodeInputView.maximumLength = 64;
  210. }
  211. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  212. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  213. viewController.touchIDManager = touchIDManager;
  214. viewController.title = NSLocalizedString(@"_e2e_settings_read_passphrase_", nil);
  215. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  216. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  217. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  218. navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
  219. [self presentViewController:navigationController animated:YES completion:nil];
  220. } else {
  221. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  222. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  223. }];
  224. [alertController addAction:okAction];
  225. [self presentViewController:alertController animated:YES completion:nil];
  226. }
  227. }
  228. - (void)removeLocallyEncryption:(XLFormRowDescriptor *)sender
  229. {
  230. [self deselectFormRow:sender];
  231. if ([[CCUtility getBlockCode] length]) {
  232. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  233. viewController.delegate = self;
  234. viewController.fromType = CCBKPasscodeFromRemoveEncryption;
  235. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  236. if ([CCUtility getSimplyBlockCode]) {
  237. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  238. viewController.passcodeInputView.maximumLength = 6;
  239. } else {
  240. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  241. viewController.passcodeInputView.maximumLength = 64;
  242. }
  243. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  244. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  245. viewController.touchIDManager = touchIDManager;
  246. viewController.title = NSLocalizedString(@"_e2e_settings_remove_", nil);
  247. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  248. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  249. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  250. navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
  251. [self presentViewController:navigationController animated:YES completion:nil];
  252. } else {
  253. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  254. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  255. }];
  256. [alertController addAction:okAction];
  257. [self presentViewController:alertController animated:YES completion:nil];
  258. }
  259. }
  260. - (void)deletePublicKey:(XLFormRowDescriptor *)sender
  261. {
  262. [self deselectFormRow:sender];
  263. [[NCNetworkingEndToEnd sharedManager] deleteEndToEndPublicKeyWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSString *message, NSInteger errorCode) {
  264. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  265. [appDelegate messageNotification:@"E2E delete publicKey" description:@"Success" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode:0];
  266. } else {
  267. [appDelegate messageNotification:@"E2E delete publicKey" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
  268. }
  269. }];
  270. }
  271. - (void)deletePrivateKey:(XLFormRowDescriptor *)sender
  272. {
  273. [self deselectFormRow:sender];
  274. [[NCNetworkingEndToEnd sharedManager] deleteEndToEndPrivateKeyWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSString *message, NSInteger errorCode) {
  275. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  276. [appDelegate messageNotification:@"E2E delete privateKey" description:@"Success" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode:0];
  277. } else {
  278. [appDelegate messageNotification:@"E2E delete privateKey" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
  279. }
  280. }];
  281. }
  282. #pragma --------------------------------------------------------------------------------------------
  283. #pragma mark === Delegate ===
  284. #pragma --------------------------------------------------------------------------------------------
  285. - (void)endToEndInitializeSuccess
  286. {
  287. // Reload All Datasource
  288. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
  289. [self initializeForm];
  290. }
  291. #pragma --------------------------------------------------------------------------------------------
  292. #pragma mark === BKPasscodeViewController ===
  293. #pragma --------------------------------------------------------------------------------------------
  294. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  295. {
  296. return _failedAttempts;
  297. }
  298. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  299. {
  300. return _lockUntilDate;
  301. }
  302. - (void)passcodeViewCloseButtonPressed:(id)sender
  303. {
  304. [self dismissViewControllerAnimated:YES completion:nil];
  305. }
  306. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  307. {
  308. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  309. _lockUntilDate = nil;
  310. _failedAttempts = 0;
  311. aResultHandler(YES);
  312. } else
  313. aResultHandler(NO);
  314. }
  315. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  316. {
  317. [aViewController dismissViewControllerAnimated:YES completion:nil];
  318. if (aViewController.fromType == CCBKPasscodeFromStartEncryption) {
  319. [self.endToEndInitialize initEndToEndEncryption];
  320. }
  321. if (aViewController.fromType == CCBKPasscodeFromCheckPassphrase) {
  322. NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:appDelegate.activeAccount];
  323. NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
  324. NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
  325. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  326. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  327. }];
  328. [alertController addAction:okAction];
  329. [self presentViewController:alertController animated:YES completion:nil];
  330. }
  331. if (aViewController.fromType == CCBKPasscodeFromRemoveEncryption) {
  332. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_e2e_settings_remove_", nil) message:NSLocalizedString(@"_e2e_settings_remove_message_", nil) preferredStyle:UIAlertControllerStyleAlert];
  333. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  334. [CCUtility clearAllKeysEndToEnd:appDelegate.activeAccount];
  335. [self initializeForm];
  336. }];
  337. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  338. NSLog(@"[LOG] Cancel action");
  339. }];
  340. [alertController addAction:okAction];
  341. [alertController addAction:cancelAction];
  342. [self presentViewController:alertController animated:YES completion:nil];
  343. }
  344. }
  345. @end