zadada 2015-09-10 00:58
浏览 7139

Shiro的SimpleAuthenticationInfo的principal赋值问题

doGetAuthenticationInfo 在 return 时 SimpleAuthenticationInfo 的赋值

 return new SimpleAuthenticationInfo(user.getStr("username"), user.getStr("password"), getName());

验证可以通过,当改为

 return new SimpleAuthenticationInfo(new ShiroUser(user), user.getStr("password"), getName());

抛出异常

Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).

不知是哪里错了。

ShiroUser.java

 package com.xxx.shiro;

import java.io.Serializable;

import com.xxx.model.HrmResource;

public class ShiroUser implements Serializable {

    private static final long serialVersionUID = -9204685886813793596L;

    private Long id;
    private String username;
    private String lastname;
    private Integer status;

    public ShiroUser() {
    }

    public ShiroUser(HrmResource hrm) {
        this.setId(hrm.getLong("id"));
        this.setLastname(hrm.getStr("lastname"));
        this.setUsername(hrm.getStr("loginid"));
        this.setStatus(hrm.getInt("status"));
    }

    public String toString() {
        return getUsername();
    }

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ShiroUser other = (ShiroUser) obj;
        if (this.username == null) {
            if (other.username != null)
                return false;
        } else if (!this.username.equals(other.username))
            return false;
        return true;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
}
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥100 求数学坐标画圆以及直线的算法
    • ¥35 平滑拟合曲线该如何生成
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 自己瞎改改,结果现在又运行不了了
    • ¥15 链式存储应该如何解决