Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cash-loan-flow-boss
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
cash-loan-flow-boss
Commits
adf802fd
Commit
adf802fd
authored
Oct 29, 2019
by
suntao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账号在别的地方登陆 退出当前登陆
parent
2814ff8d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
Assert.java
...a/cn/quantgroup/cashloanflowboss/core/asserts/Assert.java
+9
-11
ApplicationSecurityHandler.java
...owboss/core/configuration/ApplicationSecurityHandler.java
+8
-1
No files found.
src/main/java/cn/quantgroup/cashloanflowboss/core/asserts/Assert.java
View file @
adf802fd
...
@@ -3,12 +3,9 @@ package cn.quantgroup.cashloanflowboss.core.asserts;
...
@@ -3,12 +3,9 @@ package cn.quantgroup.cashloanflowboss.core.asserts;
import
cn.quantgroup.cashloanflowboss.api.login.model.Principal
;
import
cn.quantgroup.cashloanflowboss.api.login.model.Principal
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationDictionary
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationDictionary
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.Status
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.Status
;
import
cn.quantgroup.cashloanflowboss.core.exception.ApplicationException
;
import
cn.quantgroup.cashloanflowboss.core.exception.ApplicationException
;
import
org.apache.commons.lang3.ObjectUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -323,40 +320,41 @@ public class Assert {
...
@@ -323,40 +320,41 @@ public class Assert {
/**
/**
* @param concurrentHashMapLoginInfo 账号最后登陆时间
* @param concurrentHashMapLoginInfo 账号最后登陆时间
*
@param authenticationLoginCrowdOut
*
*/
*/
public
static
void
isLastLogin
(
Map
<
String
,
Object
>
concurrentHashMapLoginInfo
,
Status
authenticationLoginCrowdOut
)
{
public
static
Boolean
isLastLogin
(
Map
<
String
,
Object
>
concurrentHashMapLoginInfo
)
{
HttpSession
session
=
Application
.
getSession
();
HttpSession
session
=
Application
.
getSession
();
if
(
Objects
.
isNull
(
session
))
{
if
(
Objects
.
isNull
(
session
))
{
System
.
out
.
println
(
"session 为空"
);
System
.
out
.
println
(
"session 为空"
);
return
;
return
false
;
}
}
Principal
principal
=
Application
.
getPrincipal
();
Principal
principal
=
Application
.
getPrincipal
();
if
(
Objects
.
isNull
(
principal
))
{
if
(
Objects
.
isNull
(
principal
))
{
System
.
out
.
println
(
"principal 为空"
);
System
.
out
.
println
(
"principal 为空"
);
return
;
return
false
;
}
}
Object
userLastLoginTimeObject
=
concurrentHashMapLoginInfo
.
get
(
principal
.
getUserInfo
().
getUserId
()+
""
);
Object
userLastLoginTimeObject
=
concurrentHashMapLoginInfo
.
get
(
principal
.
getUserInfo
().
getUserId
()+
""
);
if
(
Objects
.
isNull
(
userLastLoginTimeObject
))
{
if
(
Objects
.
isNull
(
userLastLoginTimeObject
))
{
// 没有登陆时间 不处理
// 没有登陆时间 不处理
System
.
out
.
println
(
"userLastLoginTimeObject 为空"
);
System
.
out
.
println
(
"userLastLoginTimeObject 为空"
);
return
;
return
false
;
}
}
// 获取session最后登陆时间
// 获取session最后登陆时间
Object
creationTimeObject
=
session
.
getAttribute
(
ApplicationDictionary
.
USER_SESSION_LOGIN_TIME
);
Object
creationTimeObject
=
session
.
getAttribute
(
ApplicationDictionary
.
USER_SESSION_LOGIN_TIME
);
if
(
Objects
.
isNull
(
creationTimeObject
))
{
if
(
Objects
.
isNull
(
creationTimeObject
))
{
System
.
out
.
println
(
"lastAccessedTime 为空"
);
System
.
out
.
println
(
"lastAccessedTime 为空"
);
return
;
return
false
;
}
}
try
{
try
{
if
(
Long
.
valueOf
(
creationTimeObject
.
toString
())
<
Long
.
valueOf
(
userLastLoginTimeObject
.
toString
()))
{
if
(
Long
.
valueOf
(
creationTimeObject
.
toString
())
<
Long
.
valueOf
(
userLastLoginTimeObject
.
toString
()))
{
throw
new
ApplicationException
(
authenticationLoginCrowdOut
)
;
return
true
;
}
}
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
return
;
return
false
;
}
}
return
false
;
}
}
}
}
src/main/java/cn/quantgroup/cashloanflowboss/core/configuration/ApplicationSecurityHandler.java
View file @
adf802fd
...
@@ -9,6 +9,7 @@ import cn.quantgroup.cashloanflowboss.component.security.SecurityHandler;
...
@@ -9,6 +9,7 @@ import cn.quantgroup.cashloanflowboss.component.security.SecurityHandler;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.asserts.Assert
;
import
cn.quantgroup.cashloanflowboss.core.asserts.Assert
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus
;
import
cn.quantgroup.cashloanflowboss.core.exception.ApplicationException
;
import
org.aopalliance.intercept.MethodInvocation
;
import
org.aopalliance.intercept.MethodInvocation
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -36,7 +37,13 @@ public class ApplicationSecurityHandler implements SecurityHandler {
...
@@ -36,7 +37,13 @@ public class ApplicationSecurityHandler implements SecurityHandler {
Assert
.
isNull
(
principal
,
ApplicationStatus
.
AUTHENTICATION_LOGIN
);
Assert
.
isNull
(
principal
,
ApplicationStatus
.
AUTHENTICATION_LOGIN
);
// 是否 被挤下线
// 是否 被挤下线
Assert
.
isLastLogin
(
loginService
.
getConcurrentHashMapLoginInfo
(),
ApplicationStatus
.
AUTHENTICATION_LOGIN_CROWD_OUT
);
Boolean
isLogin
=
Assert
.
isLastLogin
(
loginService
.
getConcurrentHashMapLoginInfo
());
if
(
isLogin
!=
null
&&
isLogin
)
{
// 退出登陆
loginService
.
logout
();
// 返回 信息
throw
new
ApplicationException
(
ApplicationStatus
.
AUTHENTICATION_LOGIN_CROWD_OUT
);
}
// 如果是超级管理员跳过权限验证
// 如果是超级管理员跳过权限验证
...
...
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