一、简介
数据库系统中需要保存用户登录账号、密码以供用户登录校验。如果在数据库中保存密码明文则有一定的安全性,通常对密码使用Hash运算保存,常见的Hash算法有MD5、SHA等。
二、INI 配置CredentialsMatcher
[main]
#自定义Reaml 实现认证、授权
realm=com.vincent.UserRealm
#定义凭证匹配器
credentialsMatcher=org.apache.shiro.authc.credential.HashedCredentialsMatcher
credentialsMatcher.hashAlgorithmName=md5
credentialsMatcher.hashIterations=10
realm.credentialsMatcher=$credentialsMatcher
#securityManager 对象是配置文件提供的SecurityManager 默认对象
securityManager.realm=$realm
三、CredentialsMatcher
1.AuthenticatingRealm 可配置CredentialsMatcher :