Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
ab6f52b1
MaxKey
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
MaxKey
9 个月 前同步成功
通知
75
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ab6f52b1
编写于
12月 19, 2021
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
statusValid
上级
05a27e98
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
12 deletion
+40
-12
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java
...java/org/maxkey/authn/AbstractAuthenticationProvider.java
+31
-8
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/RealmAuthenticationProvider.java
...in/java/org/maxkey/authn/RealmAuthenticationProvider.java
+3
-1
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/realm/jdbc/JdbcAuthenticationRealm.java
.../org/maxkey/authn/realm/jdbc/JdbcAuthenticationRealm.java
+2
-1
maxkey-core/src/main/java/org/maxkey/persistence/db/PasswordPolicyValidator.java
...va/org/maxkey/persistence/db/PasswordPolicyValidator.java
+0
-2
maxkey-core/src/main/java/org/maxkey/web/WebConstants.java
maxkey-core/src/main/java/org/maxkey/web/WebConstants.java
+4
-0
未找到文件。
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java
浏览文件 @
ab6f52b1
...
...
@@ -25,6 +25,7 @@ import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import
org.maxkey.authn.support.rememberme.AbstractRemeberMeService
;
import
org.maxkey.configuration.ApplicationConfig
;
import
org.maxkey.constants.ConstantsLoginType
;
import
org.maxkey.constants.ConstantsStatus
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.web.WebConstants
;
...
...
@@ -324,18 +325,40 @@ public abstract class AbstractAuthenticationProvider {
return
true
;
}
protected
boolean
userinfoValid
(
UserInfo
userInfo
,
String
username
)
{
protected
boolean
statusValid
(
LoginCredential
loginCredential
,
UserInfo
userInfo
)
{
if
(
null
==
userInfo
)
{
String
m
essage
=
WebContext
.
getI18nValue
(
"login.error.username"
);
_logger
.
debug
(
"login user "
+
username
+
" not in this System ."
+
m
essage
);
UserInfo
loginUser
=
new
UserInfo
(
username
);
String
i18nM
essage
=
WebContext
.
getI18nValue
(
"login.error.username"
);
_logger
.
debug
(
"login user "
+
loginCredential
.
getUsername
()
+
" not in this System ."
+
i18nM
essage
);
UserInfo
loginUser
=
new
UserInfo
(
loginCredential
.
getUsername
()
);
loginUser
.
setId
(
loginUser
.
generateId
());
loginUser
.
setUsername
(
username
);
loginUser
.
setUsername
(
loginCredential
.
getUsername
()
);
loginUser
.
setDisplayName
(
"not exist"
);
loginUser
.
setLoginCount
(
0
);
authenticationRealm
.
insertLoginHistory
(
loginUser
,
ConstantsLoginType
.
LOCAL
,
""
,
WebContext
.
getI18nValue
(
"login.error.username"
),
WebConstants
.
LOGIN_RESULT
.
USER_NOT_EXIST
);
throw
new
BadCredentialsException
(
WebContext
.
getI18nValue
(
"login.error.username"
));
authenticationRealm
.
insertLoginHistory
(
loginUser
,
ConstantsLoginType
.
LOCAL
,
""
,
i18nMessage
,
WebConstants
.
LOGIN_RESULT
.
USER_NOT_EXIST
);
throw
new
BadCredentialsException
(
i18nMessage
);
}
else
{
if
(
userInfo
.
getIsLocked
()==
ConstantsStatus
.
LOCK
)
{
authenticationRealm
.
insertLoginHistory
(
userInfo
,
loginCredential
.
getAuthType
(),
loginCredential
.
getProvider
(),
loginCredential
.
getCode
(),
WebConstants
.
LOGIN_RESULT
.
USER_LOCKED
);
}
else
if
(
userInfo
.
getStatus
()!=
ConstantsStatus
.
ACTIVE
)
{
authenticationRealm
.
insertLoginHistory
(
userInfo
,
loginCredential
.
getAuthType
(),
loginCredential
.
getProvider
(),
loginCredential
.
getCode
(),
WebConstants
.
LOGIN_RESULT
.
USER_INACTIVE
);
}
}
return
true
;
}
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/RealmAuthenticationProvider.java
浏览文件 @
ab6f52b1
...
...
@@ -94,7 +94,7 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
userInfo
=
loadUserInfo
(
loginCredential
.
getUsername
(),
loginCredential
.
getPassword
());
userinfoValid
(
userInfo
,
loginCredential
.
getUsername
()
);
statusValid
(
loginCredential
,
userInfo
);
//mfa
tftcaptchaValid
(
loginCredential
.
getOtpCaptcha
(),
loginCredential
.
getAuthType
(),
userInfo
);
...
...
@@ -140,7 +140,9 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
@Override
public
Authentication
authentication
(
LoginCredential
loginCredential
,
boolean
isTrusted
)
{
UserInfo
loadeduserInfo
=
loadUserInfo
(
loginCredential
.
getUsername
(),
""
);
statusValid
(
loginCredential
,
loadeduserInfo
);
if
(
loadeduserInfo
!=
null
)
{
//Validate PasswordPolicy
authenticationRealm
.
getPasswordPolicyValidator
().
passwordPolicyValid
(
loadeduserInfo
);
if
(!
isTrusted
)
{
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/realm/jdbc/JdbcAuthenticationRealm.java
浏览文件 @
ab6f52b1
...
...
@@ -25,6 +25,7 @@ import org.maxkey.persistence.db.LoginHistoryService;
import
org.maxkey.persistence.db.LoginService
;
import
org.maxkey.persistence.db.PasswordPolicyValidator
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.web.WebConstants
;
import
org.maxkey.web.WebContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -119,7 +120,7 @@ public class JdbcAuthenticationRealm extends AbstractAuthenticationRealm {
_logger
.
debug
(
"passwordvalid : {}"
,
passwordMatches
);
if
(!
passwordMatches
)
{
passwordPolicyValidator
.
plusBadPasswordCount
(
userInfo
);
insertLoginHistory
(
userInfo
,
ConstantsLoginType
.
LOCAL
,
""
,
"xe00000004"
,
"password error"
);
insertLoginHistory
(
userInfo
,
ConstantsLoginType
.
LOCAL
,
""
,
"xe00000004"
,
WebConstants
.
LOGIN_RESULT
.
PASSWORD_ERROE
);
if
(
userInfo
.
getBadPasswordCount
()>=(
passwordPolicyValidator
.
getPasswordPolicy
().
getAttempts
()/
2
))
{
throw
new
BadCredentialsException
(
...
...
maxkey-core/src/main/java/org/maxkey/persistence/db/PasswordPolicyValidator.java
浏览文件 @
ab6f52b1
...
...
@@ -281,8 +281,6 @@ public class PasswordPolicyValidator {
);
}
return
true
;
}
...
...
maxkey-core/src/main/java/org/maxkey/web/WebConstants.java
浏览文件 @
ab6f52b1
...
...
@@ -91,6 +91,10 @@ public class WebConstants {
public
static
final
String
FAIL
=
"fail"
;
public
static
final
String
PASSWORD_ERROE
=
"password error"
;
public
static
final
String
USER_NOT_EXIST
=
"user not exist"
;
public
static
final
String
USER_LOCKED
=
"locked"
;
public
static
final
String
USER_INACTIVE
=
"inactive"
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录