Bug 745834 - Set encryption type correctly in java. r=mfinkle

This commit is contained in:
Wes Johnston 2012-04-16 11:27:17 -07:00
parent 31d31d347e
commit 1559635ebd
3 changed files with 9 additions and 1 deletions

View File

@ -192,6 +192,9 @@ public class BrowserContract {
public static final String TIME_PASSWORD_CHANGED = "timePasswordChanged";
public static final String TIMES_USED = "timesUsed";
public static final String GUID = "guid";
// This needs to be kept in sync with the types defined in toolkit/components/passwordmgr/nsILoginManagerCrypto.idl#45
public static final int ENCTYPE_SDR = 1;
}
public static final class DeletedPasswords implements DeletedColumns {

View File

@ -228,11 +228,13 @@ public class PasswordsProvider extends GeckoProvider {
if (values.containsKey(Passwords.ENCRYPTED_PASSWORD)) {
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_PASSWORD), uri, true);
values.put(Passwords.ENCRYPTED_PASSWORD, res);
values.put(Passwords.ENC_TYPE, Passwords.ENCTYPE_SDR);
}
if (values.containsKey(Passwords.ENCRYPTED_USERNAME)) {
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_USERNAME), uri, true);
values.put(Passwords.ENCRYPTED_USERNAME, res);
values.put(Passwords.ENC_TYPE, Passwords.ENCTYPE_SDR);
}
}
@ -241,11 +243,13 @@ public class PasswordsProvider extends GeckoProvider {
if (values.containsKey(Passwords.ENCRYPTED_PASSWORD)) {
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_PASSWORD), uri, true);
values.put(Passwords.ENCRYPTED_PASSWORD, res);
values.put(Passwords.ENC_TYPE, Passwords.ENCTYPE_SDR);
}
if (values.containsKey(Passwords.ENCRYPTED_USERNAME)) {
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_USERNAME), uri, true);
values.put(Passwords.ENCRYPTED_USERNAME, res);
values.put(Passwords.ENC_TYPE, Passwords.ENCTYPE_SDR);
}
}

View File

@ -58,10 +58,11 @@ public class testPasswordEncrypt extends BaseTest {
String decryptedU = (String)decrypt.invoke(null, context, mProfile, list.getString(0));
mAsserter.is(decryptedU, "username", "Username was encrypted correctly when inserting");
list = mActions.querySql(dbPath, "SELECT encryptedPassword FROM moz_logins");
list = mActions.querySql(dbPath, "SELECT encryptedPassword, encType FROM moz_logins");
list.moveToFirst();
String decryptedP = (String)decrypt.invoke(null, context, mProfile, list.getString(0));
mAsserter.is(decryptedP, "password", "Password was encrypted correctly when inserting");
mAsserter.is(list.getInt(1), 1, "Password has correct encryption type");
cvs.put("encryptedUsername", "username2");
cvs.put("encryptedPassword", "password2");