Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sso
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
曲欣亮
sso
Commits
76b3b60a
Commit
76b3b60a
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
a3880ef8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
13 deletions
+4
-13
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+4
-13
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
76b3b60a
...
@@ -343,28 +343,19 @@ public interface OAuthApi {
...
@@ -343,28 +343,19 @@ public interface OAuthApi {
*/
*/
default
String
doPost
(
String
url
,
Map
<
String
,
String
>
headers
,
JSONObject
data
)
{
default
String
doPost
(
String
url
,
Map
<
String
,
String
>
headers
,
JSONObject
data
)
{
try
{
try
{
String
jsonData
=
data
==
null
?
""
:
data
.
toString
();
logger
.
debug
(
"oauth post url: "
+
url
);
logger
.
debug
(
"oauth post url: "
+
url
);
logger
.
debug
(
"oauth post headers: "
+
JSON
.
toJSONString
(
headers
));
logger
.
debug
(
"oauth post headers: "
+
JSON
.
toJSONString
(
headers
));
logger
.
debug
(
"oauth post data: "
+
data
.
toJSONString
()
);
logger
.
debug
(
"oauth post data: "
+
jsonData
);
OAuthToken
token
=
this
.
getOAuthToken
();
OAuthToken
token
=
this
.
getOAuthToken
();
if
(
System
.
currentTimeMillis
()
-
token
.
getCreateMillis
()
>
((
token
.
getExpiresIn
()-
5
)
*
1000
))
{
if
(
System
.
currentTimeMillis
()
-
token
.
getCreateMillis
()
>
((
token
.
getExpiresIn
()-
5
)
*
1000
))
{
this
.
refreshOAuthToken
();
this
.
refreshOAuthToken
();
token
=
this
.
getOAuthToken
();
token
=
this
.
getOAuthToken
();
}
}
String
accept
=
"application/json"
;
String
requestId
=
(
""
+
System
.
currentTimeMillis
());
String
countryCode
=
System
.
getProperty
(
"X-SE-IFW-CountryCode"
);
String
languageCode
=
System
.
getProperty
(
"X-SE-IFW-LanguageCode"
);
String
applicationName
=
System
.
getProperty
(
"X-SE-IFW-ApplicationName"
);
headers
.
put
(
"Accept"
,
accept
);
headers
.
put
(
"X-SE-IFW-RequestId"
,
requestId
);
headers
.
put
(
"X-SE-IFW-CountryCode"
,
countryCode
);
headers
.
put
(
"X-SE-IFW-LanguageCode"
,
languageCode
);
headers
.
put
(
"X-SE-IFW-ApplicationName"
,
applicationName
);
OAuthClient
oAuthClient
=
new
OAuthClient
(
new
URLConnectionClient
());
OAuthClient
oAuthClient
=
new
OAuthClient
(
new
URLConnectionClient
());
String
accessToken
=
token
.
getAccessToken
();
String
accessToken
=
token
.
getAccessToken
();
OAuthClientRequest
clientRequest
=
new
OAuthBearerClientRequest
(
url
).
setAccessToken
(
accessToken
).
buildQueryMessage
();
OAuthClientRequest
clientRequest
=
new
OAuthBearerClientRequest
(
url
).
setAccessToken
(
accessToken
).
buildQueryMessage
();
clientRequest
.
setBody
(
data
.
toString
()
);
clientRequest
.
setBody
(
jsonData
);
clientRequest
.
setHeaders
(
headers
);
clientRequest
.
setHeaders
(
headers
);
OAuthResourceResponse
resourceResponse
=
oAuthClient
.
resource
(
clientRequest
,
"POST"
,
OAuthResourceResponse
.
class
);
OAuthResourceResponse
resourceResponse
=
oAuthClient
.
resource
(
clientRequest
,
"POST"
,
OAuthResourceResponse
.
class
);
String
resBody
=
resourceResponse
.
getBody
();
String
resBody
=
resourceResponse
.
getBody
();
...
...
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