Mercurial > libervia-web
comparison src/browser/sat_browser/plugin_sec_otr.py @ 523:5add182e7dd5
browser_side (plugin OTR): rename menus and replace 'buddy' with 'correspondent'
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 03 Sep 2014 11:04:29 +0200 |
parents | 0de69fec24e9 |
children | d41e850b31b9 |
comparison
equal
deleted
inserted
replaced
522:0de69fec24e9 | 523:5add182e7dd5 |
---|---|
33 import otrjs_wrapper as otr | 33 import otrjs_wrapper as otr |
34 import dialog | 34 import dialog |
35 | 35 |
36 NS_OTR = "otr_plugin" | 36 NS_OTR = "otr_plugin" |
37 PRIVATE_KEY = "PRIVATE KEY" | 37 PRIVATE_KEY = "PRIVATE KEY" |
38 MAIN_MENU = D_('OTR') | 38 MAIN_MENU = D_('OTR encryption') |
39 DIALOG_EOL = "<br />" | 39 DIALOG_EOL = "<br />" |
40 AUTH_INFO_TXT = D_("Authenticating a buddy helps ensure that the person you are talking to is who he or she claims to be.{eol}{eol}").format(eol=DIALOG_EOL) | 40 AUTH_INFO_TXT = D_("Authenticating a correspondent helps ensure that the person you are talking to is who he or she claims to be.{eol}{eol}").format(eol=DIALOG_EOL) |
41 AUTH_FINGERPRINT_TXT = D_("<i>To verify the fingerprint, contact your buddy via some other authenticated channel (i.e. not in this chat), such as the telephone or GPG-signed email. Each of you should tell your fingerprint to the other.</i>{eol}{eol}").format(eol=DIALOG_EOL) | 41 AUTH_FINGERPRINT_TXT = D_("<i>To verify the fingerprint, contact your correspondent via some other authenticated channel (i.e. not in this chat), such as the telephone or GPG-signed email. Each of you should tell your fingerprint to the other.</i>{eol}{eol}").format(eol=DIALOG_EOL) |
42 AUTH_QUEST_DEF = D_("<i>To authenticate using a question, pick a question whose answer is known only to you and your buddy. Enter this question and this answer, then wait for your buddy to enter the answer too. If the answers don't match, then you may be talking to an imposter.</i>{eol}{eol}").format(eol=DIALOG_EOL) | 42 AUTH_QUEST_DEF = D_("<i>To authenticate using a question, pick a question whose answer is known only to you and your correspondent. Enter this question and this answer, then wait for your correspondent to enter the answer too. If the answers don't match, then you may be talking to an imposter.</i>{eol}{eol}").format(eol=DIALOG_EOL) |
43 AUTH_QUEST_ASK = D_("<i>Your buddy is attempting to determine if he or she is really talking to you, or if it's someone pretending to be you. Your buddy has asked a question, indicated below. To authenticate to your buddy, enter the answer and click OK.</i>{eol}{eol}").format(eol=DIALOG_EOL) | 43 AUTH_QUEST_ASK = D_("<i>Your correspondent is attempting to determine if he or she is really talking to you, or if it's someone pretending to be you. Your correspondent has asked a question, indicated below. To authenticate to your correspondent, enter the answer and click OK.</i>{eol}{eol}").format(eol=DIALOG_EOL) |
44 AUTH_SECRET_TXT = D_("{eol}{eol}Enter secret answer here: (case sensitive){eol}").format(eol=DIALOG_EOL) | 44 AUTH_SECRET_TXT = D_("{eol}{eol}Enter secret answer here: (case sensitive){eol}").format(eol=DIALOG_EOL) |
45 | 45 |
46 | 46 |
47 DROP_TXT = D_("You private key is used to encrypt messages for your correspondent, nobody except you must know it, if you are in doubt, you should drop it!{eol}{eol}Are you sure you want to drop your private key?").format(eol=DIALOG_EOL) | 47 DROP_TXT = D_("You private key is used to encrypt messages for your correspondent, nobody except you must know it, if you are in doubt, you should drop it!{eol}{eol}Are you sure you want to drop your private key?").format(eol=DIALOG_EOL) |
48 | 48 |
58 def __init__(self, host, account, other_jid): | 58 def __init__(self, host, account, other_jid): |
59 """ | 59 """ |
60 | 60 |
61 @param host (satWebFrontend) | 61 @param host (satWebFrontend) |
62 @param account (Account) | 62 @param account (Account) |
63 @param other_jid (JID): JID of the person your chat buddy | 63 @param other_jid (JID): JID of the person your chat correspondent |
64 """ | 64 """ |
65 super(Context, self).__init__(account, other_jid) | 65 super(Context, self).__init__(account, other_jid) |
66 self.host = host | 66 self.host = host |
67 | 67 |
68 def getPolicy(self, key): | 68 def getPolicy(self, key): |
138 msg = _("Authentication aborted.") | 138 msg = _("Authentication aborted.") |
139 elif new_trust: | 139 elif new_trust: |
140 if act == "asked": | 140 if act == "asked": |
141 msg = _("Authentication successful.") | 141 msg = _("Authentication successful.") |
142 else: | 142 else: |
143 msg = _("Your buddy has successfully authenticated you. You may want to authenticate your buddy as well by asking your own question.") | 143 msg = _("Your correspondent has successfully authenticated you. You may want to authenticate your correspondent as well by asking your own question.") |
144 else: | 144 else: |
145 msg = _("Authentication failed.") | 145 msg = _("Authentication failed.") |
146 dialog.InfoDialog(title, msg).show() | 146 dialog.InfoDialog(title, msg).show() |
147 if act != "asked": | 147 if act != "asked": |
148 return | 148 return |
190 if type_ == 'question': | 190 if type_ == 'question': |
191 act = 'answered' # OTR._authenticate calls this method with act="asked" | 191 act = 'answered' # OTR._authenticate calls this method with act="asked" |
192 elif type_ == 'abort': | 192 elif type_ == 'abort': |
193 act = 'asked' # smpAuthAbort triggers this method with act='answered' when needed | 193 act = 'asked' # smpAuthAbort triggers this method with act='answered' when needed |
194 | 194 |
195 # FIXME upstream: if buddy uses Pidgin and use fingerprint to authenticate us, | 195 # FIXME upstream: if the correspondent uses Pidgin and authenticate us via |
196 # we will reach this code... that's wrong, this method is for SMP! There's | 196 # fingerprints, we will reach this code... that's wrong, this method is for SMP! |
197 # probably a bug to fix in otr.js. Do it together with the issue that make | 197 # There's probably a bug to fix in otr.js. Do it together with the issue that |
198 # us need the dirty self.smpAuthAbort. | 198 # make us need the dirty self.smpAuthAbort. |
199 else: | 199 else: |
200 log.error("FIXME: unmanaged ambiguous 'act' value in Context.smpAuthCb!") | 200 log.error("FIXME: unmanaged ambiguous 'act' value in Context.smpAuthCb!") |
201 title = (_("Authentication of {jid}") if act == "asked" else _("Authentication to {jid}")).format(jid=self.peer.full()) | 201 title = (_("Authentication of {jid}") if act == "asked" else _("Authentication to {jid}")).format(jid=self.peer.full()) |
202 if type_ == 'question': | 202 if type_ == 'question': |
203 if act == 'asked': | 203 if act == 'asked': |
211 def cb(answer): | 211 def cb(answer): |
212 if not answer: # dialog cancelled or the answer is empty | 212 if not answer: # dialog cancelled or the answer is empty |
213 self.smpAuthAbort('answered') | 213 self.smpAuthAbort('answered') |
214 return | 214 return |
215 self.smpAuthSecret(answer) | 215 self.smpAuthSecret(answer) |
216 text = AUTH_INFO_TXT + AUTH_QUEST_ASK + _("This is the question asked by your buddy:{eol}{question}").format(eol=DIALOG_EOL, question=data) | 216 text = AUTH_INFO_TXT + AUTH_QUEST_ASK + _("This is the question asked by your correspondent:{eol}{question}").format(eol=DIALOG_EOL, question=data) |
217 dialog.PromptDialog(cb, text + AUTH_SECRET_TXT, title=title).show() | 217 dialog.PromptDialog(cb, text + AUTH_SECRET_TXT, title=title).show() |
218 elif type_ == 'trust': | 218 elif type_ == 'trust': |
219 self.setCurrentTrust('smp' if data else '', act) | 219 self.setCurrentTrust('smp' if data else '', act) |
220 elif type_ == 'abort': | 220 elif type_ == 'abort': |
221 self.setCurrentTrust('', act, 'abort') | 221 self.setCurrentTrust('', act, 'abort') |
281 """Tell the caller which dynamic menus should be inhibited""" | 281 """Tell the caller which dynamic menus should be inhibited""" |
282 return ["OTR"] # menu categories name to inhibit | 282 return ["OTR"] # menu categories name to inhibit |
283 | 283 |
284 def extraMenus(self): | 284 def extraMenus(self): |
285 # FIXME: handle help strings too | 285 # FIXME: handle help strings too |
286 return [(self._startRefresh, C.MENU_SINGLE, (MAIN_MENU, "Start/Refresh"), (MAIN_MENU, D_("Start/Refresh"))), | 286 return [(self._startRefresh, C.MENU_SINGLE, (MAIN_MENU, "Start / refresh"), (MAIN_MENU, D_("Start / refresh"))), |
287 (self._endSession, C.MENU_SINGLE, (MAIN_MENU, "End session"), (MAIN_MENU, D_("End session"))), | 287 (self._endSession, C.MENU_SINGLE, (MAIN_MENU, "Stop encryption"), (MAIN_MENU, D_("Stop encryption"))), |
288 (self._authenticate, C.MENU_SINGLE, (MAIN_MENU, "Authenticate buddy"), (MAIN_MENU, D_("Authenticate buddy"))), | 288 (self._authenticate, C.MENU_SINGLE, (MAIN_MENU, "Authenticate correspondent"), (MAIN_MENU, D_("Authenticate correspondent"))), |
289 (self._dropPrivkey, C.MENU_SINGLE, (MAIN_MENU, "Drop private key"), (MAIN_MENU, D_("Drop private key")))] | 289 (self._dropPrivkey, C.MENU_SINGLE, (MAIN_MENU, "Drop your private key"), (MAIN_MENU, D_("Drop your private key")))] |
290 | 290 |
291 def profileConnected(self): | 291 def profileConnected(self): |
292 self.host.bridge.call('skipOTR', None) | 292 self.host.bridge.call('skipOTR', None) |
293 self.context_manager = ContextManager(self.host) | 293 self.context_manager = ContextManager(self.host) |
294 # TODO: retrieve the encrypted private key from a HTML5 persistent storage, | 294 # TODO: retrieve the encrypted private key from a HTML5 persistent storage, |
380 if otr_version == otr.context.OTR_VERSION_2: | 380 if otr_version == otr.context.OTR_VERSION_2: |
381 otrctx.fingerprintAuthCb() | 381 otrctx.fingerprintAuthCb() |
382 elif otr_version == otr.context.OTR_VERSION_3: | 382 elif otr_version == otr.context.OTR_VERSION_3: |
383 otrctx.smpAuthCb('question', None, 'asked') | 383 otrctx.smpAuthCb('question', None, 'asked') |
384 else: | 384 else: |
385 dialog.InfoDialog(_("No running session"), _("You must start a private conversation before authenticating your buddy.")).show() | 385 dialog.InfoDialog(_("No running session"), _("You must start a private conversation before authenticating your correspondent.")).show() |
386 | 386 |
387 try: | 387 try: |
388 to_jid = menu_data['jid'] | 388 to_jid = menu_data['jid'] |
389 self.fixResource(to_jid, cb) | 389 self.fixResource(to_jid, cb) |
390 except KeyError: | 390 except KeyError: |