Add a UI for changing the password

This commit is contained in:
str4d
2016-06-10 12:58:01 +00:00
parent e96838e731
commit c5708ee3ce
11 changed files with 640 additions and 31 deletions

View File

@@ -22,29 +22,17 @@ import javax.inject.Inject;
import static java.util.logging.Level.INFO;
public class SetupControllerImpl implements SetupController {
public class SetupControllerImpl extends PasswordControllerImpl
implements SetupController {
private static final Logger LOG =
Logger.getLogger(SetupControllerImpl.class.getName());
private final static String PREF_DB_KEY = "key";
@Inject
@CryptoExecutor
protected Executor cryptoExecutor;
@Inject
protected PasswordStrengthEstimator strengthEstimator;
@Inject
protected Activity activity;
@Inject
protected SharedPreferences briarPrefs;
// Fields that are accessed from background threads must be volatile
@Inject
protected volatile CryptoComponent crypto;
@Inject
protected volatile DatabaseConfig databaseConfig;
@Inject
protected volatile AuthorFactory authorFactory;
@Inject
protected volatile ReferenceManager referenceManager;
@@ -54,15 +42,6 @@ public class SetupControllerImpl implements SetupController {
}
private String encryptDatabaseKey(SecretKey key, String password) {
long now = System.currentTimeMillis();
byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Key derivation took " + duration + " ms");
return StringUtils.toHexString(encrypted);
}
private LocalAuthor createLocalAuthor(String nickname) {
long now = System.currentTimeMillis();
KeyPair keyPair = crypto.generateSignatureKeyPair();
@@ -98,10 +77,4 @@ public class SetupControllerImpl implements SetupController {
}
});
}
private void storeEncryptedDatabaseKey(String hex) {
SharedPreferences.Editor editor = briarPrefs.edit();
editor.putString(PREF_DB_KEY, hex);
editor.apply();
}
}