Search in sources :

Example 1 with InvalidPassphraseException

use of org.thoughtcrime.securesms.crypto.InvalidPassphraseException in project Signal-Android by WhisperSystems.

the class KeyCachingService method getMasterSecret.

@Nullable
public static synchronized MasterSecret getMasterSecret(Context context) {
    if (masterSecret == null && TextSecurePreferences.isPasswordDisabled(context)) {
        try {
            MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(context, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
            Intent intent = new Intent(context, KeyCachingService.class);
            context.startService(intent);
            return masterSecret;
        } catch (InvalidPassphraseException e) {
            Log.w("KeyCachingService", e);
        }
    }
    return masterSecret;
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) InvalidPassphraseException(org.thoughtcrime.securesms.crypto.InvalidPassphraseException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Nullable(android.support.annotation.Nullable)

Example 2 with InvalidPassphraseException

use of org.thoughtcrime.securesms.crypto.InvalidPassphraseException in project Signal-Android by WhisperSystems.

the class KeyCachingService method onCreate.

@Override
public void onCreate() {
    Log.w("KeyCachingService", "onCreate()");
    super.onCreate();
    this.pending = PendingIntent.getService(this, 0, new Intent(PASSPHRASE_EXPIRED_EVENT, null, this, KeyCachingService.class), 0);
    if (TextSecurePreferences.isPasswordDisabled(this)) {
        try {
            MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
            setMasterSecret(masterSecret);
        } catch (InvalidPassphraseException e) {
            Log.w("KeyCachingService", e);
        }
    }
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) InvalidPassphraseException(org.thoughtcrime.securesms.crypto.InvalidPassphraseException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 3 with InvalidPassphraseException

use of org.thoughtcrime.securesms.crypto.InvalidPassphraseException in project Signal-Android by WhisperSystems.

the class PassphrasePromptActivity method handlePassphrase.

private void handlePassphrase() {
    try {
        Editable text = passphraseText.getText();
        String passphrase = (text == null ? "" : text.toString());
        MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, passphrase);
        setMasterSecret(masterSecret);
    } catch (InvalidPassphraseException ipe) {
        passphraseText.setText("");
        passphraseText.setError(getString(R.string.PassphrasePromptActivity_invalid_passphrase_exclamation));
    }
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) InvalidPassphraseException(org.thoughtcrime.securesms.crypto.InvalidPassphraseException) Editable(android.text.Editable) SpannableString(android.text.SpannableString)

Aggregations

InvalidPassphraseException (org.thoughtcrime.securesms.crypto.InvalidPassphraseException)3 MasterSecret (org.thoughtcrime.securesms.crypto.MasterSecret)3 PendingIntent (android.app.PendingIntent)2 Intent (android.content.Intent)2 Nullable (android.support.annotation.Nullable)1 Editable (android.text.Editable)1 SpannableString (android.text.SpannableString)1