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
c719ffce
Commit
c719ffce
authored
Sep 22, 2020
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改国密加密
parent
e38f1a14
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
27 deletions
+25
-27
DatabaseLoginContextForELCS.java
...com/brilliance/eibs/auth/DatabaseLoginContextForELCS.java
+4
-1
PasswordSM2Filter.java
...a/org/sss/presentation/noui/filter/PasswordSM2Filter.java
+21
-26
No files found.
src/main/java/cn/com/brilliance/eibs/auth/DatabaseLoginContextForELCS.java
View file @
c719ffce
...
...
@@ -225,7 +225,10 @@ public class DatabaseLoginContextForELCS extends AbstractLoginContext {
if
(
dbPassword
!=
null
)
{
dbPassword
=
dbPassword
.
trim
();
}
String
encodedPassword
=
ContainerUtils
.
encodeWithSalt
?
passwordFilter
.
encode
(
password
,
userName
).
trim
()
:
passwordFilter
.
encode
(
password
).
trim
();
// String encodedPassword = ContainerUtils.encodeWithSalt ? passwordFilter.encode(password, userName).trim() : passwordFilter.encode(password).trim();
// log.info("password反转回来==="+password+",userName===="+userName);
String
encodedPassword
=
passwordFilter
.
encode
(
password
,
userName
).
trim
();
// log.info("password国密解析==="+encodedPassword);
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
View file @
c719ffce
...
...
@@ -3,58 +3,52 @@
*/
package
org
.
sss
.
presentation
.
noui
.
filter
;
import
cfca.sadk.util.HashUtil
;
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
;
import
java.nio.charset.StandardCharsets
;
/**
* 密码过滤器实现(国密)
*
* @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
{
implements
IFilter
{
static
final
Log
log
=
LogFactory
.
getLog
(
PasswordSM2Filter
.
class
);
public
String
decode
(
String
encodedValue
)
{
public
String
decode
(
String
encodedValue
)
{
if
(
ContainerUtils
.
isEmpty
(
encodedValue
))
return
null
;
return
"**********"
;
}
public
String
encode
(
String
value
)
{
public
String
encode
(
String
value
)
{
if
(
ContainerUtils
.
isEmpty
(
value
))
return
value
;
byte
[]
result
=
null
;
try
{
result
=
HashUtil
.
SM2HashMessageByBCWithoutZValue
(
value
.
getBytes
());
byte
[]
encodedPassword
=
null
;
try
{
encodedPassword
=
HashUtil
.
SM2HashMessageByBCWithoutZValue
(
value
.
getBytes
(
StandardCharsets
.
UTF_8
));
StringBuffer
buf
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
encodedPassword
.
length
;
i
++)
{
if
((
encodedPassword
[
i
]
&
0xff
)
<
0x10
)
{
buf
.
append
(
"0"
);
}
buf
.
append
(
Long
.
toString
(
encodedPassword
[
i
]
&
0xff
,
16
));
}
catch
(
Exception
e
)
{
return
buf
.
toString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"encode SM2 error."
,
e
);
return
null
;
return
""
;
}
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
);
public
String
encode
(
String
value
,
String
salt
)
{
return
encode
(
salt
+
value
);
}
}
\ 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