shiro注解@RequiresRoles,@RequiresPermissions无效

报错如下:

Principal must implement org.crazycake.shiro.AuthCachePrincipal. shiro-redis will get the key for store authorization object in Redis from org.crazycake.shiro.AuthCachePrincipal So please use AuthCachePrincipal to tell shiro-redis how to get the cache key For example: There is a class UserInfo which implements org.crazycake.shiro.AuthCachePrincipal. You can use this class to initial SimpleAuthenticationInfo like this: UserInfo userInfo = new userInfo(); new SimpleAuthenticationInfo(userInfo, "123456", "realm1")

如报错提示修改 CurrentUserDTO 实现 AuthCachePrincipal 接口

import lombok.Data;
import lombok.ToString;
import org.crazycake.shiro.AuthCachePrincipal;

import java.io.Serializable;
import java.util.Set;

/**
 * 自定义Authentication对象
 * @author zk
 * @since 2018/5/16 15:33
 */
@Data
@ToString
public class CurrentUserDTO implements AuthCachePrincipal,Serializable {

	private static final long serialVersionUID = -7844689149345394512L;
	/**
	 * 真实姓名
	 */
	private String realUserName;
	/**
	 * 业务员手机
	 */
	private String userPhone;

	private Set roleIdSet;
	private Set roleNameSet;
	private Set operationIdSet;
	private Set operationUrlSet;
	private Set permissionsSet;

	@Override
	public String getAuthCacheKey() {
		return null;
	}
}



你可能感兴趣的:(框架学习)