Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
符节科技
Jap
提交
1034a095
Jap
项目概览
符节科技
/
Jap
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
1034a095
编写于
2月 20, 2021
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🎨
Improving code
上级
98755478
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
151 addition
and
241 deletion
+151
-241
.gitignore
.gitignore
+0
-3
docs/bin/repVersion.sh
docs/bin/repVersion.sh
+1
-1
docs/bin/version.txt
docs/bin/version.txt
+1
-1
jap-core/pom.xml
jap-core/pom.xml
+1
-1
jap-core/src/main/java/com/fujieid/jap/core/JapConfig.java
jap-core/src/main/java/com/fujieid/jap/core/JapConfig.java
+0
-28
jap-core/src/main/java/com/fujieid/jap/core/context/JapAuthentication.java
.../java/com/fujieid/jap/core/context/JapAuthentication.java
+32
-32
jap-core/src/main/java/com/fujieid/jap/core/context/JapContext.java
...rc/main/java/com/fujieid/jap/core/context/JapContext.java
+80
-0
jap-core/src/main/java/com/fujieid/jap/core/strategy/AbstractJapStrategy.java
...va/com/fujieid/jap/core/strategy/AbstractJapStrategy.java
+12
-21
jap-core/src/test/java/com/fujieid/jap/core/cache/JapCacheContextHolderTest.java
...com/fujieid/jap/core/cache/JapCacheContextHolderTest.java
+0
-99
jap-mfa/pom.xml
jap-mfa/pom.xml
+2
-2
jap-oauth2/pom.xml
jap-oauth2/pom.xml
+1
-1
jap-oauth2/src/main/java/com/fujieid/jap/oauth2/Oauth2Strategy.java
.../src/main/java/com/fujieid/jap/oauth2/Oauth2Strategy.java
+2
-3
jap-oauth2/src/main/java/com/fujieid/jap/oauth2/Oauth2Util.java
...uth2/src/main/java/com/fujieid/jap/oauth2/Oauth2Util.java
+2
-2
jap-oauth2/src/main/java/com/fujieid/jap/oauth2/pkce/PkceHelper.java
...src/main/java/com/fujieid/jap/oauth2/pkce/PkceHelper.java
+3
-3
jap-oauth2/src/test/java/com/fujieid/jap/oauth2/Oauth2UtilTest.java
.../src/test/java/com/fujieid/jap/oauth2/Oauth2UtilTest.java
+4
-3
jap-oauth2/src/test/java/com/fujieid/jap/oauth2/pkce/PkceHelperTest.java
...test/java/com/fujieid/jap/oauth2/pkce/PkceHelperTest.java
+4
-3
jap-oidc/pom.xml
jap-oidc/pom.xml
+1
-1
jap-simple/pom.xml
jap-simple/pom.xml
+1
-1
jap-social/pom.xml
jap-social/pom.xml
+1
-1
jap-sso/pom.xml
jap-sso/pom.xml
+1
-1
jap-sso/src/main/java/com/fujieid/jap/sso/JapSsoHelper.java
jap-sso/src/main/java/com/fujieid/jap/sso/JapSsoHelper.java
+0
-2
jap-sso/src/main/java/com/fujieid/jap/sso/config/JapSsoConfig.java
...rc/main/java/com/fujieid/jap/sso/config/JapSsoConfig.java
+0
-30
jap.sh
jap.sh
+1
-1
pom.xml
pom.xml
+1
-1
未找到文件。
.gitignore
浏览文件 @
1034a095
...
...
@@ -48,10 +48,7 @@ build/
.vscode/
### other ###
/jap-core/src/main/java/com/fujieid/jap/core/context/
/jap-simple/src/main/java/com/fujieid/jap/simple/SimpleAuthentication.java
/jap-simple/src/main/java/com/fujieid/jap/simple/SimpleCallback.java
/jap-core/src/main/java/com/fujieid/jap/core/Credential.java
/docs/bin/deploy.sh
/jap-core/pom.xml.versionsBackup
/jap-oauth2/pom.xml.versionsBackup
...
...
docs/bin/repVersion.sh
浏览文件 @
1034a095
...
...
@@ -24,7 +24,7 @@ fi
# 替换README.md等文件中的版本
sed
-i
"s/
${
old_version
}
/
${
new_version
}
/g"
$pwd
/README.md
sed
-i
"s/
${
old_version
}
/
${
new_version
}
/g"
$pwd
/README.en
-US
.md
sed
-i
"s/
${
old_version
}
/
${
new_version
}
/g"
$pwd
/README.en.md
# 保留新版本号
echo
"
$new_version
"
>
$pwd
/docs/bin/version.txt
docs/bin/version.txt
浏览文件 @
1034a095
1.0.
0
1.0.
1
jap-core/pom.xml
浏览文件 @
1034a095
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
com.fujieid
</groupId>
<artifactId>
jap
</artifactId>
<version>
1.0.
0
</version>
<version>
1.0.
1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
jap-core/src/main/java/com/fujieid/jap/core/JapConfig.java
浏览文件 @
1034a095
...
...
@@ -51,11 +51,6 @@ public class JapConfig {
*/
private
String
successRedirect
=
"/"
;
/**
* Prompt message after successful login
*/
private
String
successMessage
;
/**
* After logout, redirect to {@code logoutRedirect}. Default is `/`
*/
...
...
@@ -66,11 +61,6 @@ public class JapConfig {
*/
private
String
failureRedirect
=
"/error"
;
/**
* Prompt message after login failed
*/
private
String
failureMessage
;
public
String
getLoginUrl
()
{
return
loginUrl
;
}
...
...
@@ -116,15 +106,6 @@ public class JapConfig {
return
this
;
}
public
String
getSuccessMessage
()
{
return
successMessage
;
}
public
JapConfig
setSuccessMessage
(
String
successMessage
)
{
this
.
successMessage
=
successMessage
;
return
this
;
}
public
String
getFailureRedirect
()
{
return
failureRedirect
;
}
...
...
@@ -134,15 +115,6 @@ public class JapConfig {
return
this
;
}
public
String
getFailureMessage
()
{
return
failureMessage
;
}
public
JapConfig
setFailureMessage
(
String
failureMessage
)
{
this
.
failureMessage
=
failureMessage
;
return
this
;
}
public
String
getLogoutRedirect
()
{
return
logoutRedirect
;
}
...
...
jap-core/src/main/java/com/fujieid/jap/core/
store/JapUserStoreContextHolder
.java
→
jap-core/src/main/java/com/fujieid/jap/core/
context/JapAuthentication
.java
浏览文件 @
1034a095
...
...
@@ -13,66 +13,60 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.fujieid.jap.core.
store
;
package
com.fujieid.jap.core.
context
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
cn.hutool.log.Log
;
import
cn.hutool.log.LogFactory
;
import
com.fujieid.jap.core.JapConfig
;
import
com.fujieid.jap.core.JapUser
;
import
com.fujieid.jap.core.exception.JapException
;
import
com.fujieid.jap.core.JapUtil
;
import
com.fujieid.jap.core.store.JapUserStore
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.Serializable
;
import
java.util.Map
;
/**
* Store and obtain the {@code JapUserStore}, and provide simple operation for users.
* <p>
* Currently, Mixed scenarios of single sign on and non single sign on are not supported for the time being, such as:
* The system uses a variety of login methods, such as {@code jap-simple} and {@code jap-oauth2},
* but it requires that {@code jap-simple} support Single sign on of {@code jap-oauth2} does not support Single sign on.
* Manage the context of jap, after successful login,
* you can obtain the logged-in user information through jap authentication or execute logout events
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0.0
* @since 1.0.0
*/
public
class
JapUserStoreContextHolder
{
private
static
final
Log
log
=
LogFactory
.
get
();
private
static
JapUserStore
currentJapUserStore
;
public
class
JapAuthentication
implements
Serializable
{
private
static
JapContext
context
;
public
static
void
enable
(
JapUserStore
japUserStore
)
{
if
(
null
==
japUserStore
)
{
throw
new
JapException
(
"JapUserStore cannot be null."
);
}
currentJapUserStore
=
japUserStore
;
private
JapAuthentication
()
{
}
public
static
JapUserStore
getUserStore
()
{
if
(
null
==
currentJapUserStore
)
{
log
.
warn
(
"JapUserStore has not been initialized yet."
);
return
null
;
}
return
currentJapUserStore
;
public
static
JapContext
getContext
()
{
return
context
;
}
public
static
JapUser
getStoreUser
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
JapUserStore
japUserStore
=
getUserStore
();
return
null
==
japUserStore
?
null
:
japUserStore
.
get
(
request
,
response
);
public
static
void
setContext
(
JapContext
japContext
)
{
context
=
japContext
;
}
public
static
void
removeStoreUser
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
JapUserStore
japUserStore
=
getUserStore
();
public
static
JapUser
getUser
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(
null
==
context
)
{
return
null
;
}
JapUserStore
japUserStore
=
context
.
getUserStore
();
if
(
null
==
japUserStore
)
{
return
;
return
null
;
}
japUserStore
.
remove
(
request
,
response
);
return
japUserStore
.
get
(
request
,
response
);
}
public
static
void
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
removeStoreUser
(
request
,
response
);
JapUserStore
japUserStore
=
context
.
getUserStore
();
if
(
null
==
japUserStore
)
{
return
;
}
japUserStore
.
remove
(
request
,
response
);
// Clear all cookie information
Map
<
String
,
Cookie
>
cookieMap
=
ServletUtil
.
readCookieMap
(
request
);
...
...
@@ -83,5 +77,11 @@ public class JapUserStoreContextHolder {
cookie
.
setMaxAge
(
0
);
response
.
addCookie
(
cookie
);
});
JapConfig
config
=
context
.
getConfig
();
if
(
null
!=
config
)
{
JapUtil
.
redirect
(
config
.
getLogoutRedirect
(),
response
);
}
}
}
jap-core/src/main/java/com/fujieid/jap/core/c
ache/JapCacheContextHolder
.java
→
jap-core/src/main/java/com/fujieid/jap/core/c
ontext/JapContext
.java
浏览文件 @
1034a095
...
...
@@ -13,29 +13,68 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.fujieid.jap.core.cache
;
package
com.fujieid.jap.core.context
;
import
com.fujieid.jap.core.JapConfig
;
import
com.fujieid.jap.core.cache.JapCache
;
import
com.fujieid.jap.core.store.JapUserStore
;
/**
* Stores {@link com.fujieid.jap.core.cache.JapCache} for global calls
* The context of jap.
* <p>
* Persist jap user store, jap cache and jap config in memory to facilitate the management of jap user data.
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0.0
* @since 1.0.0
*/
public
class
JapCacheContextHolder
{
public
class
JapContext
{
/**
* user store
*/
private
JapUserStore
userStore
;
/**
* jap cache
*/
private
JapCache
cache
;
/**
* Jap configuration.
*/
private
JapConfig
config
;
public
JapContext
()
{
}
private
static
JapCache
currentJapCache
;
public
JapContext
(
JapUserStore
userStore
,
JapCache
cache
,
JapConfig
config
)
{
this
.
userStore
=
userStore
;
this
.
cache
=
cache
;
this
.
config
=
config
;
}
public
JapUserStore
getUserStore
()
{
return
userStore
;
}
public
JapContext
setUserStore
(
JapUserStore
userStore
)
{
this
.
userStore
=
userStore
;
return
this
;
}
public
JapCache
getCache
()
{
return
cache
;
}
public
JapContext
setCache
(
JapCache
cache
)
{
this
.
cache
=
cache
;
return
this
;
}
public
static
void
enable
(
JapCache
japCache
)
{
currentJapCache
=
null
==
japCache
?
new
JapLocalCache
()
:
japCache
;
public
JapConfig
getConfig
(
)
{
return
config
;
}
public
static
JapCache
getCache
()
{
if
(
null
==
currentJapCache
)
{
JapCache
japCache
=
new
JapLocalCache
();
enable
(
japCache
);
return
japCache
;
}
return
currentJapCache
;
public
JapContext
setConfig
(
JapConfig
config
)
{
this
.
config
=
config
;
return
this
;
}
}
jap-core/src/main/java/com/fujieid/jap/core/strategy/AbstractJapStrategy.java
浏览文件 @
1034a095
...
...
@@ -19,11 +19,11 @@ import cn.hutool.core.util.ClassUtil;
import
cn.hutool.core.util.ObjectUtil
;
import
com.fujieid.jap.core.*
;
import
com.fujieid.jap.core.cache.JapCache
;
import
com.fujieid.jap.core.cache.JapCacheContextHolder
;
import
com.fujieid.jap.core.cache.JapLocalCache
;
import
com.fujieid.jap.core.context.JapAuthentication
;
import
com.fujieid.jap.core.context.JapContext
;
import
com.fujieid.jap.core.exception.JapException
;
import
com.fujieid.jap.core.store.JapUserStore
;
import
com.fujieid.jap.core.store.JapUserStoreContextHolder
;
import
com.fujieid.jap.core.store.SessionJapUserStore
;
import
com.fujieid.jap.core.store.SsoJapUserStore
;
import
com.fujieid.jap.sso.JapSsoHelper
;
...
...
@@ -45,18 +45,10 @@ public abstract class AbstractJapStrategy implements JapStrategy {
* Abstract the user-related function interface, which is implemented by the caller business system.
*/
protected
JapUserService
japUserService
;
/**
* user store
*/
protected
JapUserStore
japUserStore
;
/**
* jap cache
*/
protected
JapCache
japCache
;
/**
* Jap configuration.
*/
protected
JapCon
fig
japConfig
;
protected
JapCon
text
japContext
;
/**
* `Strategy` constructor.
...
...
@@ -77,37 +69,36 @@ public abstract class AbstractJapStrategy implements JapStrategy {
*/
public
AbstractJapStrategy
(
JapUserService
japUserService
,
JapConfig
japConfig
,
JapCache
japCache
)
{
this
.
japUserService
=
japUserService
;
this
.
japCache
=
japCache
;
this
.
japConfig
=
japConfig
;
this
.
japUserStore
=
japConfig
.
isSso
()
?
new
SsoJapUserStore
(
japUserService
,
japConfig
.
getSsoConfig
())
:
new
SessionJapUserStore
();
if
(
japConfig
.
isSso
())
{
// init Kisso config
JapSsoHelper
.
initKissoConfig
(
japConfig
.
getSsoConfig
());
}
JapUserStore
japUserStore
=
japConfig
.
isSso
()
?
new
SsoJapUserStore
(
japUserService
,
japConfig
.
getSsoConfig
())
:
new
SessionJapUserStore
();
this
.
japContext
=
new
JapContext
(
japUserStore
,
japCache
,
japConfig
);
JapAuthentication
.
setContext
(
this
.
japContext
);
JapUserStoreContextHolder
.
enable
(
this
.
japUserStore
);
JapCacheContextHolder
.
enable
(
this
.
japCache
);
}
/**
* Verify whether the user logs in. If so, jump to {@code japConfig.getSuccessRedirect()}. Otherwise, return {@code false}
*
* @param request Current Authentication Request
* @param request Current
Jap
Authentication Request
* @param response Current response
* @return boolean
*/
protected
boolean
checkSession
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
JapUser
sessionUser
=
jap
UserStore
.
get
(
request
,
response
);
JapUser
sessionUser
=
jap
Context
.
getUserStore
()
.
get
(
request
,
response
);
if
(
null
!=
sessionUser
)
{
JapUtil
.
redirect
(
japCon
fig
.
getSuccessRedirect
(),
response
);
JapUtil
.
redirect
(
japCon
text
.
getConfig
()
.
getSuccessRedirect
(),
response
);
return
true
;
}
return
false
;
}
protected
void
loginSuccess
(
JapUser
japUser
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
jap
UserStore
.
save
(
request
,
response
,
japUser
);
JapUtil
.
redirect
(
japCon
fig
.
getSuccessRedirect
(),
response
);
jap
Context
.
getUserStore
()
.
save
(
request
,
response
,
japUser
);
JapUtil
.
redirect
(
japCon
text
.
getConfig
()
.
getSuccessRedirect
(),
response
);
}
/**
...
...
jap-core/src/test/java/com/fujieid/jap/core/cache/JapCacheContextHolderTest.java
已删除
100644 → 0
浏览文件 @
98755478
/*
* Copyright (c) 2020-2040, 北京符节科技有限公司 (support@fujieid.com & https://www.fujieid.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.fujieid.jap.core.cache
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.io.Serializable
;
/**
* unit test
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0.0
* @since 1.0.0
*/
public
class
JapCacheContextHolderTest
{
@Test
public
void
enableNull
()
{
JapCacheContextHolder
.
enable
(
null
);
Assert
.
assertTrue
(
JapCacheContextHolder
.
getCache
()
instanceof
JapLocalCache
);
}
@Test
public
void
enableJapCache
()
{
JapCacheContextHolder
.
enable
(
new
TestJapCacheImpl
());
Assert
.
assertFalse
(
JapCacheContextHolder
.
getCache
()
instanceof
JapLocalCache
);
Assert
.
assertTrue
(
JapCacheContextHolder
.
getCache
()
instanceof
TestJapCacheImpl
);
}
@Test
public
void
getCache
()
{
JapCache
japCache
=
JapCacheContextHolder
.
getCache
();
Assert
.
assertTrue
(
japCache
instanceof
JapLocalCache
);
JapCacheContextHolder
.
enable
(
new
TestJapCacheImpl
());
Assert
.
assertTrue
(
JapCacheContextHolder
.
getCache
()
instanceof
TestJapCacheImpl
);
}
public
static
class
TestJapCacheImpl
implements
JapCache
{
/**
* Set cache
*
* @param key Cache key
* @param value Cache value after serialization
*/
@Override
public
void
set
(
String
key
,
Serializable
value
)
{
}
/**
* Set the cache and specify the expiration time of the cache
*
* @param key Cache key
* @param value Cache value after serialization
* @param timeout The expiration time of the cache, in milliseconds
*/
@Override
public
void
set
(
String
key
,
Serializable
value
,
long
timeout
)
{
}
/**
* Get cache value
*
* @param key Cache key
* @return Cache value
*/
@Override
public
Serializable
get
(
String
key
)
{
return
null
;
}
/**
* Determine whether a key exists in the cache
*
* @param key Cache key
* @return boolean
*/
@Override
public
boolean
containsKey
(
String
key
)
{
return
false
;
}
}
}
jap-mfa/pom.xml
浏览文件 @
1034a095
...
...
@@ -3,9 +3,9 @@
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
jap
</artifactId>
<groupId>
com.fujieid
</groupId>
<version>
1.0.0
</version>
<artifactId>
jap
</artifactId>
<version>
1.0.1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
jap-oauth2/pom.xml
浏览文件 @
1034a095
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
com.fujieid
</groupId>
<artifactId>
jap
</artifactId>
<version>
1.0.
0
</version>
<version>
1.0.
1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
jap-oauth2/src/main/java/com/fujieid/jap/oauth2/Oauth2Strategy.java
浏览文件 @
1034a095
...
...
@@ -18,8 +18,7 @@ package com.fujieid.jap.oauth2;
import
cn.hutool.core.util.*
;
import
com.fujieid.jap.core.*
;
import
com.fujieid.jap.core.cache.JapCache
;
import
com.fujieid.jap.core.cache.JapCacheContextHolder
;
import
com.fujieid.jap.core.exception.JapOauth2Exception
;
import
com.fujieid.jap.core.context.JapAuthentication
;
import
com.fujieid.jap.core.exception.JapUserException
;
import
com.fujieid.jap.core.strategy.AbstractJapStrategy
;
import
com.fujieid.jap.oauth2.pkce.PkceHelper
;
...
...
@@ -159,7 +158,7 @@ public class Oauth2Strategy extends AbstractJapStrategy {
state
=
RandomUtil
.
randomString
(
6
);
}
params
.
put
(
"state"
,
oAuthConfig
.
getState
());
Jap
CacheContextHolder
.
getCache
().
set
(
Oauth2Const
.
STATE_CACHE_KEY
.
concat
(
oAuthConfig
.
getClientId
()),
state
);
Jap
Authentication
.
getContext
()
.
getCache
().
set
(
Oauth2Const
.
STATE_CACHE_KEY
.
concat
(
oAuthConfig
.
getClientId
()),
state
);
// Pkce is only applicable to authorization code mode
if
(
Oauth2ResponseType
.
code
==
oAuthConfig
.
getResponseType
()
&&
oAuthConfig
.
isEnablePkce
())
{
params
.
putAll
(
PkceHelper
.
generatePkceParameters
(
oAuthConfig
));
...
...
jap-oauth2/src/main/java/com/fujieid/jap/oauth2/Oauth2Util.java
浏览文件 @
1034a095
...
...
@@ -20,7 +20,7 @@ import cn.hutool.core.util.ObjectUtil;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
com.fujieid.jap.core.c
ache.JapCacheContextHolder
;
import
com.fujieid.jap.core.c
ontext.JapAuthentication
;
import
com.fujieid.jap.core.exception.JapOauth2Exception
;
import
com.fujieid.jap.oauth2.pkce.PkceCodeChallengeMethod
;
import
com.xkcoding.json.util.Kv
;
...
...
@@ -95,7 +95,7 @@ public class Oauth2Util {
throw
new
JapOauth2Exception
(
"Illegal state."
);
}
Serializable
cacheState
=
Jap
CacheContextHolder
.
getCache
().
get
(
Oauth2Const
.
STATE_CACHE_KEY
.
concat
(
clientId
));
Serializable
cacheState
=
Jap
Authentication
.
getContext
()
.
getCache
().
get
(
Oauth2Const
.
STATE_CACHE_KEY
.
concat
(
clientId
));
if
(
null
==
cacheState
||
!
cacheState
.
equals
(
state
))
{
throw
new
JapOauth2Exception
(
"Illegal state."
);
}
...
...
jap-oauth2/src/main/java/com/fujieid/jap/oauth2/pkce/PkceHelper.java
浏览文件 @
1034a095
...
...
@@ -15,7 +15,7 @@
*/
package
com.fujieid.jap.oauth2.pkce
;
import
com.fujieid.jap.core.c
ache.JapCacheContextHolder
;
import
com.fujieid.jap.core.c
ontext.JapAuthentication
;
import
com.fujieid.jap.oauth2.OAuthConfig
;
import
com.fujieid.jap.oauth2.Oauth2Util
;
import
com.google.common.collect.Maps
;
...
...
@@ -59,7 +59,7 @@ public class PkceHelper {
params
.
put
(
PkceParams
.
CODE_CHALLENGE
,
codeChallenge
);
params
.
put
(
PkceParams
.
CODE_CHALLENGE_METHOD
,
pkceCodeChallengeMethod
);
// The default cache is local map.
Jap
CacheContextHolder
.
getCache
().
set
(
oAuthConfig
.
getClientId
(),
codeVerifier
,
oAuthConfig
.
getCodeVerifierTimeout
());
Jap
Authentication
.
getContext
()
.
getCache
().
set
(
oAuthConfig
.
getClientId
(),
codeVerifier
,
oAuthConfig
.
getCodeVerifierTimeout
());
return
params
;
}
...
...
@@ -70,6 +70,6 @@ public class PkceHelper {
* @return {@code code_verifier}
*/
public
static
String
getCacheCodeVerifier
(
String
clientId
)
{
return
(
String
)
Jap
CacheContextHolder
.
getCache
().
get
(
clientId
);
return
(
String
)
Jap
Authentication
.
getContext
()
.
getCache
().
get
(
clientId
);
}
}
jap-oauth2/src/test/java/com/fujieid/jap/oauth2/Oauth2UtilTest.java
浏览文件 @
1034a095
...
...
@@ -16,8 +16,9 @@
package
com.fujieid.jap.oauth2
;
import
com.fujieid.jap.core.cache.JapCache
;
import
com.fujieid.jap.core.cache.JapCacheContextHolder
;
import
com.fujieid.jap.core.cache.JapLocalCache
;
import
com.fujieid.jap.core.context.JapAuthentication
;
import
com.fujieid.jap.core.context.JapContext
;
import
com.fujieid.jap.core.exception.JapOauth2Exception
;
import
com.fujieid.jap.oauth2.pkce.PkceCodeChallengeMethod
;
import
com.xkcoding.json.util.Kv
;
...
...
@@ -158,7 +159,7 @@ public class Oauth2UtilTest {
boolean
verifyState
=
true
;
JapCache
cache
=
new
JapLocalCache
();
cache
.
set
(
Oauth2Const
.
STATE_CACHE_KEY
.
concat
(
clientId
),
state
);
Jap
CacheContextHolder
.
enable
(
cache
);
Jap
Authentication
.
setContext
(
new
JapContext
().
setCache
(
cache
)
);
Oauth2Util
.
checkState
(
state
,
clientId
,
verifyState
);
}
...
...
@@ -169,7 +170,7 @@ public class Oauth2UtilTest {
boolean
verifyState
=
true
;
JapCache
cache
=
new
JapLocalCache
();
cache
.
set
(
Oauth2Const
.
STATE_CACHE_KEY
.
concat
(
clientId
),
"11"
);
Jap
CacheContextHolder
.
enable
(
cache
);
Jap
Authentication
.
setContext
(
new
JapContext
().
setCache
(
cache
)
);
Assert
.
assertThrows
(
JapOauth2Exception
.
class
,
()
->
Oauth2Util
.
checkState
(
state
,
clientId
,
verifyState
));
}
...
...
jap-oauth2/src/test/java/com/fujieid/jap/oauth2/pkce/PkceHelperTest.java
浏览文件 @
1034a095
...
...
@@ -16,8 +16,9 @@
package
com.fujieid.jap.oauth2.pkce
;
import
com.fujieid.jap.core.cache.JapCache
;
import
com.fujieid.jap.core.cache.JapCacheContextHolder
;
import
com.fujieid.jap.core.cache.JapLocalCache
;
import
com.fujieid.jap.core.context.JapAuthentication
;
import
com.fujieid.jap.core.context.JapContext
;
import
com.fujieid.jap.oauth2.OAuthConfig
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -77,8 +78,8 @@ public class PkceHelperTest {
@Test
public
void
getCacheCodeVerifier
()
{
JapCache
japCache
=
new
JapLocalCache
();
Jap
CacheContextHolder
.
enable
(
japCache
);
Jap
CacheContextHolder
.
getCache
().
set
(
"clientId"
,
"111"
,
111111
);
Jap
Authentication
.
setContext
(
new
JapContext
().
setCache
(
japCache
)
);
Jap
Authentication
.
getContext
()
.
getCache
().
set
(
"clientId"
,
"111"
,
111111
);
String
res
=
PkceHelper
.
getCacheCodeVerifier
(
"clientId"
);
Assert
.
assertNotNull
(
res
);
Assert
.
assertEquals
(
"111"
,
res
);
...
...
jap-oidc/pom.xml
浏览文件 @
1034a095
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
com.fujieid
</groupId>
<artifactId>
jap
</artifactId>
<version>
1.0.
0
</version>
<version>
1.0.
1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
jap-simple/pom.xml
浏览文件 @
1034a095
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
com.fujieid
</groupId>
<artifactId>
jap
</artifactId>
<version>
1.0.
0
</version>
<version>
1.0.
1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
jap-social/pom.xml
浏览文件 @
1034a095
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
com.fujieid
</groupId>
<artifactId>
jap
</artifactId>
<version>
1.0.
0
</version>
<version>
1.0.
1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
jap-sso/pom.xml
浏览文件 @
1034a095
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
com.fujieid
</groupId>
<artifactId>
jap
</artifactId>
<version>
1.0.
0
</version>
<version>
1.0.
1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
jap-sso/src/main/java/com/fujieid/jap/sso/JapSsoHelper.java
浏览文件 @
1034a095
...
...
@@ -81,8 +81,6 @@ public class JapSsoHelper {
ssoConfig
.
setCookieDomain
(
japSsoConfig
.
getCookieDomain
());
ssoConfig
.
setCookieName
(
japSsoConfig
.
getCookieName
());
ssoConfig
.
setParamReturnUrl
(
japSsoConfig
.
getParamReturnUrl
());
ssoConfig
.
setLoginUrl
(
japSsoConfig
.
getLoginUrl
());
ssoConfig
.
setLogoutUrl
(
japSsoConfig
.
getLogoutUrl
());
ssoConfig
.
setCookieMaxAge
(
japSsoConfig
.
getCookieMaxAge
());
KiSsoHelper
.
setSsoConfig
(
ssoConfig
);
return
ssoConfig
;
...
...
jap-sso/src/main/java/com/fujieid/jap/sso/config/JapSsoConfig.java
浏览文件 @
1034a095
...
...
@@ -41,18 +41,6 @@ public class JapSsoConfig {
*/
private
String
paramReturnUrl
=
"returnUrl"
;
/**
* Login Url. Default is `/login`
*/
@Deprecated
private
String
loginUrl
=
"/login"
;
/**
* Logout Url. Default is `/logout`
*/
@Deprecated
private
String
logoutUrl
=
"/logout"
;
public
String
getCookieName
()
{
return
cookieName
;
}
...
...
@@ -80,15 +68,6 @@ public class JapSsoConfig {
return
this
;
}
public
String
getLoginUrl
()
{
return
loginUrl
;
}
public
JapSsoConfig
setLoginUrl
(
String
loginUrl
)
{
this
.
loginUrl
=
loginUrl
;
return
this
;
}
public
int
getCookieMaxAge
()
{
return
cookieMaxAge
;
}
...
...
@@ -97,13 +76,4 @@ public class JapSsoConfig {
this
.
cookieMaxAge
=
cookieMaxAge
;
return
this
;
}
public
String
getLogoutUrl
()
{
return
logoutUrl
;
}
public
JapSsoConfig
setLogoutUrl
(
String
logoutUrl
)
{
this
.
logoutUrl
=
logoutUrl
;
return
this
;
}
}
jap.sh
浏览文件 @
1034a095
...
...
@@ -25,7 +25,7 @@ case "$1" in
docs/bin/deploy.sh
;;
'c'
)
docs/bin/codecov.sh
docs/bin/codecov.sh
$2
;;
*
)
help
...
...
pom.xml
浏览文件 @
1034a095
...
...
@@ -5,7 +5,7 @@
<groupId>
com.fujieid
</groupId>
<artifactId>
jap
</artifactId>
<version>
1.0.
0
</version>
<version>
1.0.
1
</version>
<packaging>
pom
</packaging>
<name>
jap
</name>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录