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
c46280e9
Commit
c46280e9
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
76b3b60a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+7
-7
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
c46280e9
...
@@ -301,8 +301,11 @@ public interface OAuthApi {
...
@@ -301,8 +301,11 @@ public interface OAuthApi {
* <p>一旦出现token过期的情况,可调用此方法进行刷新</p>
* <p>一旦出现token过期的情况,可调用此方法进行刷新</p>
* <p>此方法的具体操作就是通过refresh_token去更新access_token, 通常情况下, refresh_token的有效期时长,会比access_token的有效期时长长很多</p>
* <p>此方法的具体操作就是通过refresh_token去更新access_token, 通常情况下, refresh_token的有效期时长,会比access_token的有效期时长长很多</p>
* <p>如果refresh_token也过期了,那么就需要通过 doRedirectOAuthLogin 进行重新授权了</p>
* <p>如果refresh_token也过期了,那么就需要通过 doRedirectOAuthLogin 进行重新授权了</p>
*
* @return 返回刷新后的 OAuthToken
*
*/
*/
default
void
refreshOAuthToken
()
{
default
OAuthToken
refreshOAuthToken
()
{
try
{
try
{
HttpServletRequest
request
=
this
.
getHttpServletRequest
();
HttpServletRequest
request
=
this
.
getHttpServletRequest
();
HttpSession
session
=
request
.
getSession
();
HttpSession
session
=
request
.
getSession
();
...
@@ -327,6 +330,7 @@ public interface OAuthApi {
...
@@ -327,6 +330,7 @@ public interface OAuthApi {
OAuthToken
newToken
=
new
OAuthToken
(
accessToken
,
refreshToken
,
idToken
,
tokenType
,
expiresIn
);
OAuthToken
newToken
=
new
OAuthToken
(
accessToken
,
refreshToken
,
idToken
,
tokenType
,
expiresIn
);
logger
.
debug
(
"oauth refresh result: "
+
JSON
.
toJSONString
(
newToken
));
logger
.
debug
(
"oauth refresh result: "
+
JSON
.
toJSONString
(
newToken
));
this
.
saveOAuthToken
(
newToken
);
this
.
saveOAuthToken
(
newToken
);
return
newToken
;
}
catch
(
OAuthApiException
e
)
{
}
catch
(
OAuthApiException
e
)
{
throw
e
;
throw
e
;
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
...
@@ -348,9 +352,8 @@ public interface OAuthApi {
...
@@ -348,9 +352,8 @@ public interface OAuthApi {
logger
.
debug
(
"oauth post headers: "
+
JSON
.
toJSONString
(
headers
));
logger
.
debug
(
"oauth post headers: "
+
JSON
.
toJSONString
(
headers
));
logger
.
debug
(
"oauth post data: "
+
jsonData
);
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
)
*
60
*
1000
))
{
this
.
refreshOAuthToken
();
token
=
this
.
refreshOAuthToken
();
token
=
this
.
getOAuthToken
();
}
}
OAuthClient
oAuthClient
=
new
OAuthClient
(
new
URLConnectionClient
());
OAuthClient
oAuthClient
=
new
OAuthClient
(
new
URLConnectionClient
());
String
accessToken
=
token
.
getAccessToken
();
String
accessToken
=
token
.
getAccessToken
();
...
@@ -368,7 +371,4 @@ public interface OAuthApi {
...
@@ -368,7 +371,4 @@ public interface OAuthApi {
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
3599
/
60
);
}
}
}
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