Work on new result handling (WIP)
This commit is contained in:
@@ -40,6 +40,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
||||
import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||
@@ -269,6 +270,17 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
/* Operation */
|
||||
PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(
|
||||
new ProviderHelper(this),
|
||||
new PassphraseCacheInterface() {
|
||||
@Override
|
||||
public String getCachedPassphrase(long masterKeyId) throws PassphraseCacheInterface.NoSecretKeyException {
|
||||
try {
|
||||
return PassphraseCacheService.getCachedPassphrase(
|
||||
KeychainIntentService.this, masterKeyId);
|
||||
} catch (PassphraseCacheService.KeyNotFoundException e) {
|
||||
throw new PassphraseCacheInterface.NoSecretKeyException();
|
||||
}
|
||||
}
|
||||
},
|
||||
inputData, outStream
|
||||
);
|
||||
builder.setProgressable(this)
|
||||
@@ -342,14 +354,14 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
// verification of signatures
|
||||
PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(
|
||||
new ProviderHelper(this),
|
||||
new PgpDecryptVerify.PassphraseCache() {
|
||||
new PassphraseCacheInterface() {
|
||||
@Override
|
||||
public String getCachedPassphrase(long masterKeyId) {
|
||||
public String getCachedPassphrase(long masterKeyId) throws PassphraseCacheInterface.NoSecretKeyException {
|
||||
try {
|
||||
return PassphraseCacheService.getCachedPassphrase(
|
||||
KeychainIntentService.this, masterKeyId);
|
||||
} catch (PassphraseCacheService.KeyNotFoundException e) {
|
||||
return null;
|
||||
throw new PassphraseCacheInterface.NoSecretKeyException();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -390,14 +402,14 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
// verification of signatures
|
||||
PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(
|
||||
new ProviderHelper(this),
|
||||
new PgpDecryptVerify.PassphraseCache() {
|
||||
new PassphraseCacheInterface() {
|
||||
@Override
|
||||
public String getCachedPassphrase(long masterKeyId) throws PgpDecryptVerify.NoSecretKeyException {
|
||||
public String getCachedPassphrase(long masterKeyId) throws PassphraseCacheInterface.NoSecretKeyException {
|
||||
try {
|
||||
return PassphraseCacheService.getCachedPassphrase(
|
||||
KeychainIntentService.this, masterKeyId);
|
||||
} catch (PassphraseCacheService.KeyNotFoundException e) {
|
||||
throw new PgpDecryptVerify.NoSecretKeyException();
|
||||
throw new PassphraseCacheInterface.NoSecretKeyException();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -26,12 +26,12 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
public class DecryptVerifyResult extends OperationResult {
|
||||
|
||||
// the fourth bit indicates a "data pending" result! (it's also a form of non-success)
|
||||
public static final int RESULT_PENDING = RESULT_ERROR +8;
|
||||
public static final int RESULT_PENDING = RESULT_ERROR + 8;
|
||||
|
||||
// fifth to sixth bit in addition indicate specific type of pending
|
||||
public static final int RESULT_PENDING_ASYM_PASSPHRASE = RESULT_PENDING +16;
|
||||
public static final int RESULT_PENDING_SYM_PASSPHRASE = RESULT_PENDING +32;
|
||||
public static final int RESULT_PENDING_NFC = RESULT_PENDING +48;
|
||||
public static final int RESULT_PENDING_ASYM_PASSPHRASE = RESULT_PENDING + 16;
|
||||
public static final int RESULT_PENDING_SYM_PASSPHRASE = RESULT_PENDING + 32;
|
||||
public static final int RESULT_PENDING_NFC = RESULT_PENDING + 48;
|
||||
|
||||
long mKeyIdPassphraseNeeded;
|
||||
byte[] mNfcSessionKey;
|
||||
|
||||
@@ -475,7 +475,6 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_SE_ERROR_SIGN_KEY(LogLevel.ERROR, R.string.msg_se_error_sign_key),
|
||||
MSG_SE_ERROR_KEY_SIGN (LogLevel.ERROR, R.string.msg_se_error_key_sign),
|
||||
MSG_SE_ERROR_NFC (LogLevel.ERROR, R.string.msg_se_error_nfc),
|
||||
MSG_SE_ERROR_NO_PASSPHRASE (LogLevel.ERROR, R.string.msg_se_error_no_passphrase),
|
||||
MSG_SE_ERROR_PGP (LogLevel.ERROR, R.string.msg_se_error_pgp),
|
||||
MSG_SE_ERROR_SIG (LogLevel.ERROR, R.string.msg_se_error_sig),
|
||||
MSG_SE_ERROR_UNLOCK (LogLevel.ERROR, R.string.msg_se_error_unlock),
|
||||
@@ -484,6 +483,7 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_SE_KEY_WARN (LogLevel.WARN, R.string.msg_se_key_warn),
|
||||
MSG_SE_OK (LogLevel.OK, R.string.msg_se_ok),
|
||||
MSG_SE_PENDING_NFC (LogLevel.INFO, R.string.msg_se_pending_nfc),
|
||||
MSG_SE_PENDING_PASSPHRASE (LogLevel.INFO, R.string.msg_se_pending_passphrase),
|
||||
MSG_SE (LogLevel.DEBUG, R.string.msg_se),
|
||||
MSG_SE_SIGNING (LogLevel.DEBUG, R.string.msg_se_signing),
|
||||
MSG_SE_SIGCRYPTING (LogLevel.DEBUG, R.string.msg_se_sigcrypting),
|
||||
|
||||
@@ -24,15 +24,26 @@ import java.util.Date;
|
||||
public class SignEncryptResult extends OperationResult {
|
||||
|
||||
// the fourth bit indicates a "data pending" result! (it's also a form of non-success)
|
||||
public static final int RESULT_PENDING = RESULT_ERROR +8;
|
||||
public static final int RESULT_PENDING = RESULT_ERROR + 8;
|
||||
|
||||
// fifth to sixth bit in addition indicate specific type of pending
|
||||
public static final int RESULT_PENDING_NFC = RESULT_PENDING +16;
|
||||
public static final int RESULT_PENDING_PASSPHRASE = RESULT_PENDING + 16;
|
||||
public static final int RESULT_PENDING_NFC = RESULT_PENDING + 32;
|
||||
|
||||
long mKeyIdPassphraseNeeded;
|
||||
|
||||
byte[] mNfcHash;
|
||||
int mNfcAlgo;
|
||||
Date mNfcTimestamp;
|
||||
|
||||
public long getKeyIdPassphraseNeeded() {
|
||||
return mKeyIdPassphraseNeeded;
|
||||
}
|
||||
|
||||
public void setKeyIdPassphraseNeeded(long keyIdPassphraseNeeded) {
|
||||
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
|
||||
}
|
||||
|
||||
public void setNfcData(byte[] sessionKey, int nfcAlgo, Date nfcTimestamp) {
|
||||
mNfcHash = sessionKey;
|
||||
mNfcAlgo = nfcAlgo;
|
||||
@@ -52,7 +63,7 @@ public class SignEncryptResult extends OperationResult {
|
||||
}
|
||||
|
||||
public boolean isPending() {
|
||||
return (mResult & RESULT_PENDING) != 0;
|
||||
return (mResult & RESULT_PENDING) == RESULT_PENDING;
|
||||
}
|
||||
|
||||
public SignEncryptResult(int result, OperationLog log) {
|
||||
|
||||
Reference in New Issue
Block a user