Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
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
黄营
datax-cloud
Commits
97555703
Commit
97555703
authored
Nov 01, 2019
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
7fcdab4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
pom.xml
datax-common/datax-common-core/pom.xml
+5
-0
SecurityUtil.java
...ore/src/main/java/cn/datax/common/utils/SecurityUtil.java
+32
-0
No files found.
datax-common/datax-common-core/pom.xml
View file @
97555703
...
...
@@ -79,6 +79,10 @@
<groupId>
com.fasterxml.jackson.datatype
</groupId>
<artifactId>
jackson-datatype-jsr310
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-oauth2
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
datax-common/datax-common-core/src/main/java/cn/datax/common/utils/SecurityUtil.java
View file @
97555703
package
cn
.
datax
.
common
.
utils
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.oauth2.provider.OAuth2Authentication
;
public
class
SecurityUtil
{
/**
* 获取客户端
*
* @return clientId
*/
private
String
getClientId
()
{
Authentication
authentication
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
if
(
authentication
instanceof
OAuth2Authentication
)
{
OAuth2Authentication
auth2Authentication
=
(
OAuth2Authentication
)
authentication
;
return
auth2Authentication
.
getOAuth2Request
().
getClientId
();
}
return
null
;
}
/**
* 获取用户名称
*
* @return username
*/
private
String
getUsername
()
{
Authentication
authentication
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
if
(
authentication
instanceof
OAuth2Authentication
)
{
OAuth2Authentication
auth2Authentication
=
(
OAuth2Authentication
)
authentication
;
return
auth2Authentication
.
getName
();
}
return
null
;
}
}
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