Giter VIP home page Giter VIP logo

Comments (8)

alexxiyang avatar alexxiyang commented on August 16, 2024

from shiro-redis.

yunzhao824 avatar yunzhao824 commented on August 16, 2024

from shiro-redis.

alexxiyang avatar alexxiyang commented on August 16, 2024

from shiro-redis.

alexxiyang avatar alexxiyang commented on August 16, 2024

from shiro-redis.

yunzhao824 avatar yunzhao824 commented on August 16, 2024

按照你的文档改了,仍然报同样的错。
代码如下:
//登录验证
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
String userCode = (String) authenticationToken.getPrincipal();
String password = new String((char[]) authenticationToken.getCredentials());

    // 查询用户信息
    SysUserDTO sysUser = sysApiService.getLoginUserByUserCode(userCode);

    if (null == sysUser) {
        throw new UnknownAccountException();
    }
    if (!sysUser.getPassword().equals(MD5Util.MD5(password + sysUser.getSalt()))) {
        throw new IncorrectCredentialsException();
    }
    if (sysUser.getUseable() == 0) {
        throw new LockedAccountException();
    }

    UserInfo userInfo = new UserInfo();
    BeanUtils.copyProperties(sysUser, userInfo);
    
    AuthenticationInfo authcInfo = new SimpleAuthenticationInfo(userInfo, password, getName());

UserInfo.java
public class UserInfo implements Serializable, AuthCachePrincipal {
private static final long serialVersionUID = -6477843453976551075L;

private String id;

private String userCode;

private String userName;

...

@Override
public String getAuthCacheKey() {
    return this.getUserCode();
}

}

from shiro-redis.

alexxiyang avatar alexxiyang commented on August 16, 2024

可否断点调试 RedisCache 类 line 133:

if (!(principalCollection.getPrimaryPrincipal() instanceof AuthCachePrincipal)) {
            throw new PrincipalInstanceException();
        }

观察此处 principalCollection.getPrimaryPrincipal() 取出的对象是否是UserInfo对象?

from shiro-redis.

alexxiyang avatar alexxiyang commented on August 16, 2024

Any updates?

from shiro-redis.

alexxiyang avatar alexxiyang commented on August 16, 2024

请升级至3.1.0,3.1.0取消了AuthCachePrincipal接口,转而使用反射来获取auth的redis对象id,请在 cacheManager.principalIdFieldName 中配置id字段,具体请参考README.md

from shiro-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.