NCEntoToEndInterface.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. //
  2. // NCEntoToEndInterface.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 03/04/17.
  6. // Copyright © 2017 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  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 Foundation
  24. class NCEntoToEndInterface : NSObject, OCNetworkingDelegate {
  25. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  26. var getSignPublicKey = false;
  27. var getStorePrivateKey = false;
  28. override init() {
  29. }
  30. // --------------------------------------------------------------------------------------------
  31. // MARK: End To End Encryption - PublicKey
  32. // --------------------------------------------------------------------------------------------
  33. @objc func initEndToEndEncryption() {
  34. getSignPublicKey = false;
  35. getStorePrivateKey = false;
  36. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  37. metadataNet.action = actionGetEndToEndPublicKeys;
  38. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  39. metadataNet.action = actionGetEndToEndPrivateKeyCipher;
  40. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  41. metadataNet.action = actionGetEndToEndServerPublicKey;
  42. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  43. }
  44. func getEndToEndPublicKeysSuccess(_ metadataNet: CCMetadataNet!) {
  45. CCUtility.setEndToEndPublicKeySign(appDelegate.activeAccount, publicKey: metadataNet.key)
  46. getSignPublicKey = true
  47. if (getStorePrivateKey) {
  48. alertControllerSuccess("_success_", message: "_e2e_settings_activated_")
  49. }
  50. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPublicKeys, note: "E2E PublicKeys present on Server and stored to keychain", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  51. }
  52. func getEndToEndPublicKeysFailure(_ metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  53. getSignPublicKey = false
  54. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPublicKeys, note: message as String!, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  55. switch errorCode {
  56. case 400:
  57. appDelegate.messageNotification("E2E public keys", description: "bad request: unpredictable internal error", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  58. case 404:
  59. // public keys couldn't be found
  60. // remove keychain
  61. CCUtility.setEndToEndPublicKeySign(appDelegate.activeAccount, publicKey: nil)
  62. guard let publicKey = NCEndToEndEncryption.sharedManager().createEnd(toEndPublicKey: appDelegate.activeUserID, directoryUser: appDelegate.directoryUser) else {
  63. appDelegate.messageNotification("E2E public keys", description: "E2E Error to create PublicKey", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  64. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPublicKeys, note: "E2E Error to create PublicKey", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  65. return
  66. }
  67. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  68. metadataNet.action = actionSignEndToEndPublicKey;
  69. metadataNet.key = publicKey;
  70. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  71. case 409:
  72. appDelegate.messageNotification("E2E public keys", description: "forbidden: the user can't access the public keys", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  73. default:
  74. appDelegate.messageNotification("E2E public keys", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  75. }
  76. }
  77. func signEnd(toEndPublicKeySuccess metadataNet: CCMetadataNet!) {
  78. // Insert CSR To Cheychain end delete
  79. guard let publicKey = NCEndToEndEncryption.sharedManager().getCSRFromDisk(appDelegate.directoryUser, delete: true) else {
  80. appDelegate.messageNotification("E2E public key", description: "Error : publicKey not present", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: 0)
  81. return
  82. }
  83. // OK signed key locally keychain
  84. CCUtility.setEndToEndPublicKeySign(appDelegate.activeAccount, publicKey: publicKey)
  85. getSignPublicKey = true
  86. if (getStorePrivateKey) {
  87. alertControllerSuccess("_success_", message: "_e2e_settings_activated_")
  88. }
  89. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionSignEndToEndPublicKey, note: "E2E PublicKey sign on Server and stored locally", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  90. }
  91. func signEnd(toEndPublicKeyFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  92. getSignPublicKey = false
  93. appDelegate.messageNotification("E2E sign public keys", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  94. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionSignEndToEndPublicKey, note: message, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  95. }
  96. func deleteEnd(toEndPublicKeySuccess metadataNet: CCMetadataNet!) {
  97. appDelegate.messageNotification("E2E delete public key", description: "Success", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.success, errorCode: 0)
  98. }
  99. func deleteEnd(toEndPublicKeyFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  100. appDelegate.messageNotification("E2E delete public key", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  101. }
  102. // --------------------------------------------------------------------------------------------
  103. // MARK: End To End Encryption - PrivateKey
  104. // --------------------------------------------------------------------------------------------
  105. func getEndToEndPrivateKeyCipherSuccess(_ metadataNet: CCMetadataNet!) {
  106. // request Passphrase
  107. var passphraseTextField: UITextField?
  108. let alertController = UIAlertController(title: NSLocalizedString("_e2e_passphrase_request_title_", comment: ""), message: NSLocalizedString("_e2e_passphrase_request_message_", comment: ""), preferredStyle: .alert)
  109. let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in
  110. let passphrase = passphraseTextField?.text
  111. let publicKey = CCUtility.getEndToEndPublicKeySign(self.appDelegate.activeAccount)
  112. guard let privateKey = NCEndToEndEncryption.sharedManager().decryptPrivateKeyCipher(metadataNet.key, passphrase: passphrase, publicKey: publicKey) else {
  113. self.appDelegate.messageNotification("E2E decrypt private key", description: "E2E Error to decrypt Private Key", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: 0)
  114. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: "E2E Error to decrypt Private Key", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  115. return
  116. }
  117. // Save to keychain
  118. CCUtility.setEndToEndPrivateKey(self.appDelegate.activeAccount, privateKey: privateKey)
  119. // Save passphrase to keychain
  120. CCUtility.setEndToEndPassphrase(self.appDelegate.activeAccount, passphrase:passphrase)
  121. self.getStorePrivateKey = true
  122. if (self.getSignPublicKey) {
  123. self.alertControllerSuccess("_success_", message: "_e2e_settings_activated_")
  124. }
  125. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: "E2E PrivateKey present on Server and stored to keychain", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  126. })
  127. let cancel = UIAlertAction(title: "Cancel", style: .cancel) { (action) -> Void in
  128. }
  129. alertController.addAction(ok)
  130. alertController.addAction(cancel)
  131. alertController.addTextField { (textField) -> Void in
  132. passphraseTextField = textField
  133. passphraseTextField?.placeholder = "Enter passphrase (12 words)"
  134. }
  135. appDelegate.activeMain.present(alertController, animated: true)
  136. }
  137. func getEndToEndPrivateKeyCipherFailure(_ metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  138. getStorePrivateKey = false;
  139. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: message as String!, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  140. switch errorCode {
  141. case 400:
  142. appDelegate.messageNotification("E2E public keys", description: "bad request: unpredictable internal error", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  143. case 404:
  144. // private keys couldn't be found
  145. // remove keychain
  146. CCUtility.setEndToEndPrivateKey(appDelegate.activeAccount, privateKey: nil)
  147. CCUtility.setEndToEndPassphrase(appDelegate.activeAccount, passphrase: nil)
  148. // message
  149. let e2ePassphrase = NYMnemonic.generateString(128, language: "english")
  150. let message = "\n" + NSLocalizedString("_e2e_settings_view_passphrase_", comment: "") + "\n\n" + e2ePassphrase!
  151. let alertController = UIAlertController(title: NSLocalizedString("_e2e_settings_title_", comment: ""), message: NSLocalizedString(message, comment: ""), preferredStyle: .alert)
  152. let OKAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { action in
  153. guard let privateKeyChiper = NCEndToEndEncryption.sharedManager().createEnd(toEndPrivateKey: self.appDelegate.activeUserID, directoryUser: self.appDelegate.directoryUser, passphrase: e2ePassphrase) else {
  154. self.appDelegate.messageNotification("E2E private keys", description: "E2E Error to create PublicKey chiper", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  155. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: "E2E Error to create PublicKey chiper", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  156. return
  157. }
  158. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: self.appDelegate.activeAccount)
  159. metadataNet.action = actionStoreEndToEndPrivateKeyCipher
  160. metadataNet.key = privateKeyChiper
  161. metadataNet.password = e2ePassphrase
  162. self.appDelegate.addNetworkingOperationQueue(self.appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  163. }
  164. alertController.addAction(OKAction)
  165. appDelegate.activeMain.present(alertController, animated: true)
  166. case 409:
  167. appDelegate.messageNotification("E2E private keys", description: "forbidden: the user can't access the private keys", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  168. default:
  169. appDelegate.messageNotification("E2E private keys", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  170. }
  171. }
  172. func storeEnd(toEndPrivateKeyCipherSuccess metadataNet: CCMetadataNet!) {
  173. // Insert PrivateKey (end delete) and passphrase to Cheychain
  174. guard let privateKey = NCEndToEndEncryption.sharedManager().getPrivateKey(fromDisk: appDelegate.directoryUser, delete: true) else {
  175. appDelegate.messageNotification("E2E private key", description: "Error : privateKey not present", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: 0)
  176. return
  177. }
  178. CCUtility.setEndToEndPrivateKey(appDelegate.activeAccount, privateKey: privateKey)
  179. CCUtility.setEndToEndPassphrase(appDelegate.activeAccount, passphrase:metadataNet.password)
  180. getStorePrivateKey = true
  181. if (getSignPublicKey) {
  182. alertControllerSuccess("_success_", message: "_e2e_settings_activated_")
  183. }
  184. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionStoreEndToEndPrivateKeyCipher, note: "E2E PrivateKey stored on Server and stored locally", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  185. }
  186. func storeEnd(toEndPrivateKeyCipherFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  187. getStorePrivateKey = false
  188. appDelegate.messageNotification("E2E sign private key", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  189. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionStoreEndToEndPrivateKeyCipher, note: message, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  190. }
  191. func deleteEnd(toEndPrivateKeySuccess metadataNet: CCMetadataNet!) {
  192. appDelegate.messageNotification("E2E delete private key", description: "Success", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.success, errorCode: 0)
  193. }
  194. func deleteEnd(toEndPrivateKeyFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  195. appDelegate.messageNotification("E2E delete private key", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  196. }
  197. // --------------------------------------------------------------------------------------------
  198. // MARK: End To End Encryption - Server PublicKey
  199. // --------------------------------------------------------------------------------------------
  200. func getEndToEndServerPublicKeySuccess(_ metadataNet: CCMetadataNet!) {
  201. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndServerPublicKey, note: "E2E Server PublicKey present on Server and stored to keychain", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  202. }
  203. func getEndToEndServerPublicKeyFailure(_ metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  204. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndServerPublicKey, note: message as String!, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  205. switch (errorCode) {
  206. case 400:
  207. appDelegate.messageNotification("E2E Server public key", description: "bad request: unpredictable internal error", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  208. case 404:
  209. appDelegate.messageNotification("E2E Server public key", description: "Server publickey doesn't exists", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  210. case 409:
  211. appDelegate.messageNotification("E2E Server public key", description: "forbidden: the user can't access the Server publickey", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  212. default:
  213. appDelegate.messageNotification("E2E Server public key", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  214. }
  215. }
  216. // --------------------------------------------------------------------------------------------
  217. // MARK: Mark/Delete Encrypted Folder
  218. // --------------------------------------------------------------------------------------------
  219. func markEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  220. print("E2E mark folder success")
  221. }
  222. func markEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  223. // Unauthorized
  224. if (errorCode == kOCErrorServerUnauthorized) {
  225. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  226. }
  227. if (errorCode != kOCErrorServerUnauthorized) {
  228. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  229. }
  230. }
  231. @objc func markEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  232. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  233. metadataNet.action = actionMarkEndToEndFolderEncrypted;
  234. metadataNet.fileID = metadata.fileID;
  235. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  236. }
  237. func deletemarkEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  238. print("E2E delete mark folder success")
  239. }
  240. func deletemarkEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  241. // Unauthorized
  242. if (errorCode == kOCErrorServerUnauthorized) {
  243. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  244. }
  245. if (errorCode != kOCErrorServerUnauthorized) {
  246. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  247. }
  248. }
  249. @objc func deletemarkEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  250. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  251. metadataNet.action = actionDeletemarkEndToEndFolderEncrypted;
  252. metadataNet.fileID = metadata.fileID;
  253. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  254. }
  255. // --------------------------------------------------------------------------------------------
  256. // MARK: Mark/Delete Encrypted Folder
  257. // --------------------------------------------------------------------------------------------
  258. func unlockEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  259. print("E2E lock file success")
  260. }
  261. func unlockEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  262. // Unauthorized
  263. if (errorCode == kOCErrorServerUnauthorized) {
  264. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  265. }
  266. if (errorCode != kOCErrorServerUnauthorized) {
  267. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  268. }
  269. }
  270. @objc func unlockEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  271. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  272. metadataNet.action = actionUnlockEndToEndFolderEncrypted;
  273. metadataNet.fileID = metadata.fileID;
  274. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  275. }
  276. func lockEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  277. print("E2E lock file success")
  278. }
  279. func lockEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  280. // Unauthorized
  281. if (errorCode == kOCErrorServerUnauthorized) {
  282. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  283. }
  284. if (errorCode != kOCErrorServerUnauthorized) {
  285. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  286. }
  287. }
  288. @objc func lockEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  289. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  290. metadataNet.action = actionLockEndToEndFolderEncrypted;
  291. metadataNet.fileID = metadata.fileID;
  292. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  293. }
  294. // --------------------------------------------------------------------------------------------
  295. // MARK: Form
  296. // --------------------------------------------------------------------------------------------
  297. func alertControllerSuccess(_ title: String, message: String) {
  298. getSignPublicKey = false
  299. getStorePrivateKey = false
  300. let alertController = UIAlertController(title: NSLocalizedString(title, comment: ""), message: NSLocalizedString(message, comment: ""), preferredStyle: .alert)
  301. let OKAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { action in
  302. NotificationCenter.default.post(name: Notification.Name("reloadManageEndToEndEncryption"), object: nil)
  303. }
  304. alertController.addAction(OKAction)
  305. appDelegate.activeMain.present(alertController, animated: true)
  306. }
  307. }