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
21589cee
Commit
21589cee
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
422e9925
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+8
-9
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
21589cee
...
...
@@ -77,7 +77,7 @@ public interface OAuthApi {
OAuthClientRequest
oauthResponse
=
builder
.
buildQueryMessage
();
String
redirectUrl
=
oauthResponse
.
getLocationUri
();
redirectUrl
=
redirectUrl
.
replaceAll
(
"\\+"
,
"%20"
);
logger
.
debug
(
"
redirect
:"
+
redirectUrl
);
logger
.
debug
(
"
oauth authorization url
:"
+
redirectUrl
);
return
redirectUrl
;
}
catch
(
OAuthApiException
e
)
{
throw
e
;
...
...
@@ -89,7 +89,7 @@ public interface OAuthApi {
default
void
callback
()
{
try
{
HttpServletRequest
request
=
this
.
getHttpServletRequest
();
logger
.
debug
(
"oauth callback: "
+
request
.
getRequestURI
()
+
" "
+
JSON
.
toJSONString
(
request
.
getParameterMap
()));
logger
.
debug
(
"oauth callback
request
: "
+
request
.
getRequestURI
()
+
" "
+
JSON
.
toJSONString
(
request
.
getParameterMap
()));
OAuthConfig
config
=
this
.
getOAuthConfig
();
OAuthAuthzResponse
oauthAuthzResponse
=
OAuthAuthzResponse
.
oauthCodeAuthzResponse
(
request
);
String
code
=
oauthAuthzResponse
.
getCode
();
...
...
@@ -108,6 +108,7 @@ public interface OAuthApi {
String
idToken
=
oAuthResponse
.
getParam
(
"id_token"
);
String
tokenType
=
oAuthResponse
.
getTokenType
();
OAuthToken
token
=
new
OAuthToken
(
accessToken
,
refreshToken
,
idToken
,
tokenType
,
expiresIn
);
logger
.
debug
(
"oauth callback result: "
+
JSON
.
toJSONString
(
token
));
saveOAuthToken
(
token
);
}
catch
(
OAuthApiException
e
)
{
throw
e
;
...
...
@@ -147,11 +148,9 @@ public interface OAuthApi {
builder
.
setClientId
(
config
.
getClientId
());
builder
.
setClientSecret
(
config
.
getClientSecret
());
OAuthClientRequest
oauthClientRequest
=
builder
.
buildQueryMessage
();
logger
.
debug
(
"oauth refresh request: "
+
oauthClientRequest
.
getLocationUri
());
logger
.
debug
(
"oauth refresh headers: "
+
JSON
.
toJSONString
(
oauthClientRequest
.
getHeaders
()));
logger
.
debug
(
"oauth refresh body: "
+
JSON
.
toJSONString
(
oauthClientRequest
.
getBody
()));
OAuthClient
oAuthClient
=
new
OAuthClient
(
new
URLConnectionClient
());
OAuthJSONAccessTokenResponse
oAuthResponse
=
oAuthClient
.
accessToken
(
oauthClientRequest
,
OAuth
.
HttpMethod
.
POST
);
String
accessToken
=
oAuthResponse
.
getAccessToken
();
...
...
@@ -160,7 +159,7 @@ public interface OAuthApi {
String
idToken
=
oAuthResponse
.
getParam
(
"id_token"
);
String
tokenType
=
oAuthResponse
.
getTokenType
();
OAuthToken
newToken
=
new
OAuthToken
(
accessToken
,
refreshToken
,
idToken
,
tokenType
,
expiresIn
);
logger
.
debug
(
"oauth refresh:"
+
JSON
.
toJSONString
(
newToken
));
logger
.
debug
(
"oauth refresh
result
:"
+
JSON
.
toJSONString
(
newToken
));
session
.
setAttribute
(
OAUTH_TOKEN_SESSION
,
newToken
);
}
catch
(
OAuthApiException
e
)
{
throw
e
;
...
...
@@ -171,9 +170,9 @@ public interface OAuthApi {
default
String
doPost
(
String
url
,
Map
<
String
,
String
>
headers
,
JSONObject
data
)
{
try
{
logger
.
debug
(
"oauth post: "
+
url
);
logger
.
debug
(
"oauth headers: "
+
JSON
.
toJSONString
(
headers
));
logger
.
debug
(
"oauth data: "
+
data
.
toJSONString
());
logger
.
debug
(
"oauth post
url
: "
+
url
);
logger
.
debug
(
"oauth
post
headers: "
+
JSON
.
toJSONString
(
headers
));
logger
.
debug
(
"oauth
post
data: "
+
data
.
toJSONString
());
String
accept
=
"application/json"
;
String
requestId
=
(
""
+
System
.
currentTimeMillis
());
String
countryCode
=
System
.
getProperty
(
"X-SE-IFW-CountryCode"
);
...
...
@@ -194,7 +193,7 @@ public interface OAuthApi {
clientRequest
.
setHeaders
(
headers
);
OAuthResourceResponse
resourceResponse
=
oAuthClient
.
resource
(
clientRequest
,
"POST"
,
OAuthResourceResponse
.
class
);
String
resBody
=
resourceResponse
.
getBody
();
logger
.
debug
(
"oauth result: "
+
resBody
);
logger
.
debug
(
"oauth
post
result: "
+
resBody
);
return
resBody
;
}
catch
(
OAuthApiException
e
)
{
throw
e
;
...
...
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