Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
V
volunteer_service
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
volunteer_service
Commits
983011c5
Commit
983011c5
authored
Apr 12, 2021
by
xc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shiro 登录报错
parent
a74e8884
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
UserModularRealmAuthenticator.java
...ergy/service/shir/util/UserModularRealmAuthenticator.java
+10
-11
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/shir/util/UserModularRealmAuthenticator.java
View file @
983011c5
package
cn
.
wisenergy
.
service
.
shir
.
util
;
import
cn.wisenergy.service.util.UserToken
;
import
com.itextpdf.text.log.Logger
;
import
com.itextpdf.text.log.LoggerFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.shiro.authc.AuthenticationException
;
import
org.apache.shiro.authc.AuthenticationInfo
;
import
org.apache.shiro.authc.AuthenticationToken
;
...
...
@@ -12,13 +11,13 @@ import org.apache.shiro.realm.Realm;
import
java.util.ArrayList
;
import
java.util.Collection
;
@Slf4j
public
class
UserModularRealmAuthenticator
extends
ModularRealmAuthenticator
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserModularRealmAuthenticator
.
class
);
@Override
protected
AuthenticationInfo
doAuthenticate
(
AuthenticationToken
authenticationToken
)
throws
AuthenticationException
{
log
ger
.
info
(
"UserModularRealmAuthenticator:method doAuthenticate() execute "
);
log
.
info
(
"UserModularRealmAuthenticator:method doAuthenticate() execute "
);
// 判断getRealms()是否返回为空
assertRealmsConfigured
();
// 强制转换回自定义的CustomizedToken
...
...
@@ -30,17 +29,17 @@ public class UserModularRealmAuthenticator extends ModularRealmAuthenticator {
// 登录类型对应的所有Realm
Collection
<
Realm
>
typeRealms
=
new
ArrayList
<>();
for
(
Realm
realm
:
realms
)
{
if
(
realm
.
getName
().
contains
(
loginType
));
typeRealms
.
add
(
realm
);
if
(
realm
.
getName
().
toLowerCase
().
contains
(
loginType
.
toLowerCase
())){
typeRealms
.
add
(
realm
);
}
}
// 判断是单Realm还是多Realm
if
(
typeRealms
.
size
()
==
1
){
log
ger
.
info
(
"doSingleRealmAuthentication() execute "
);
log
.
info
(
"doSingleRealmAuthentication() execute "
);
return
doSingleRealmAuthentication
(((
ArrayList
<
Realm
>)
typeRealms
).
get
(
0
),
userToken
);
}
else
{
logger
.
info
(
"doMultiRealmAuthentication() execute "
);
}
else
{
log
.
info
(
"doMultiRealmAuthentication() execute "
);
return
doMultiRealmAuthentication
(
typeRealms
,
userToken
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment