shiro_02_身份认证加密( 四 )


我们怎么拿到数据库里的数据
我们查询的SQL语句也不一样了
之前的SQL语句查询
* fromwhere ='zs' and =
现在的SQL语句查询
* fromwhere ='zs'
假设:用户名: 密码:
传递到后台 就能接收到这两个变量
1.生成随机的盐
2.利用原始密码 + 生成的盐 = 得到加密后的密码
3. 在执行语句
二、shiro的认证
1.完成登录的方法 层的编写,接着就是biz层
2.完成自定义realm(重点)
3.与shiro的整合(注意)
4.测试
1.完成登录的方法 层的编写和biz层
通过逆向工程将五张表生成对应的model、
.xml主要生成好了之后记得要把它切换掉为其他的

我们这就生成好了如图所示:??????????????

shiro_02_身份认证加密

文章插图
在我们的.xml中 新增方法
selectfrom t_shiro_userwhere userName = #{userName}
.java 也加上 我们刚刚写的方法
package com.jwj.ssm.mapper;import com.jwj.ssm.model.User;import org.apache.ibatis.annotations.Param;import org.springframework.stereotype.Repository;//这个加也可以不加也可以,不加那边的实现方法就会报红,会感觉不舒服,加了就不会报红@Repositorypublic interface UserMapper {int deleteByPrimaryKey(Integer userid);int insert(User record);int insertSelective(User record);User selectByPrimaryKey(Integer userid);int updateByPrimaryKeySelective(User record);int updateByPrimaryKey(User record);User queryUserByUserName(@Param("userName") String userName);}
.java
package com.jwj.ssm.biz;import com.jwj.ssm.model.User;import org.apache.ibatis.annotations.Param;/*** @author 敢敢* @site www.javajwj.com* @company xxx公司* @create2022-08-25 19:10*/public interface UserBiz {int deleteByPrimaryKey(Integer userid);int insert(User record);int insertSelective(User record);User selectByPrimaryKey(Integer userid);int updateByPrimaryKeySelective(User record);int updateByPrimaryKey(User record);User queryUserByUserName(String userName);}
实现类 .java
package com.jwj.ssm.biz.impl;import com.jwj.ssm.biz.UserBiz;import com.jwj.ssm.mapper.UserMapper;import com.jwj.ssm.model.User;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;/*** @author 敢敢* @site www.javajwj.com* @company xxx公司* @create2022-08-25 19:11*/@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 int updateByPrimaryKeySelective(User record) {return userMapper.updateByPrimaryKeySelective(record);}@Overridepublic int updateByPrimaryKey(User record) {return userMapper.updateByPrimaryKey(record);}@Overridepublic User queryUserByUserName(String userName) {return userMapper.queryUserByUserName(userName);}}