springboot中集成shiro只需要两个类:一个是shiroConfig类,一个是CustonRealm类。
ShiroConfig类:
顾名思义就是对shiro的一些配置,相对于之前的xml配置。包括:过滤的文件和权限,密码加密的算法,其用注解等相关功能。
CustomRealm类:
自定义的CustomRealm继承AuthorizingRealm。并且重写父类中的doGetAuthorizationInfo(权限相关)、doGetAuthenticationInfo(身份认证)这两个方法。
在重写中CustomRealm类的验证方法如果想要实现MD5盐值加密的话就需要返回4个参数,若不使用MD5返回三个即可。
MD5加密
return new SimpleAuthenticationInfo(users,users.getPassword(),
ByteSource.Util.bytes(users.getUsername()), getName());
无MD5
return new SimpleAuthenticationInfo(userName, password,getName());