*/
public synchronized void saveMasterPasswordConfig(MasterPasswordConfig config,
char[] currPasswd, char[] newPasswd, char[] newPasswdConfirm) throws Exception {
//load the (possibly new) master password provider
MasterPasswordProviderConfig mpProviderConfig =
loadMasterPassswordProviderConfig(config.getProviderName());
MasterPasswordProvider mpProvider = loadMasterPasswordProvider(config.getProviderName());
if (mpProviderConfig.isReadOnly()) {
//new password comes from the provider
newPasswd = mpProvider.getMasterPassword();
}
//first validate the password change
MasterPasswordChangeRequest req = new MasterPasswordChangeRequest();
req.setCurrentPassword(currPasswd);
req.setNewPassword(newPasswd);
req.setConfirmPassword(newPasswdConfirm);
MasterPasswordChangeValidator val = new MasterPasswordChangeValidator(this);
val.validateChangeRequest(req);
//validate the new config
MasterPasswordConfigValidator validator = new MasterPasswordConfigValidator(this);
validator.validateMasterPasswordConfig(config);
//save the current config to fall back to
MasterPasswordConfig oldConfig = new MasterPasswordConfig(this.masterPasswordConfig);
String oldMasterPasswdDigest = masterPasswdDigest;
KeyStoreProvider ksProvider = getKeyStoreProvider();
synchronized (ksProvider) {
ksProvider.prepareForMasterPasswordChange(currPasswd, newPasswdConfirm);
try {
if (!mpProviderConfig.isReadOnly()) {
//write it back first
try {
mpProvider.setMasterPassword(newPasswd);
} catch (Exception e) {
throw new IOException(e);