Shiro认证-身份认证加密( 二 )


测试
盐加密新增用户的操作流程:
form
用户:oyang
密码:
传到后台
1.生成随机的盐
2.利用原始密码 + 生成随机的盐 得到加密后的密码
3.
二、shiro认证 步骤
1)完成登录的方法 层的编写,接着biz层
2)完成自定义realm(重点)
3)与Shiro的整合(注意)
3.1)shiro在加载的时候,上下文还没有加载完毕

Shiro认证-身份认证加密

文章插图
所以@与@是不能使用
3.2)-shiro.xml文件中,需要依赖的业务
由于没有被配置,所以需要指定的bean的id
通过@("具体的名字")
4)测试
1.通过逆向工程将五张表生成对应的model、
.xml

2.中新增
selectfrom t_shiro_userwhere username = #{username}
Biz层
package com.oyang.ssm.biz;import com.oyang.ssm.model.User;import org.apache.ibatis.annotations.Param;public interface UserBiz {int deleteByPrimaryKey(Integer userid);int insert(User record);int insertSelective(User record);User selectByPrimaryKey(Integer userid);User queryUserByUserName(String username);int updateByPrimaryKeySelective(User record);int updateByPrimaryKey(User record);}
实现类
package com.oyang.ssm.impl;import com.oyang.ssm.biz.UserBiz;import com.oyang.ssm.mapper.UserMapper;import com.oyang.ssm.model.User;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;/*** @author oyang* @site https://blog.csdn.net* @qq 1828190940* @create2022-08-25 19:59*/@Service("userBiz")public class UserBizImpl implements UserBiz {@Autowiredprivate UserMapper userMapper;@Overridepublic int deleteByPrimaryKey(Integer userid) {return userMapper.deleteByPrimaryKey(userid);}@Overridepublic int insert(User record) {return userMapper.insert(record);}@Overridepublic int insertSelective(User record) {return userMapper.insertSelective(record);}@Overridepublic User selectByPrimaryKey(Integer userid) {return userMapper.selectByPrimaryKey(userid);}@Overridepublic User queryUserByUserName(String username) {return userMapper.queryUserByUserName(username);}@Overridepublic int updateByPrimaryKeySelective(User record) {return userMapper.updateByPrimaryKeySelective(record);}@Overridepublic int updateByPrimaryKey(User record) {return userMapper.updateByPrimaryKey(record);}}
整合 配置文件-shiro.xml