Вопрос

I'm allowing the user to specify its own KeyStore in my application. I'd like to validate that KeyStore password, given by the user, is valid.
Is there a way doing that?

Это было полезно?

Решение

try loading it

FileInputStream is = new FileInputStream(file);
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
/* getting the key*/
keystore.load(is, password.toCharArray());

Throws: IOException - if there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top