Mercurial > libervia-web
comparison src/browser/sat_browser/plugin_sec_otr.py @ 524:d41e850b31b9
browser_side (plugin OTR): limit the max width for all dialogs
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 03 Sep 2014 11:22:37 +0200 |
parents | 5add182e7dd5 |
children | 307f84fee972 |
comparison
equal
deleted
inserted
replaced
523:5add182e7dd5 | 524:d41e850b31b9 |
---|---|
141 msg = _("Authentication successful.") | 141 msg = _("Authentication successful.") |
142 else: | 142 else: |
143 msg = _("Your correspondent has successfully authenticated you. You may want to authenticate your correspondent 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, AddStyleName="maxWidthLimit").show() |
147 if act != "asked": | 147 if act != "asked": |
148 return | 148 return |
149 old_trust = self.getCurrentTrust() | 149 old_trust = self.getCurrentTrust() |
150 otr.context.Context.setCurrentTrust(self, new_trust) | 150 otr.context.Context.setCurrentTrust(self, new_trust) |
151 if old_trust != new_trust: | 151 if old_trust != new_trust: |
162 | 162 |
163 other_key = self.getCurrentKey() | 163 other_key = self.getCurrentKey() |
164 if other_key is None: | 164 if other_key is None: |
165 # we have a private key, but not the fingerprint of our correspondent | 165 # we have a private key, but not the fingerprint of our correspondent |
166 msg = AUTH_INFO_TXT + ("Your fingerprint is:{eol}{fingerprint}{eol}{eol}Start an OTR conversation to have your correspondent one.").format(fingerprint=priv_key.fingerprint(), eol=DIALOG_EOL) | 166 msg = AUTH_INFO_TXT + ("Your fingerprint is:{eol}{fingerprint}{eol}{eol}Start an OTR conversation to have your correspondent one.").format(fingerprint=priv_key.fingerprint(), eol=DIALOG_EOL) |
167 dialog.InfoDialog(_("Fingerprint"), msg).show() | 167 dialog.InfoDialog(_("Fingerprint"), msg, AddStyleName="maxWidthLimit").show() |
168 return | 168 return |
169 | 169 |
170 def setTrust(confirm): | 170 def setTrust(confirm): |
171 self.setCurrentTrust('fingerprint' if confirm else '') | 171 self.setCurrentTrust('fingerprint' if confirm else '') |
172 | 172 |
173 text = AUTH_INFO_TXT + AUTH_FINGERPRINT_TXT + _("Fingerprint for you, {jid}:{eol}{fingerprint}{eol}{eol}").format(jid=self.host.whoami, fingerprint=priv_key.fingerprint(), eol=DIALOG_EOL) | 173 text = AUTH_INFO_TXT + AUTH_FINGERPRINT_TXT + _("Fingerprint for you, {jid}:{eol}{fingerprint}{eol}{eol}").format(jid=self.host.whoami, fingerprint=priv_key.fingerprint(), eol=DIALOG_EOL) |
174 text += _("Purported fingerprint for {jid}:{eol}{fingerprint}{eol}{eol}").format(jid=self.peer, fingerprint=other_key.fingerprint(), eol=DIALOG_EOL) | 174 text += _("Purported fingerprint for {jid}:{eol}{fingerprint}{eol}{eol}").format(jid=self.peer, fingerprint=other_key.fingerprint(), eol=DIALOG_EOL) |
175 text += _("Did you verify that this is in fact the correct fingerprint for {jid}?").format(jid=self.peer) | 175 text += _("Did you verify that this is in fact the correct fingerprint for {jid}?").format(jid=self.peer) |
176 title = _('Authentication of {jid}').format(jid=self.peer.full()) | 176 title = _('Authentication of {jid}').format(jid=self.peer.full()) |
177 dialog.ConfirmDialog(setTrust, text, title).show() | 177 dialog.ConfirmDialog(setTrust, text, title, AddStyleName="maxWidthLimit").show() |
178 | 178 |
179 def smpAuthCb(self, type_, data, act=None): | 179 def smpAuthCb(self, type_, data, act=None): |
180 """OTR v3 authentication using the socialist millionaire protocol. | 180 """OTR v3 authentication using the socialist millionaire protocol. |
181 | 181 |
182 @param type_ (str): a value in ('question', 'trust', 'abort') | 182 @param type_ (str): a value in ('question', 'trust', 'abort') |
204 def cb(question, answer=None): | 204 def cb(question, answer=None): |
205 if question is False or not answer: # dialog cancelled or the answer is empty | 205 if question is False or not answer: # dialog cancelled or the answer is empty |
206 return | 206 return |
207 self.smpAuthSecret(answer, question) | 207 self.smpAuthSecret(answer, question) |
208 text = AUTH_INFO_TXT + AUTH_QUEST_DEF + _("Enter question here:{eol}").format(eol=DIALOG_EOL, question=data) | 208 text = AUTH_INFO_TXT + AUTH_QUEST_DEF + _("Enter question here:{eol}").format(eol=DIALOG_EOL, question=data) |
209 dialog.PromptDialog(cb, [text, AUTH_SECRET_TXT], title=title).show() | 209 dialog.PromptDialog(cb, [text, AUTH_SECRET_TXT], title=title, AddStyleName="maxWidthLimit").show() |
210 else: | 210 else: |
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 correspondent:{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, AddStyleName="maxWidthLimit").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') |
222 | 222 |
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 correspondent.")).show() | 385 dialog.InfoDialog(_("No running session"), _("You must start a private conversation before authenticating your correspondent."), AddStyleName="maxWidthLimit").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: |
400 def cb(to_jid): | 400 def cb(to_jid): |
401 priv_key = self.context_manager.account.privkey | 401 priv_key = self.context_manager.account.privkey |
402 | 402 |
403 if priv_key is None: | 403 if priv_key is None: |
404 # we have no private key yet | 404 # we have no private key yet |
405 dialog.InfoDialog(_("No private key"), _("You don't have any private key yet!")).show() | 405 dialog.InfoDialog(_("No private key"), _("You don't have any private key yet!"), AddStyleName="maxWidthLimit").show() |
406 return | 406 return |
407 | 407 |
408 def dropKey(confirm): | 408 def dropKey(confirm): |
409 if confirm: | 409 if confirm: |
410 # we end all sessions | 410 # we end all sessions |
411 for context in self.context_manager.contexts.values(): | 411 for context in self.context_manager.contexts.values(): |
412 if context.state not in (otr.context.STATE_FINISHED, otr.context.STATE_PLAINTEXT): | 412 if context.state not in (otr.context.STATE_FINISHED, otr.context.STATE_PLAINTEXT): |
413 context.disconnect() | 413 context.disconnect() |
414 self.context_manager.account.privkey = None | 414 self.context_manager.account.privkey = None |
415 self.context_manager.account.getPrivkey() # as account.privkey are None, getPrivkey will generate a new key, and save it | 415 self.context_manager.account.getPrivkey() # as account.privkey are None, getPrivkey will generate a new key, and save it |
416 dialog.InfoDialog(_("Your private key has been dropped"), _('Drop')).show() | 416 dialog.InfoDialog(_('Private key'), _("Your private key has been dropped."), AddStyleName="maxWidthLimit").show() |
417 | 417 |
418 text = _(DROP_TXT) | 418 text = _(DROP_TXT) |
419 title = _('Confirm private key drop') | 419 title = _('Drop your private key') |
420 dialog.ConfirmDialog(dropKey, text, title).show() | 420 dialog.ConfirmDialog(dropKey, text, title, AddStyleName="maxWidthLimit").show() |
421 | 421 |
422 try: | 422 try: |
423 to_jid = menu_data['jid'] | 423 to_jid = menu_data['jid'] |
424 self.fixResource(to_jid, cb) | 424 self.fixResource(to_jid, cb) |
425 except KeyError: | 425 except KeyError: |