Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
符节科技
Jap
提交
408a2942
Jap
项目概览
符节科技
/
Jap
大约 1 年 前同步成功
通知
91
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Jap
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
408a2942
编写于
1月 14, 2021
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
💩
Writing bad code that needs to be improved.
上级
560b754c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
30 deletion
+47
-30
jap-core/src/main/java/com/fujieid/jap/core/JapUserService.java
...re/src/main/java/com/fujieid/jap/core/JapUserService.java
+30
-19
jap-core/src/main/java/com/fujieid/jap/core/strategy/AbstractJapStrategy.java
...va/com/fujieid/jap/core/strategy/AbstractJapStrategy.java
+13
-0
jap-social/src/main/java/com/fujieid/jap/social/SocialStrategy.java
.../src/main/java/com/fujieid/jap/social/SocialStrategy.java
+3
-11
pom.xml
pom.xml
+1
-0
未找到文件。
jap-core/src/main/java/com/fujieid/jap/core/JapUserService.java
浏览文件 @
408a2942
package
com.fujieid.jap.core
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fujieid.jap.core.exception.JapUserException
;
/**
...
...
@@ -13,27 +14,34 @@ import com.fujieid.jap.core.exception.JapUserException;
public
interface
JapUserService
{
/**
* Get user info by userid.
* Get user info by username.
* <p>
* It is suitable for the {@code jap-simple} module
*
* @param user
Id User id
of the business system
* @param user
name username
of the business system
* @return JapUser
*/
default
JapUser
getBy
Id
(
String
userId
)
{
throw
new
JapUserException
(
"JapUserService#getBy
Id
(String) must be overridden by subclass"
);
default
JapUser
getBy
Name
(
String
username
)
{
throw
new
JapUserException
(
"JapUserService#getBy
Name
(String) must be overridden by subclass"
);
}
/**
* Get user info by username.
* Verify that the password entered by the user matches
* <p>
* It is suitable for the {@code jap-simple} module
*
* @param username username of the business system
* @return JapUser
* @param password The password in the HTML-based login form
* @param user User information that is queried by the user name in the HTML form
* @return {@code boolean} When true is returned, the password matches, otherwise the password is wrong
*/
default
JapUser
getByName
(
String
username
)
{
throw
new
JapUserException
(
"JapUserService#
getByName(String
) must be overridden by subclass"
);
default
boolean
validPassword
(
String
password
,
JapUser
user
)
{
throw
new
JapUserException
(
"JapUserService#
validPassword(String, JapUser
) must be overridden by subclass"
);
}
/**
* Get user information in the current system by social platform and social user id
* <p>
* It is suitable for the {@code jap-social} module
*
* @param platform social platform,refer to {@code me.zhyd.oauth.config.AuthSource#getName()}
* @param uid social user id
...
...
@@ -44,24 +52,27 @@ public interface JapUserService {
}
/**
* Verify that the password entered by the user matches
* Save the social login user information to the database and return JapUser
* <p>
* It is suitable for the {@code jap-social} module
*
* @param password The password in the HTML-based login form
* @param user User information that is queried by the user name in the HTML form
* @return {@code boolean} When true is returned, the password matches, otherwise the password is wrong
* @param userInfo User information obtained through justauth third-party login, type {@code me.zhyd.oauth.model.AuthUser}
* @return When saving successfully, return {@code JapUser}, otherwise return {@code null}
*/
default
boolean
validPassword
(
String
password
,
JapUser
user
)
{
throw
new
JapUserException
(
"JapUserService#
validPassword(String, Jap
User) must be overridden by subclass"
);
default
JapUser
createAndGetSocialUser
(
Object
userInfo
)
{
throw
new
JapUserException
(
"JapUserService#
createSocialUser(Auth
User) must be overridden by subclass"
);
}
/**
* Save the social login user information to the database and return JapUser
* Save the oauth login user information to the database and return JapUser
* <p>
* It is suitable for the {@code jap-oauth2} module
*
* @param
authUser User information obtained through justauth third-party login, type {@code me.zhyd.oauth.model.AuthUser}
* @param
userInfo The basic user information returned by the OAuth platform
* @return When saving successfully, return {@code JapUser}, otherwise return {@code null}
*/
default
JapUser
createAndGet
SocialUser
(
Object
authUser
)
{
throw
new
JapUserException
(
"JapUserService#create
SocialUser(String
) must be overridden by subclass"
);
default
JapUser
createAndGet
Oauth2User
(
JSONObject
userInfo
)
{
throw
new
JapUserException
(
"JapUserService#create
AndGetOauth2User(JSONObject
) must be overridden by subclass"
);
}
}
jap-core/src/main/java/com/fujieid/jap/core/strategy/AbstractJapStrategy.java
浏览文件 @
408a2942
...
...
@@ -65,6 +65,19 @@ public abstract class AbstractJapStrategy implements JapStrategy {
return
false
;
}
protected
void
loginSuccess
(
JapUser
japUser
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(
japConfig
.
isSession
())
{
HttpSession
session
=
request
.
getSession
();
japUser
.
setPassword
(
null
);
session
.
setAttribute
(
JapConst
.
SESSION_USER_KEY
,
japUser
);
}
try
{
response
.
sendRedirect
(
japConfig
.
getSuccessRedirect
());
}
catch
(
IOException
e
)
{
throw
new
JapException
(
"JAP failed to redirect via HttpServletResponse."
,
e
);
}
}
/**
* Verify that the AuthenticateConfig is of the specified class type
*
...
...
jap-social/src/main/java/com/fujieid/jap/social/SocialStrategy.java
浏览文件 @
408a2942
...
...
@@ -2,6 +2,7 @@ package com.fujieid.jap.social;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fujieid.jap.core.*
;
import
com.fujieid.jap.core.exception.JapException
;
...
...
@@ -124,16 +125,7 @@ public class SocialStrategy extends AbstractJapStrategy {
}
}
if
(
japConfig
.
isSession
())
{
HttpSession
session
=
request
.
getSession
();
japUser
.
setPassword
(
null
);
session
.
setAttribute
(
JapConst
.
SESSION_USER_KEY
,
japUser
);
}
try
{
response
.
sendRedirect
(
japConfig
.
getSuccessRedirect
());
}
catch
(
IOException
e
)
{
throw
new
JapException
(
"JAP failed to redirect via HttpServletResponse."
,
e
);
}
this
.
loginSuccess
(
japUser
,
request
,
response
);
}
/**
...
...
@@ -155,7 +147,7 @@ public class SocialStrategy extends AbstractJapStrategy {
}
else
if
(
source
.
equals
(
AuthDefaultSource
.
HUAWEI
.
name
()))
{
code
=
authCallback
.
getAuthorization_code
();
}
return
!
Str
ingUtils
.
isEmpty
(
code
);
return
!
Str
Util
.
isEmpty
(
code
);
}
/**
...
...
pom.xml
浏览文件 @
408a2942
...
...
@@ -54,6 +54,7 @@
<guava.version>
RELEASE
</guava.version>
<javax.servlet.version>
4.0.1
</javax.servlet.version>
<justauth.version>
1.15.9
</justauth.version>
<jose4j.version>
0.7.1
</jose4j.version>
</properties>
<dependencies>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录