Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
Overview
Overview
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
gechengyang
nouiWithSpringMVC
Commits
0131a50b
Commit
0131a50b
authored
Aug 18, 2020
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化登陆密码校验
添加国密密码校验器
parent
a8343c57
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
4 deletions
+70
-4
DatabaseLoginContextForELCS.java
...com/brilliance/eibs/auth/DatabaseLoginContextForELCS.java
+9
-4
PasswordSM2Filter.java
...a/org/sss/presentation/noui/filter/PasswordSM2Filter.java
+61
-0
No files found.
src/main/java/cn/com/brilliance/eibs/auth/DatabaseLoginContextForELCS.java
View file @
0131a50b
...
...
@@ -5,10 +5,11 @@ import log.LogFactory;
import
org.apache.commons.dbutils.DbUtils
;
import
org.sss.common.impl.AbstractLoginContext
;
import
org.sss.common.impl.MenuItemImpl
;
import
org.sss.common.impl.PasswordFilter
;
import
org.sss.common.model.IContext.DataType
;
import
org.sss.common.model.IFilter
;
import
org.sss.common.model.IMenuItem
;
import
org.sss.presentation.noui.api.response.ErrorCode
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.util.ContainerUtils
;
import
java.sql.*
;
...
...
@@ -152,10 +153,14 @@ public class DatabaseLoginContextForELCS extends AbstractLoginContext {
}
public
String
checkPassword
(
String
userName
,
String
dbPassword
,
String
password
)
{
PasswordFilter
passwordFilter
=
new
PasswordFilter
();
if
(
dbPassword
!=
null
)
IFilter
passwordFilter
=
NoUiUtils
.
passwordFilter
;
if
(
NoUiUtils
.
passwordFilter
==
null
){
log
.
info
(
"请在eibs.xml为NoUiUtils配置passwordFilter项"
);
}
if
(
dbPassword
!=
null
){
dbPassword
=
dbPassword
.
trim
();
String
encodedPassword
=
passwordFilter
.
encode
(
password
).
trim
();
}
String
encodedPassword
=
ContainerUtils
.
encodeWithSalt
?
passwordFilter
.
encode
(
password
,
userName
).
trim
()
:
passwordFilter
.
encode
(
password
).
trim
();
log
.
debug
(
"password(input/db)"
+
dbPassword
+
"\t"
+
encodedPassword
);
if
(!
encodedPassword
.
equals
(
dbPassword
))
return
"[Database: NOT Match.]"
;
...
...
src/main/java/org/sss/presentation/noui/filter/PasswordSM2Filter.java
0 → 100644
View file @
0131a50b
/*
* Create on 2007-11-15
*/
package
org
.
sss
.
presentation
.
noui
.
filter
;
import
log.Log
;
import
log.LogFactory
;
import
org.apache.commons.codec.binary.Base64
;
import
org.sss.common.model.IFilter
;
import
org.sss.util.ContainerUtils
;
import
cfca.sadk.util.HashUtil
;
/**
* 密码过滤器实现(国密)
* @author Jason.Hoo (latest modification by $Author: hujianxin $)
* @version $Revision: 1014 $ $Date: 2019-01-03 18:23:23 +0800 (Thu, 03 Jan 2019) $
*/
public
class
PasswordSM2Filter
implements
IFilter
{
static
final
Log
log
=
LogFactory
.
getLog
(
PasswordSM2Filter
.
class
);
public
String
decode
(
String
encodedValue
)
{
if
(
ContainerUtils
.
isEmpty
(
encodedValue
))
return
null
;
return
"**********"
;
}
public
String
encode
(
String
value
)
{
if
(
ContainerUtils
.
isEmpty
(
value
))
return
value
;
byte
[]
result
=
null
;
try
{
result
=
HashUtil
.
SM2HashMessageByBCWithoutZValue
(
value
.
getBytes
());
}
catch
(
Exception
e
)
{
log
.
error
(
"encode SM2 error."
,
e
);
return
null
;
}
return
new
Base64
().
encodeToString
(
result
).
trim
();
}
public
String
encode
(
String
value
,
String
salt
)
{
if
(
ContainerUtils
.
isEmpty
(
value
))
return
value
;
value
=
encode
(
value
);
if
(
ContainerUtils
.
isEmpty
(
salt
)
||
ContainerUtils
.
isEmpty
(
value
))
return
value
;
else
return
encode
(
value
+
salt
);
}
}
\ No newline at end of file
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