Addressed review comments: Fixed copy-paste error, fixed migration from Facebook conceal and removed unused variable.
This commit is contained in:
parent
10463e693d
commit
544b92f262
|
@ -192,6 +192,8 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
||||||
service = service == null ? DEFAULT_ALIAS : service;
|
service = service == null ? DEFAULT_ALIAS : service;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
final byte[] decryptedUsername;
|
||||||
|
final byte[] decryptedPassword;
|
||||||
byte[] recuser = getBytesFromPrefs(service, DELIMITER + "u");
|
byte[] recuser = getBytesFromPrefs(service, DELIMITER + "u");
|
||||||
byte[] recpass = getBytesFromPrefs(service, DELIMITER + "p");
|
byte[] recpass = getBytesFromPrefs(service, DELIMITER + "p");
|
||||||
if (recuser == null || recpass == null) {
|
if (recuser == null || recpass == null) {
|
||||||
|
@ -202,24 +204,25 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
||||||
setGenericPasswordForOptions(
|
setGenericPasswordForOptions(
|
||||||
originalService,
|
originalService,
|
||||||
new String(resultSet.decryptedUsername, Charset.forName("UTF-8")),
|
new String(resultSet.decryptedUsername, Charset.forName("UTF-8")),
|
||||||
new String(resultSet.decryptedUsername, Charset.forName("UTF-8")));
|
new String(resultSet.decryptedPassword, Charset.forName("UTF-8")));
|
||||||
// Remove the legacy value(s)
|
// Remove the legacy value(s)
|
||||||
resetGenericPasswordForOptionsLegacy(originalService);
|
resetGenericPasswordForOptionsLegacy(originalService);
|
||||||
recuser = resultSet.decryptedUsername;
|
decryptedUsername = resultSet.decryptedUsername;
|
||||||
recpass = resultSet.decryptedPassword;
|
decryptedPassword = resultSet.decryptedPassword;
|
||||||
} else {
|
} else {
|
||||||
Log.e(KEYCHAIN_MODULE, "no keychain entry found for service: " + service);
|
Log.e(KEYCHAIN_MODULE, "no keychain entry found for service: " + service);
|
||||||
promise.resolve(false);
|
promise.resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
KeyStore keyStore = getKeyStoreAndLoad();
|
||||||
|
|
||||||
KeyStore keyStore = getKeyStoreAndLoad();
|
Key key = keyStore.getKey(service, null);
|
||||||
|
|
||||||
Key key = keyStore.getKey(service, null);
|
decryptedUsername = decryptBytes(key, recuser);
|
||||||
|
decryptedPassword = decryptBytes(key, recpass);
|
||||||
byte[] decryptedUsername = decryptBytes(key, recuser);
|
}
|
||||||
byte[] decryptedPassword = decryptBytes(key, recpass);
|
|
||||||
|
|
||||||
WritableMap credentials = Arguments.createMap();
|
WritableMap credentials = Arguments.createMap();
|
||||||
|
|
||||||
|
@ -300,7 +303,6 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getBytesFromPrefs(String service, String prefix) {
|
private byte[] getBytesFromPrefs(String service, String prefix) {
|
||||||
String key = service + prefix;
|
|
||||||
String value = prefs.getString(service + prefix, null);
|
String value = prefs.getString(service + prefix, null);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return Base64.decode(value, Base64.DEFAULT);
|
return Base64.decode(value, Base64.DEFAULT);
|
||||||
|
|
Loading…
Reference in New Issue