Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hg-smart
Overview
Overview
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
platform
hg-smart
Commits
2f2ed119
Commit
2f2ed119
authored
Aug 30, 2024
by
宋祥
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.德诚获取token接口
parent
425bd4e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
2 deletions
+47
-2
ServiceXSUserJwt.java
...a/com/baosight/xservices/xs/service/ServiceXSUserJwt.java
+47
-2
No files found.
src/main/java/com/baosight/xservices/xs/service/ServiceXSUserJwt.java
View file @
2f2ed119
package
com
.
baosight
.
xservices
.
xs
.
service
;
import
com.baosight.iplat4j.core.FrameworkInfo
;
import
com.baosight.iplat4j.core.ei.EiConstant
;
import
com.baosight.iplat4j.core.ei.EiInfo
;
import
com.baosight.iplat4j.core.log.Logger
;
import
com.baosight.iplat4j.core.log.LoggerFactory
;
...
...
@@ -11,11 +12,12 @@ import com.baosight.iplat4j.core.service.impl.ServiceBase;
import
com.baosight.iplat4j.core.util.StringUtils
;
import
com.baosight.iplat4j.core.web.threadlocal.UserSession
;
import
com.baosight.xservices.xs.jwt.JwtTokenValidator
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 重写
*
...
...
@@ -76,6 +78,49 @@ public class ServiceXSUserJwt extends ServiceBase {
return
outInfo
;
}
/**
* 德诚系统对接专用
*
* @param inInfo
* @return
*/
public
EiInfo
generateJwtDc
(
EiInfo
inInfo
)
{
String
username
=
inInfo
.
getString
(
"loginName"
);
String
password
=
inInfo
.
getString
(
"password"
);
String
audience
=
inInfo
.
getString
(
"audience"
);
EiInfo
outInfo
=
new
EiInfo
();
try
{
if
(!
StringUtils
.
isNotEmpty
(
audience
))
{
audience
=
FrameworkInfo
.
getProjectEname
().
toUpperCase
();
}
IUserManager
um
=
SecurityFactory
.
getUserManager
();
User
user
=
um
.
getUser
(
"DC"
+
username
);
if
(
user
==
null
)
{
throw
new
UsernameNotFoundException
(
"Can't find user!"
);
}
Map
tokenMap
=
new
HashMap
();
tokenMap
.
put
(
"sub"
,
user
.
getLoginName
());
tokenMap
.
put
(
"uid"
,
user
.
getUserId
());
Object
userCname
=
user
.
get
(
"userName"
);
if
(
userCname
!=
null
)
{
tokenMap
.
put
(
"ucn"
,
userCname
.
toString
());
}
if
(!
StringUtils
.
isNotEmpty
(
audience
))
{
audience
=
FrameworkInfo
.
getProjectEname
().
toUpperCase
();
}
String
token
=
this
.
jwtTokenValidator
.
generateToken
(
tokenMap
,
audience
);
outInfo
.
setStatus
(
EiConstant
.
STATUS_SUCCESS
);
outInfo
.
setMsg
(
"登录成功!"
);
outInfo
.
set
(
"token"
,
token
);
}
catch
(
Exception
var11
)
{
this
.
logger
.
error
(
var11
.
getMessage
(),
var11
);
outInfo
.
setStatus
(
EiConstant
.
STATUS_FAILURE
);
outInfo
.
setMsg
(
var11
.
getMessage
());
}
return
outInfo
;
}
public
EiInfo
validateTest
(
EiInfo
inInfo
)
{
new
HashMap
();
inInfo
.
set
(
"userSessionData"
,
new
HashMap
(
UserSession
.
getData
()));
...
...
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