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
c95b8117
Commit
c95b8117
authored
Jul 24, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
c723c452
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
OAuthApi.java
src/main/java/com/egolm/sso/api/OAuthApi.java
+19
-0
No files found.
src/main/java/com/egolm/sso/api/OAuthApi.java
View file @
c95b8117
...
@@ -7,11 +7,13 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -7,11 +7,13 @@ import javax.servlet.http.HttpServletResponse;
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.OAuthClientRequest
;
import
org.apache.oltu.oauth2.client.request.OAuthClientRequest
;
import
org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
;
import
org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
;
import
org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
;
import
org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
;
import
org.apache.oltu.oauth2.client.response.OAuthAuthzResponse
;
import
org.apache.oltu.oauth2.client.response.OAuthAuthzResponse
;
import
org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse
;
import
org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse
;
import
org.apache.oltu.oauth2.client.response.OAuthResourceResponse
;
import
org.apache.oltu.oauth2.common.OAuth
;
import
org.apache.oltu.oauth2.common.OAuth
;
import
org.apache.oltu.oauth2.common.exception.OAuthProblemException
;
import
org.apache.oltu.oauth2.common.exception.OAuthProblemException
;
import
org.apache.oltu.oauth2.common.exception.OAuthSystemException
;
import
org.apache.oltu.oauth2.common.exception.OAuthSystemException
;
...
@@ -54,4 +56,21 @@ public interface OAuthApi {
...
@@ -54,4 +56,21 @@ public interface OAuthApi {
return
token
;
return
token
;
}
}
default
String
getResource
(
String
method
,
String
url
,
OAuthToken
token
)
throws
OAuthSystemException
,
OAuthProblemException
{
OAuthClient
oAuthClient
=
new
OAuthClient
(
new
URLConnectionClient
());
String
accessToken
=
token
.
getAccessToken
();
OAuthClientRequest
request
=
new
OAuthBearerClientRequest
(
url
).
setAccessToken
(
accessToken
).
buildQueryMessage
();
OAuthResourceResponse
resourceResponse
=
oAuthClient
.
resource
(
request
,
method
,
OAuthResourceResponse
.
class
);
String
resBody
=
resourceResponse
.
getBody
();
return
resBody
;
}
default
String
doGetResource
(
String
url
,
OAuthToken
token
)
throws
OAuthSystemException
,
OAuthProblemException
{
return
this
.
getResource
(
"GET"
,
url
,
token
);
}
default
String
doPostResource
(
String
url
,
OAuthToken
token
)
throws
OAuthSystemException
,
OAuthProblemException
{
return
this
.
getResource
(
"POST"
,
url
,
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