Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
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
station
YeeAmosFireAutoSysRoot
Commits
5e9e1b37
Commit
5e9e1b37
authored
Jul 14, 2022
by
zhangsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取isdp的token接口
parent
2f6cccbb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
0 deletions
+166
-0
pom.xml
YeeAmosFireAutoSysService/pom.xml
+19
-0
SsoTokenController.java
...join/amos/fas/business/controller/SsoTokenController.java
+60
-0
SSLClient.java
...in/java/com/yeejoin/amos/fas/business/util/SSLClient.java
+80
-0
application-dev.properties
...utoSysStart/src/main/resources/application-dev.properties
+7
-0
No files found.
YeeAmosFireAutoSysService/pom.xml
View file @
5e9e1b37
...
@@ -120,6 +120,24 @@
...
@@ -120,6 +120,24 @@
<version>2.2.1</version>
<version>2.2.1</version>
</dependency>-->
</dependency>-->
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.4.8
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<version>
6.11
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/SsoTokenController.java
0 → 100644
View file @
5e9e1b37
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
com.yeejoin.amos.fas.business.util.JSONUtil
;
import
com.yeejoin.amos.fas.business.util.SSLClient
;
import
com.yeejoin.amos.fas.core.util.CommonResponseUtil2
;
import
com.yeejoin.amos.fas.core.util.ResponseModel
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/api/sso"
)
@Api
(
tags
=
"获取isdp的tokenAPI"
)
public
class
SsoTokenController
{
@Value
(
"${sso.client.id}"
)
private
String
clientId
;
@Value
(
"${sso.client.secret}"
)
private
String
clientSecret
;
@Value
(
"${sso.login.client}"
)
private
String
loginClient
;
@Value
(
"${sso.client.url}"
)
private
String
clientUrl
;
@Value
(
"${sso.login.type}"
)
private
String
loginType
;
@Autowired
private
SSLClient
sslClient
;
/**
* 获取tokenAPI
*/
@ApiOperation
(
value
=
"获取token"
,
notes
=
"获取token"
)
@GetMapping
(
value
=
"/getSsoToken"
,
produces
=
"application/json;charset=UTF-8"
)
public
ResponseModel
getSsoToken
(
@RequestParam
(
value
=
"username"
)
String
username
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"client_id"
,
clientId
);
params
.
put
(
"client_secret"
,
clientSecret
);
params
.
put
(
"loginClient"
,
loginClient
);
params
.
put
(
"login_type"
,
loginType
);
params
.
put
(
"username"
,
username
);
String
message
=
JSONUtil
.
toJson
(
params
);
String
result
=
sslClient
.
doPost
(
clientUrl
,
message
,
"utf-8"
);
return
CommonResponseUtil2
.
success
(
result
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/util/SSLClient.java
0 → 100644
View file @
5e9e1b37
package
com
.
yeejoin
.
amos
.
fas
.
business
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.conn.ClientConnectionManager
;
import
org.apache.http.conn.scheme.Scheme
;
import
org.apache.http.conn.scheme.SchemeRegistry
;
import
org.apache.http.conn.ssl.SSLSocketFactory
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.stereotype.Component
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
@Slf4j
@Component
public
class
SSLClient
extends
DefaultHttpClient
{
public
SSLClient
()
throws
Exception
{
super
();
//传输协议需要根据自己的判断
SSLContext
ctx
=
SSLContext
.
getInstance
(
"TLS"
);
X509TrustManager
tm
=
new
X509TrustManager
()
{
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
};
ctx
.
init
(
null
,
new
TrustManager
[]{
tm
},
null
);
SSLSocketFactory
ssf
=
new
SSLSocketFactory
(
ctx
,
SSLSocketFactory
.
ALLOW_ALL_HOSTNAME_VERIFIER
);
ClientConnectionManager
ccm
=
this
.
getConnectionManager
();
SchemeRegistry
sr
=
ccm
.
getSchemeRegistry
();
sr
.
register
(
new
Scheme
(
"https"
,
443
,
ssf
));
}
public
String
doPost
(
String
url
,
String
map
,
String
charset
)
{
org
.
apache
.
http
.
client
.
HttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
try
{
httpClient
=
new
SSLClient
();
httpPost
=
new
HttpPost
(
url
);
//设置参数
httpPost
.
addHeader
(
"Accept"
,
"application/json"
);
httpPost
.
addHeader
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
StringEntity
stringEntity
=
new
StringEntity
(
map
);
stringEntity
.
setContentEncoding
(
"UTF-8"
);
stringEntity
.
setContentType
(
"application/json"
);
httpPost
.
setEntity
(
stringEntity
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
if
(
response
!=
null
)
{
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
return
result
;
}
}
YeeAmosFireAutoSysStart/src/main/resources/application-dev.properties
View file @
5e9e1b37
...
@@ -86,3 +86,10 @@ maparea.action.is-area=action1-2,action1-6
...
@@ -86,3 +86,10 @@ maparea.action.is-area=action1-2,action1-6
plan.dynamic.execut.topic
=
\u6362\u
6D41
\u
7AD9
\u
6D88
\u9632\u
4E13
\u9879\u9884\u6848
/autoExec
plan.dynamic.execut.topic
=
\u6362\u
6D41
\u
7AD9
\u
6D88
\u9632\u
4E13
\u9879\u9884\u6848
/autoExec
#服务端获取isdp的token用
sso.client.id
=
dce
sso.client.secret
=
6t5oDDKhEODXa++UNUxxLHSF5kVqECq6j+wahtCbv8c=
sso.login.type
=
server_auth
sso.login.client
=
dce
sso.client.url
=
https://198.87.103.88:30443/oauth2/oauth/rest_token
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