New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shiro-redis从2.4升级到3.0后报错 #56
Comments
正如错误信息提示的 principal需要实现AuthCachePrincipal
3.0.0新增接口
…On Tue, May 29, 2018 at 18:55 yunzhao824 ***@***.***> wrote:
错误信息如下
org.crazycake.shiro.exception.PrincipalInstanceException: 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")
at
org.crazycake.shiro.RedisCache.getRedisKeyFromPrincipalCollection(RedisCache.java:134)
~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.getStringRedisKey(RedisCache.java:123)
~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.getRedisCacheKey(RedisCache.java:112)
~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.get(RedisCache.java:61)
~[shiro-redis-3.0.0.jar:na]
at
org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:328)
~[shiro-core-1.3.2.jar:1.3.2]
at
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:462)
~[shiro-core-1.3.2.jar:1.3.2]
at
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:458)
~[shiro-core-1.3.2.jar:1.3.2]
at
org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
~[shiro-core-1.3.2.jar:1.3.2]
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#56>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACNPejFQdColkLLXY3y3G5I-ULyI_B6Tks5t3fwqgaJpZM4USeVA>
.
|
能具体点吗,我需要在哪个类上实现这个接口?
在 2018-05-30 10:01:31,"alex" <notifications@github.com> 写道:
正如错误信息提示的 principal需要实现AuthCachePrincipal
3.0.0新增接口
On Tue, May 29, 2018 at 18:55 yunzhao824 ***@***.***> wrote:
错误信息如下
org.crazycake.shiro.exception.PrincipalInstanceException: 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")
at
org.crazycake.shiro.RedisCache.getRedisKeyFromPrincipalCollection(RedisCache.java:134)
~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.getStringRedisKey(RedisCache.java:123)
~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.getRedisCacheKey(RedisCache.java:112)
~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.get(RedisCache.java:61)
~[shiro-redis-3.0.0.jar:na]
at
org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:328)
~[shiro-core-1.3.2.jar:1.3.2]
at
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:462)
~[shiro-core-1.3.2.jar:1.3.2]
at
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:458)
~[shiro-core-1.3.2.jar:1.3.2]
at
org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
~[shiro-core-1.3.2.jar:1.3.2]
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#56>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACNPejFQdColkLLXY3y3G5I-ULyI_B6Tks5t3fwqgaJpZM4USeVA>
.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
参考before use 段落
…On Tue, May 29, 2018 at 19:10 yunzhao824 ***@***.***> wrote:
能具体点吗,我需要在哪个类上实现这个接口?
在 2018-05-30 10:01:31,"alex" ***@***.***> 写道:
正如错误信息提示的 principal需要实现AuthCachePrincipal
3.0.0新增接口
On Tue, May 29, 2018 at 18:55 yunzhao824 ***@***.***> wrote:
> 错误信息如下
> org.crazycake.shiro.exception.PrincipalInstanceException: 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")
> at
>
org.crazycake.shiro.RedisCache.getRedisKeyFromPrincipalCollection(RedisCache.java:134)
> ~[shiro-redis-3.0.0.jar:na]
> at org.crazycake.shiro.RedisCache.getStringRedisKey(RedisCache.java:123)
> ~[shiro-redis-3.0.0.jar:na]
> at org.crazycake.shiro.RedisCache.getRedisCacheKey(RedisCache.java:112)
> ~[shiro-redis-3.0.0.jar:na]
> at org.crazycake.shiro.RedisCache.get(RedisCache.java:61)
> ~[shiro-redis-3.0.0.jar:na]
> at
>
org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:328)
> ~[shiro-core-1.3.2.jar:1.3.2]
> at
>
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:462)
> ~[shiro-core-1.3.2.jar:1.3.2]
> at
>
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:458)
> ~[shiro-core-1.3.2.jar:1.3.2]
> at
>
org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
> ~[shiro-core-1.3.2.jar:1.3.2]
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#56>, or mute the
thread
> <
https://github.com/notifications/unsubscribe-auth/ACNPejFQdColkLLXY3y3G5I-ULyI_B6Tks5t3fwqgaJpZM4USeVA
>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#56 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACNPegYAWKJGtmwCRMS8_6CmRdGBdEaRks5t3f-ggaJpZM4USeVA>
.
|
… On Tue, May 29, 2018 at 19:14 Xi Yang ***@***.***> wrote:
参考before use 段落
On Tue, May 29, 2018 at 19:10 yunzhao824 ***@***.***> wrote:
> 能具体点吗,我需要在哪个类上实现这个接口?
>
> 在 2018-05-30 10:01:31,"alex" ***@***.***> 写道:
> 正如错误信息提示的 principal需要实现AuthCachePrincipal
>
> 3.0.0新增接口
>
> On Tue, May 29, 2018 at 18:55 yunzhao824 ***@***.***>
> wrote:
>
> > 错误信息如下
> > org.crazycake.shiro.exception.PrincipalInstanceException: 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")
> > at
> >
> org.crazycake.shiro.RedisCache.getRedisKeyFromPrincipalCollection(RedisCache.java:134)
> > ~[shiro-redis-3.0.0.jar:na]
> > at org.crazycake.shiro.RedisCache.getStringRedisKey(RedisCache.java:123)
> > ~[shiro-redis-3.0.0.jar:na]
> > at org.crazycake.shiro.RedisCache.getRedisCacheKey(RedisCache.java:112)
> > ~[shiro-redis-3.0.0.jar:na]
> > at org.crazycake.shiro.RedisCache.get(RedisCache.java:61)
> > ~[shiro-redis-3.0.0.jar:na]
> > at
> >
> org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:328)
> > ~[shiro-core-1.3.2.jar:1.3.2]
> > at
> >
> org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:462)
> > ~[shiro-core-1.3.2.jar:1.3.2]
> > at
> >
> org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:458)
> > ~[shiro-core-1.3.2.jar:1.3.2]
> > at
> >
> org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
> > ~[shiro-core-1.3.2.jar:1.3.2]
> >
> > —
> > You are receiving this because you are subscribed to this thread.
> > Reply to this email directly, view it on GitHub
> > <#56>, or mute the
> thread
> > <
> https://github.com/notifications/unsubscribe-auth/ACNPejFQdColkLLXY3y3G5I-ULyI_B6Tks5t3fwqgaJpZM4USeVA
> >
> > .
> >
>
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub, or mute the thread.
>
> —
> You are receiving this because you commented.
>
>
> Reply to this email directly, view it on GitHub
> <#56 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ACNPegYAWKJGtmwCRMS8_6CmRdGBdEaRks5t3f-ggaJpZM4USeVA>
> .
>
|
按照你的文档改了,仍然报同样的错。
UserInfo.java
} |
可否断点调试 RedisCache 类 line 133: if (!(principalCollection.getPrimaryPrincipal() instanceof AuthCachePrincipal)) {
throw new PrincipalInstanceException();
} 观察此处 principalCollection.getPrimaryPrincipal() 取出的对象是否是UserInfo对象? |
Any updates? |
请升级至3.1.0,3.1.0取消了AuthCachePrincipal接口,转而使用反射来获取auth的redis对象id,请在 |
错误信息如下
org.crazycake.shiro.exception.PrincipalInstanceException: 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")
at org.crazycake.shiro.RedisCache.getRedisKeyFromPrincipalCollection(RedisCache.java:134) ~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.getStringRedisKey(RedisCache.java:123) ~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.getRedisCacheKey(RedisCache.java:112) ~[shiro-redis-3.0.0.jar:na]
at org.crazycake.shiro.RedisCache.get(RedisCache.java:61) ~[shiro-redis-3.0.0.jar:na]
at org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:328) ~[shiro-core-1.3.2.jar:1.3.2]
at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:462) ~[shiro-core-1.3.2.jar:1.3.2]
at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:458) ~[shiro-core-1.3.2.jar:1.3.2]
at org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223) ~[shiro-core-1.3.2.jar:1.3.2]
The text was updated successfully, but these errors were encountered: