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
d4b275f0
Commit
d4b275f0
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
bf115406
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+39
-1
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
d4b275f0
...
...
@@ -24,22 +24,57 @@ import org.apache.oltu.oauth2.common.message.types.GrantType;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
/**
*
* SSO 权限校验接口, 权限获取和业务接口调用已经全部封装在接口默认方法中, 使用者只需实现此接口并实现接口中的抽象方法即可.
* 需要实现的抽象方法如下:
* 1. getOAuthConfig 获取OAuth系统配置信息
* 2.getHttpServletRequest 获取HttpServletRequest对象, 用户获取Session保存OAuthToken信息, 也用于获取和解析授权后OAuth回调中的Token信息
* 3.getHttpServletResponse 获取HttpServletResponse对象, 用于直接重定向到OAuth授权页面, 如果业务不需要直接重定向, 也可以通过 getAuthorizationUrl 方法获取OAuth的授权地址, 由用户主动点击跳转到 OAuth授权页面
*
* @author Quxl
*
*/
public
interface
OAuthApi
{
Log
logger
=
LogFactory
.
getLog
(
OAuthApi
.
class
);
/**
* 获取OAuth授权系统配置信息, 此方法需由用户自己实现
* @return OAuthConfig
*/
OAuthConfig
getOAuthConfig
();
/**
* 获取HttpServletRequest
* @return HttpServletRequest
*/
HttpServletRequest
getHttpServletRequest
();
/**
* 获取HttpServletResponse
* @return HttpServletResponse
*/
HttpServletResponse
getHttpServletResponse
();
/**
* 用户存储在HttpSession中的OAuthToken的键, 通过此变量可在Session中存储或获取已存在的OAuthToken信息
*/
final
String
OAUTH_TOKEN_SESSION
=
"OAUTH2_TOKEN_SESSION_KEY"
;
/**
* 判断OAuthToken是否已经存在, 或判断用户是否登陆
*
* @return true存在, false不存在
*/
default
boolean
isExistsOAuthToken
()
{
return
getOAuthToken
()
!=
null
;
}
/**
* 获取存储在Session中的OAuthToken信息
* @return 如果存在则返回, 否则返回null
*/
default
OAuthToken
getOAuthToken
()
{
try
{
HttpServletRequest
request
=
this
.
getHttpServletRequest
();
...
...
@@ -53,7 +88,10 @@ public interface OAuthApi {
}
}
default
void
doOAuthLogin
()
{
/**
*
*/
default
void
doRedirectOAuthLogin
()
{
try
{
String
redirectUrl
=
this
.
getAuthorizationUrl
();
HttpServletResponse
response
=
this
.
getHttpServletResponse
();
...
...
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