05自定义Realm实现认证
- Shiro默认使用自带的IniRealm,IniRealm从ini配置文件中读取用户的信息,大部分情况下需要从系统的数据库中读取用户信息,所以需要自定义Realm
1.Realm接口

- 最基础的是Realm接口,CachingRealm负责缓存处理,AuthenticatingRealm负责认证,AuthorizingRealm负责授权,通常已定义的realm继承AuthorizingRealm
2.实现步骤
1.创建项目
2.创建User类
package com.domain;
import java.util.Date;
public class User {
private Integer id;
private String username;
private String pwd;
private Date createtime;
public User(){
}
public User(Integer id, String username, String pwd, Date createtime) {
this.id = id;
this.username = username;
this.pwd = pwd;
this.createtime = createtime;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public Date getCreatetime() {
return createtime