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
0d6622ec
Commit
0d6622ec
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
c0b2cc21
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+8
-5
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
0d6622ec
...
@@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.oltu.oauth2.client.OAuthClient
;
import
org.apache.oltu.oauth2.client.OAuthClient
;
import
org.apache.oltu.oauth2.client.URLConnectionClient
;
import
org.apache.oltu.oauth2.client.URLConnectionClient
;
import
org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest
;
import
org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest
;
...
@@ -23,6 +25,8 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -23,6 +25,8 @@ import com.alibaba.fastjson.JSONObject;
public
interface
OAuthApi
{
public
interface
OAuthApi
{
Log
logger
=
LogFactory
.
getLog
(
OAuthApi
.
class
);
OAuthConfig
getOAuthConfig
();
OAuthConfig
getOAuthConfig
();
HttpServletRequest
getHttpServletRequest
();
HttpServletRequest
getHttpServletRequest
();
...
@@ -42,9 +46,8 @@ public interface OAuthApi {
...
@@ -42,9 +46,8 @@ public interface OAuthApi {
return
token
;
return
token
;
}
}
default
void
toLogin
()
{
default
String
getOAuthPath
()
{
try
{
try
{
HttpServletResponse
response
=
this
.
getHttpServletResponse
();
OAuthConfig
config
=
this
.
getOAuthConfig
();
OAuthConfig
config
=
this
.
getOAuthConfig
();
AuthenticationRequestBuilder
builder
=
OAuthClientRequest
.
authorizationLocation
(
config
.
getAuthorizeUrl
());
AuthenticationRequestBuilder
builder
=
OAuthClientRequest
.
authorizationLocation
(
config
.
getAuthorizeUrl
());
builder
.
setResponseType
(
OAuth
.
OAUTH_CODE
);
builder
.
setResponseType
(
OAuth
.
OAUTH_CODE
);
...
@@ -55,14 +58,14 @@ public interface OAuthApi {
...
@@ -55,14 +58,14 @@ public interface OAuthApi {
OAuthClientRequest
oauthResponse
=
builder
.
buildQueryMessage
();
OAuthClientRequest
oauthResponse
=
builder
.
buildQueryMessage
();
String
redirectUrl
=
oauthResponse
.
getLocationUri
();
String
redirectUrl
=
oauthResponse
.
getLocationUri
();
redirectUrl
=
redirectUrl
.
replaceAll
(
"\\+"
,
"%20"
);
redirectUrl
=
redirectUrl
.
replaceAll
(
"\\+"
,
"%20"
);
System
.
out
.
println
(
"redirect:"
+
redirectUrl
);
logger
.
debug
(
"redirect:"
+
redirectUrl
);
re
sponse
.
sendRedirect
(
redirectUrl
)
;
re
turn
redirectUrl
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
OAuthApiException
(
e
.
getMessage
(),
e
);
throw
new
OAuthApiException
(
e
.
getMessage
(),
e
);
}
}
}
}
default
void
do
Login
()
{
default
void
do
OAuthCallback
()
{
try
{
try
{
HttpServletRequest
request
=
this
.
getHttpServletRequest
();
HttpServletRequest
request
=
this
.
getHttpServletRequest
();
HttpSession
session
=
request
.
getSession
();
HttpSession
session
=
request
.
getSession
();
...
...
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