| @@ 318-384 (lines=67) @@ | ||
| 315 | /** |
|
| 316 | * @static |
|
| 317 | */ |
|
| 318 | PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients) |
|
| 319 | { |
|
| 320 | return function() { |
|
| 321 | ||
| 322 | var |
|
| 323 | message = null, |
|
| 324 | $this = $(this); |
|
| 325 | ||
| 326 | if ($this.hasClass('success')) |
|
| 327 | { |
|
| 328 | return false; |
|
| 329 | } |
|
| 330 | ||
| 331 | try |
|
| 332 | { |
|
| 333 | message = store.openpgp.message.readArmored(sArmoredMessage); |
|
| 334 | } |
|
| 335 | catch (e) |
|
| 336 | { |
|
| 337 | Utils.log(e); |
|
| 338 | } |
|
| 339 | ||
| 340 | if (message && message.getText && message.verify && message.decrypt) |
|
| 341 | { |
|
| 342 | store.decryptMessage(message, aRecipients, function(oValidPrivateKey, oDecryptedMessage, oValidPublicKey, aSigningKeyIds) { |
|
| 343 | ||
| 344 | if (oDecryptedMessage) |
|
| 345 | { |
|
| 346 | if (oValidPublicKey) |
|
| 347 | { |
|
| 348 | store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', { |
|
| 349 | 'USER': oValidPublicKey.user + ' (' + oValidPublicKey.id + ')' |
|
| 350 | }), oDecryptedMessage.getText()); |
|
| 351 | } |
|
| 352 | else if (oValidPrivateKey) |
|
| 353 | { |
|
| 354 | var |
|
| 355 | aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null, |
|
| 356 | sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) { |
|
| 357 | return oItem && oItem.toHex ? oItem.toHex() : null; |
|
| 358 | })).join(', ') : ''; |
|
| 359 | ||
| 360 | store.controlsHelper(mDom, $this, false, |
|
| 361 | Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + |
|
| 362 | (sAdditional ? ' (' + sAdditional + ')' : ''), |
|
| 363 | oDecryptedMessage.getText()); |
|
| 364 | } |
|
| 365 | else |
|
| 366 | { |
|
| 367 | store.controlsHelper(mDom, $this, false, |
|
| 368 | Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR')); |
|
| 369 | } |
|
| 370 | } |
|
| 371 | else |
|
| 372 | { |
|
| 373 | store.controlsHelper(mDom, $this, false, |
|
| 374 | Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR')); |
|
| 375 | } |
|
| 376 | }); |
|
| 377 | ||
| 378 | return false; |
|
| 379 | } |
|
| 380 | ||
| 381 | store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR')); |
|
| 382 | return false; |
|
| 383 | }; |
|
| 384 | }; |
|
| 385 | ||
| 386 | /** |
|
| 387 | * @static |
|
| @@ 389-440 (lines=52) @@ | ||
| 386 | /** |
|
| 387 | * @static |
|
| 388 | */ |
|
| 389 | PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage) |
|
| 390 | { |
|
| 391 | return function() { |
|
| 392 | ||
| 393 | var |
|
| 394 | message = null, |
|
| 395 | $this = $(this); |
|
| 396 | ||
| 397 | if ($this.hasClass('success') || $this.hasClass('error')) |
|
| 398 | { |
|
| 399 | return false; |
|
| 400 | } |
|
| 401 | ||
| 402 | try |
|
| 403 | { |
|
| 404 | message = store.openpgp.cleartext.readArmored(sArmoredMessage); |
|
| 405 | } |
|
| 406 | catch (e) |
|
| 407 | { |
|
| 408 | Utils.log(e); |
|
| 409 | } |
|
| 410 | ||
| 411 | if (message && message.getText && message.verify) |
|
| 412 | { |
|
| 413 | store.verifyMessage(message, function(oValidKey, aSigningKeyIds) { |
|
| 414 | if (oValidKey) |
|
| 415 | { |
|
| 416 | store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', { |
|
| 417 | 'USER': oValidKey.user + ' (' + oValidKey.id + ')' |
|
| 418 | }), message.getText()); |
|
| 419 | } |
|
| 420 | else |
|
| 421 | { |
|
| 422 | var |
|
| 423 | aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null, |
|
| 424 | sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) { |
|
| 425 | return oItem && oItem.toHex ? oItem.toHex() : null; |
|
| 426 | })).join(', ') : ''; |
|
| 427 | ||
| 428 | store.controlsHelper(mDom, $this, false, |
|
| 429 | Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + |
|
| 430 | (sAdditional ? ' (' + sAdditional + ')' : '')); |
|
| 431 | } |
|
| 432 | }); |
|
| 433 | ||
| 434 | return false; |
|
| 435 | } |
|
| 436 | ||
| 437 | store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR')); |
|
| 438 | return false; |
|
| 439 | }; |
|
| 440 | }; |
|
| 441 | ||
| 442 | /** |
|
| 443 | * @param {*} mDom |
|