thank you for excellent support in my previous request in "Keystore.checkPassword" funciton. I am testing further the changing of password and encountered in a strange behavior. Briefly - I can change password of keystore which is proved after setting it, but at next call the password remains unchanged.
I am calling firstly this:
KeyStore keyStore = new KeyStore(userName+".keystore", pass);
//load the key store data from a previous session
File keystoreFile = mContext.getFileStreamPath(userName+".keystore");
if (keystoreFile.exists())
{
mKeyPath = keystoreFile.getAbsolutePath();
InputStream keystoreStream = mContext.openFileInput(userName+".keystore");
keyStore.loadFromStream(keystoreStream);
System.err.println("mKeyPath: "+mKeyPath+ "keystore password: "+keyStore.getKeystorePassword());
}
This functions shows the right password in logs
Then I am calling directly checking the password from KeyPair object:
// user id is the userMail
if (keyStore.getKey(userMail).checkPassword(pass))
{
System.err.println("password is right: "+keyStore.getKeystorePassword());
........
and here to I see the right password in logs.
Then in next function I am trying to change the password. I am creating the LeyStore object exactly as here in above code calling:
......
keyStore.setKeystorePassword(newPass);
System.err.println("setting new password; "+"keystore password: "+keyStore.getKeystorePassword());
the checking the password shows that is set, i.e. the getKeystorePassword() shows already the new password.
But in this case the direct calling of code below fails:
// user id is the userMail
if (keyStore.getKey(userMail).checkPassword(newPass))
{
...... fails here
and in next call the keyStore.getKeystorePassword() (I am using dialog box for adding old/new password) shows that the password is an older one, not a newer, even the logs above shown that it was changes succesfully.
So, I hope I described the case rightly, the "keyStore.setKeystorePassword(newPass);" function has no effect to next call of it.
Could you kindly help in this case? Possibly it is a bug in android module.
Thank you in advance,
Sargis