fixed symmetric decrypting, stream didn't support .reset(), I guess, so now creating fresh streams where needed, and changed exception string to "" + e, rather than getMessage(), as that still can be null... annoying.

This commit is contained in:
Thialfihar 2010-05-21 02:47:40 +00:00
parent e5573973e7
commit 2c784554c7
7 changed files with 32 additions and 33 deletions

View File

@ -465,7 +465,7 @@ public class Apg {
} catch (UserIdEditor.NoEmailException e) { } catch (UserIdEditor.NoEmailException e) {
throw new Apg.GeneralException(context.getString(R.string.error_userIdNeedsAnEmailAddress)); throw new Apg.GeneralException(context.getString(R.string.error_userIdNeedsAnEmailAddress));
} catch (UserIdEditor.InvalidEmailException e) { } catch (UserIdEditor.InvalidEmailException e) {
throw new Apg.GeneralException(e.getMessage()); throw new Apg.GeneralException("" + e);
} }
if (userId.equals("")) { if (userId.equals("")) {

View File

@ -373,9 +373,9 @@ public class DecryptActivity extends BaseActivity {
// look at the file/message again to check whether there's // look at the file/message again to check whether there's
// symmetric encryption data in there // symmetric encryption data in there
if (mDecryptTarget == Id.target.file) { if (mDecryptTarget == Id.target.file) {
((FileInputStream) in).reset(); in = new FileInputStream(mInputFilename);
} else { } else {
((ByteArrayInputStream) in).reset(); in = new ByteArrayInputStream(mMessage.getText().toString().getBytes());
} }
if (!Apg.hasSymmetricEncryption(this, in)) { if (!Apg.hasSymmetricEncryption(this, in)) {
throw new Apg.GeneralException(getString(R.string.error_noKnownEncryptionFound)); throw new Apg.GeneralException(getString(R.string.error_noKnownEncryptionFound));
@ -396,9 +396,9 @@ public class DecryptActivity extends BaseActivity {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
error = getString(R.string.error_fileNotFound); error = getString(R.string.error_fileNotFound);
} catch (IOException e) { } catch (IOException e) {
error = e.getLocalizedMessage(); error = "" + e;
} catch (Apg.GeneralException e) { } catch (Apg.GeneralException e) {
error = e.getLocalizedMessage(); error = "" + e;
} }
if (error != null) { if (error != null) {
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.makeText(this, getString(R.string.errorMessage, error),
@ -479,14 +479,13 @@ public class DecryptActivity extends BaseActivity {
out).toByteArray())); out).toByteArray()));
} }
} catch (PGPException e) { } catch (PGPException e) {
error = e.getMessage(); error = "" + e;
} catch (IOException e) { } catch (IOException e) {
error = e.getMessage(); error = "" + e;
} catch (SignatureException e) { } catch (SignatureException e) {
error = e.getMessage(); error = "" + e;
e.printStackTrace();
} catch (Apg.GeneralException e) { } catch (Apg.GeneralException e) {
error = e.getMessage(); error = "" + e;
} }
data.putInt("type", Id.message.done); data.putInt("type", Id.message.done);

View File

@ -245,15 +245,15 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener {
Apg.buildSecretKey(this, mUserIds, mKeys, oldPassPhrase, newPassPhrase, this); Apg.buildSecretKey(this, mUserIds, mKeys, oldPassPhrase, newPassPhrase, this);
Apg.setCachedPassPhrase(getMasterKeyId(), newPassPhrase); Apg.setCachedPassPhrase(getMasterKeyId(), newPassPhrase);
} catch (NoSuchProviderException e) { } catch (NoSuchProviderException e) {
error = e.getMessage(); error = "" + e;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
error = e.getMessage(); error = "" + e;
} catch (PGPException e) { } catch (PGPException e) {
error = e.getMessage(); error = "" + e;
} catch (SignatureException e) { } catch (SignatureException e) {
error = e.getMessage(); error = "" + e;
} catch (Apg.GeneralException e) { } catch (Apg.GeneralException e) {
error = e.getMessage(); error = "" + e;
} }
data.putInt("type", Id.message.done); data.putInt("type", Id.message.done);

View File

@ -585,17 +585,17 @@ public class EncryptActivity extends BaseActivity {
data.putString("message", new String(((ByteArrayOutputStream)out).toByteArray())); data.putString("message", new String(((ByteArrayOutputStream)out).toByteArray()));
} }
} catch (IOException e) { } catch (IOException e) {
error = e.getMessage(); error = "" + e;
} catch (PGPException e) { } catch (PGPException e) {
error = e.getMessage(); error = "" + e;
} catch (NoSuchProviderException e) { } catch (NoSuchProviderException e) {
error = e.getMessage(); error = "" + e;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
error = e.getMessage(); error = "" + e;
} catch (SignatureException e) { } catch (SignatureException e) {
error = e.getMessage(); error = "" + e;
} catch (Apg.GeneralException e) { } catch (Apg.GeneralException e) {
error = e.getMessage(); error = "" + e;
} }
data.putInt("type", Id.message.done); data.putInt("type", Id.message.done);

View File

@ -280,11 +280,11 @@ public class PublicKeyListActivity extends BaseActivity {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
error = getString(R.string.error_fileNotFound); error = getString(R.string.error_fileNotFound);
} catch (IOException e) { } catch (IOException e) {
error = e.getMessage(); error = "" + e;
} catch (PGPException e) { } catch (PGPException e) {
error = e.getMessage(); error = "" + e;
} catch (Apg.GeneralException e) { } catch (Apg.GeneralException e) {
error = e.getMessage(); error = "" + e;
} }
if (mTask == Id.task.import_keys) { if (mTask == Id.task.import_keys) {

View File

@ -381,11 +381,11 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
error = getString(R.string.error_fileNotFound); error = getString(R.string.error_fileNotFound);
} catch (IOException e) { } catch (IOException e) {
error = e.getMessage(); error = "" + e;
} catch (PGPException e) { } catch (PGPException e) {
error = e.getMessage(); error = "" + e;
} catch (Apg.GeneralException e) { } catch (Apg.GeneralException e) {
error = e.getMessage(); error = "" + e;
} }
if (mTask == Id.task.import_keys) { if (mTask == Id.task.import_keys) {

View File

@ -310,17 +310,17 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
mNewKeySize, passPhrase, mNewKeySize, passPhrase,
masterKey); masterKey);
} catch (NoSuchProviderException e) { } catch (NoSuchProviderException e) {
error = e.getMessage(); error = "" + e;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
error = e.getMessage(); error = "" + e;
} catch (PGPException e) { } catch (PGPException e) {
error = e.getMessage(); error = "" + e;
} catch (InvalidParameterException e) { } catch (InvalidParameterException e) {
error = e.getMessage(); error = "" + e;
} catch (InvalidAlgorithmParameterException e) { } catch (InvalidAlgorithmParameterException e) {
error = e.getMessage(); error = "" + e;
} catch (Apg.GeneralException e) { } catch (Apg.GeneralException e) {
error = e.getMessage(); error = "" + e;
} }
Message message = new Message(); Message message = new Message();