Skip to content

Commit ffc06f1

Browse files
committed
UserRealm修改hashMatche写法
1 parent a638eec commit ffc06f1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/src/main/java/com/abc/shiro/UserRealm.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.abc.vo.AuthVo;
99
import com.baomidou.mybatisplus.mapper.EntityWrapper;
1010
import org.apache.shiro.authc.*;
11+
import org.apache.shiro.authc.credential.CredentialsMatcher;
1112
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
1213
import org.apache.shiro.authz.AuthorizationException;
1314
import org.apache.shiro.authz.AuthorizationInfo;
@@ -37,16 +38,16 @@ public class UserRealm extends AuthorizingRealm {
3738
@Autowired
3839
private SysPermService permService;
3940

40-
{
41+
@Override
42+
public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) {
4143
//设置用于匹配密码的CredentialsMatcher
4244
HashedCredentialsMatcher hashMatcher = new HashedCredentialsMatcher();
4345
hashMatcher.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME);
4446
hashMatcher.setStoredCredentialsHexEncoded(false);
4547
hashMatcher.setHashIterations(1024);
46-
this.setCredentialsMatcher(hashMatcher);
48+
super.setCredentialsMatcher(hashMatcher);
4749
}
4850

49-
5051
@Override
5152
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
5253
//null usernames are invalid

0 commit comments

Comments
 (0)