shiro: [Question] Can shiro 2.0 + use shiro 1 's hash Algorithm, such as "SHA-256" ?
Search before asking
- I had searched in the issues and found no similar issues.
Question
I use shiro 2.0.0-alpha-2 with shiro 1 's hash Algorithm “SHA-256” , exception as below:
public static String str2SHA256(String str)
{
DefaultPasswordService passwordService = new DefaultPasswordService();
passwordService.setHashService(new DefaultHashService()
{
{
setDefaultAlgorithmName("SHA-256");
}
});
String encryptedValue = passwordService.encryptPassword(str);
return encryptedValue;
}
exception:
Exception in thread "main" java.lang.UnsupportedOperationException: Shiro2CryptFormat can only format classes extending AbstractCryptHash.
at org.apache.shiro.crypto.hash.format.Shiro2CryptFormat.format(Shiro2CryptFormat.java:107)
at org.apache.shiro.authc.credential.DefaultPasswordService.encryptPassword(DefaultPasswordService.java:83)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (12 by maintainers)
Commits related to this issue
- Merge pull request #1263 from lprimak/add-default-hash-service-method [#1022] DefaultPasswordService takes HashService default hash… — committed to apache/shiro by lprimak 3 years ago
- Merge pull request #1265 from lprimak/shiro-parse-unsalted [#1022] bugfix(crypto): Shiro 1 hash parser now supports unsalted passwords — committed to apache/shiro by lprimak 3 years ago
- Improved: Upgrade Apache Shiro from 1.13.0 to 2.0.0 (OFBIZ-12961) Summary, TL;DR: the changes are minimal and things work like before. OFBiz uses now Shiro 2.0.0 for AES ciphering instead of Shiro 1.... — committed to apache/ofbiz-framework by JacquesLeRoux 3 years ago
Depending on the size of (and how much friction it would cause) your user base. You could reset passwords.
A more complex option would be to check if a user’s password has was stored in an older format, if so validate the hash. If it matches re-hash the password with a different algorithm and store it.
Shiro doesn’t provide password write APIs so you would need to write custom code for this.