Menu

#21 Introduce interface SaltedPasswordEncryptor

v1.9.x
open
jasypt (16)
5
2013-03-06
2013-03-06
Anonymous
No

Please introduce a SalltedPasswordEncryptor interface that inherits from PasswordEncryptor and contains at least setSaltSizeBytes(). Right now I have to do the following, which is ugly like hell...
------------------------------------------------------------------------------
if(xmlLdapCredentialStore.isSetPasswordSaltLength()) {
if(!saltSupport.contains(algorithmName))
throw new RuntimeException("Algorithm doesn't support salt:"+algorithmName);
if(store.getPasswordEncryptor() instanceof RFC2307SMD5PasswordEncryptor) {
((RFC2307SMD5PasswordEncryptor)store.getPasswordEncryptor()).setSaltSizeBytes(xmlLdapCredentialStore.getPasswordSaltLength());
} else if(store.getPasswordEncryptor() instanceof RFC2307SSHAPasswordEncryptor) {
((RFC2307SSHAPasswordEncryptor)store.getPasswordEncryptor()).setSaltSizeBytes(xmlLdapCredentialStore.getPasswordSaltLength());
}
}
----------------------------------------------------------------------------------------------
With the interface it would look like this:
if(xmlLdapCredentialStore.isSetPasswordSaltLength()) {
if(!store.getPasswordEncryptor() instanceof SaltedPasswordEncryptor)
throw new RuntimeException("Algorithm doesn't support salt:"+algorithmName);
else
((SaltedPasswordEncryptor)store.getPasswordEncryptor()).setSaltSizeBytes(xmlLdapCredentialStore.getPasswordSaltLength());
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB