NCManageEndToEndEncryption.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. [self presentViewController:navigationController animated:YES completion:nil];
  187. } else {
  188. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  189. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  190. }];
  191. [alertController addAction:okAction];
  192. [self presentViewController:alertController animated:YES completion:nil];
  193. }
  194. }
  195. - (void)readPassphrase:(XLFormRowDescriptor *)sender
  196. {
  197. [self deselectFormRow:sender];
  198. if ([[CCUtility getBlockCode] length]) {
  199. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  200. viewController.delegate = self;
  201. viewController.fromType = CCBKPasscodeFromCheckPassphrase;
  202. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  203. if ([CCUtility getSimplyBlockCode]) {
  204. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  205. viewController.passcodeInputView.maximumLength = 6;
  206. } else {
  207. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  208. viewController.passcodeInputView.maximumLength = 64;
  209. }
  210. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  211. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  212. viewController.touchIDManager = touchIDManager;
  213. viewController.title = NSLocalizedString(@"_e2e_settings_read_passphrase_", nil);
  214. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  215. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  216. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  217. [self presentViewController:navigationController animated:YES completion:nil];
  218. } else {
  219. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  220. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  221. }];
  222. [alertController addAction:okAction];
  223. [self presentViewController:alertController animated:YES completion:nil];
  224. }
  225. }
  226. - (void)removeLocallyEncryption:(XLFormRowDescriptor *)sender
  227. {
  228. [self deselectFormRow:sender];
  229. if ([[CCUtility getBlockCode] length]) {
  230. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  231. viewController.delegate = self;
  232. viewController.fromType = CCBKPasscodeFromRemoveEncryption;
  233. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  234. if ([CCUtility getSimplyBlockCode]) {
  235. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  236. viewController.passcodeInputView.maximumLength = 6;
  237. } else {
  238. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  239. viewController.passcodeInputView.maximumLength = 64;
  240. }
  241. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  242. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  243. viewController.touchIDManager = touchIDManager;
  244. viewController.title = NSLocalizedString(@"_e2e_settings_remove_", nil);
  245. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  246. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  247. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  248. [self presentViewController:navigationController animated:YES completion:nil];
  249. } else {
  250. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  251. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  252. }];
  253. [alertController addAction:okAction];
  254. [self presentViewController:alertController animated:YES completion:nil];
  255. }
  256. }
  257. - (void)deletePublicKey:(XLFormRowDescriptor *)sender
  258. {
  259. [self deselectFormRow:sender];
  260. [[NCNetworkingEndToEnd sharedManager] deleteEndToEndPublicKeyWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSString *message, NSInteger errorCode) {
  261. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  262. [appDelegate messageNotification:@"E2E delete publicKey" description:@"Success" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode:0];
  263. } else {
  264. [appDelegate messageNotification:@"E2E delete publicKey" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
  265. }
  266. }];
  267. }
  268. - (void)deletePrivateKey:(XLFormRowDescriptor *)sender
  269. {
  270. [self deselectFormRow:sender];
  271. [[NCNetworkingEndToEnd sharedManager] deleteEndToEndPrivateKeyWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSString *message, NSInteger errorCode) {
  272. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  273. [appDelegate messageNotification:@"E2E delete privateKey" description:@"Success" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode:0];
  274. } else {
  275. [appDelegate messageNotification:@"E2E delete privateKey" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
  276. }
  277. }];
  278. }
  279. #pragma --------------------------------------------------------------------------------------------
  280. #pragma mark === Delegate ===
  281. #pragma --------------------------------------------------------------------------------------------
  282. - (void)endToEndInitializeSuccess
  283. {
  284. // Reload All Datasource
  285. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
  286. [self initializeForm];
  287. }
  288. #pragma --------------------------------------------------------------------------------------------
  289. #pragma mark === BKPasscodeViewController ===
  290. #pragma --------------------------------------------------------------------------------------------
  291. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  292. {
  293. return _failedAttempts;
  294. }
  295. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  296. {
  297. return _lockUntilDate;
  298. }
  299. - (void)passcodeViewCloseButtonPressed:(id)sender
  300. {
  301. [self dismissViewControllerAnimated:YES completion:nil];
  302. }
  303. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  304. {
  305. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  306. _lockUntilDate = nil;
  307. _failedAttempts = 0;
  308. aResultHandler(YES);
  309. } else
  310. aResultHandler(NO);
  311. }
  312. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  313. {
  314. [aViewController dismissViewControllerAnimated:YES completion:nil];
  315. if (aViewController.fromType == CCBKPasscodeFromStartEncryption) {
  316. [self.endToEndInitialize initEndToEndEncryption];
  317. }
  318. if (aViewController.fromType == CCBKPasscodeFromCheckPassphrase) {
  319. NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:appDelegate.activeAccount];
  320. NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
  321. NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
  322. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  323. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  324. }];
  325. [alertController addAction:okAction];
  326. [self presentViewController:alertController animated:YES completion:nil];
  327. }
  328. if (aViewController.fromType == CCBKPasscodeFromRemoveEncryption) {
  329. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_e2e_settings_remove_", nil) message:NSLocalizedString(@"_e2e_settings_remove_message_", nil) preferredStyle:UIAlertControllerStyleAlert];
  330. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  331. [CCUtility clearAllKeysEndToEnd:appDelegate.activeAccount];
  332. [self initializeForm];
  333. }];
  334. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  335. NSLog(@"[LOG] Cancel action");
  336. }];
  337. [alertController addAction:okAction];
  338. [alertController addAction:cancelAction];
  339. [self presentViewController:alertController animated:YES completion:nil];
  340. }
  341. }
  342. @end