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
f5f1108e
Commit
f5f1108e
authored
Jul 26, 2022
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调通e结算第一版
parent
df85524c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
390 additions
and
380 deletions
+390
-380
pom.xml
pom.xml
+1
-1
EmptyLoginContext.java
...n/java/cn/com/brilliance/eibs/auth/EmptyLoginContext.java
+66
-48
EhcacheCacheEventListener.java
...ntation/noui/cache/Ehcache/EhcacheCacheEventListener.java
+5
-5
Constants.java
...main/java/org/sss/presentation/noui/common/Constants.java
+3
-1
AbstractCommonController.java
...resentation/noui/controller/AbstractCommonController.java
+2
-6
FileTypeInterceptor.java
...org/sss/presentation/noui/filter/FileTypeInterceptor.java
+78
-76
PasswordSM2Filter.java
...a/org/sss/presentation/noui/filter/PasswordSM2Filter.java
+53
-53
ResourceAccessFilter.java
...rg/sss/presentation/noui/filter/ResourceAccessFilter.java
+4
-4
OpenTransInterceptor.java
...a/org/sss/presentation/noui/jwt/OpenTransInterceptor.java
+2
-2
TokenInterceptor.java
.../java/org/sss/presentation/noui/jwt/TokenInterceptor.java
+2
-2
AESUtil.java
src/main/java/org/sss/presentation/noui/util/AESUtil.java
+0
-0
HttpClientUtil.java
...n/java/org/sss/presentation/noui/util/HttpClientUtil.java
+2
-2
NoUiPresentationUtil.java
.../org/sss/presentation/noui/util/NoUiPresentationUtil.java
+0
-2
PropertyUtil.java
...ain/java/org/sss/presentation/noui/util/PropertyUtil.java
+169
-174
ResourceAcccessEncryptUtil.java
...ss/presentation/noui/util/ResourceAcccessEncryptUtil.java
+2
-3
eIBS.xml
src/main/resources/eIBS.xml
+1
-1
No files found.
pom.xml
View file @
f5f1108e
...
...
@@ -21,7 +21,7 @@
</repositories>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
GBK
</project.build.sourceEncoding>
<maven-dependency-plugin.version>
3.2.0
</maven-dependency-plugin.version>
<spring.version>
5.1.3.RELEASE
</spring.version>
<slf4j-api_version>
1.7.25
</slf4j-api_version>
...
...
src/main/java/cn/com/brilliance/eibs/auth/EmptyLoginContext.java
View file @
f5f1108e
package
cn
.
com
.
brilliance
.
eibs
.
auth
;
import
java.sql.Connection
;
import
java.util.Map
;
import
org.sss.common.impl.AbstractLoginContext
;
import
org.sss.common.model.IMenuItem
;
public
class
EmptyLoginContext
extends
AbstractLoginContext
{
private
String
userId
;
public
EmptyLoginContext
(
String
userId
)
{
this
.
userId
=
userId
;
}
@Override
public
String
getLoginUser
()
{
return
this
.
userId
;
}
@Override
public
boolean
auth
(
Connection
arg0
,
Map
arg1
)
{
return
true
;
}
@Override
public
IMenuItem
getMenu
()
{
return
null
;
}
@Override
protected
String
getParameter
(
Map
arg0
,
String
arg1
)
{
return
null
;
}
@Override
public
Object
getValue
(
String
arg0
)
{
return
null
;
}
@Override
public
boolean
login
(
Connection
arg0
,
Map
arg1
)
{
return
true
;
}
}
package
cn
.
com
.
brilliance
.
eibs
.
auth
;
import
org.sss.common.impl.AbstractLoginContext
;
import
org.sss.common.model.IMenuItem
;
import
java.sql.Connection
;
import
java.util.Map
;
public
class
EmptyLoginContext
extends
AbstractLoginContext
{
private
String
userId
;
public
EmptyLoginContext
(
String
userId
)
{
this
.
userId
=
userId
;
}
@Override
public
String
getLoginUser
()
{
return
this
.
userId
;
}
@Override
public
boolean
auth
(
Connection
arg0
,
Map
arg1
)
{
return
true
;
}
@Override
public
IMenuItem
getMenu
()
{
return
null
;
}
@Override
protected
String
getParameter
(
Map
map
,
String
key
)
{
if
(
map
==
null
){
return
null
;
}
Object
o
=
map
.
get
(
key
);
if
(
o
==
null
){
return
null
;
}
else
if
(
o
instanceof
String
){
return
(
String
)
o
;
}
else
if
(
o
instanceof
String
[]){
return
((
String
[])
o
)[
0
];
}
else
{
return
o
.
toString
();
}
}
@Override
public
Object
getValue
(
String
key
)
{
if
(
"usrinr"
.
equals
(
key
)){
return
userId
;
}
return
null
;
}
@Override
public
boolean
login
(
Connection
arg0
,
Map
arg1
)
{
return
true
;
}
}
src/main/java/org/sss/presentation/noui/cache/Ehcache/EhcacheCacheEventListener.java
View file @
f5f1108e
...
...
@@ -34,11 +34,6 @@ public class EhcacheCacheEventListener implements CacheEventListener {
@Override
public
void
notifyElementExpired
(
Ehcache
ehcache
,
Element
element
)
{
System
.
out
.
println
(
"销毁"
+
element
.
getObjectKey
()
+
":"
+
element
.
getObjectValue
());
}
@Override
public
void
notifyElementEvicted
(
Ehcache
ehcache
,
Element
element
)
{
//获取过期的key
String
expireKey
=
String
.
valueOf
(
element
.
getObjectKey
());
log
.
debug
(
"expireKey is:"
+
expireKey
);
...
...
@@ -57,6 +52,11 @@ public class EhcacheCacheEventListener implements CacheEventListener {
}
@Override
public
void
notifyElementEvicted
(
Ehcache
ehcache
,
Element
element
)
{
}
@Override
public
void
notifyRemoveAll
(
Ehcache
ehcache
)
{
}
...
...
src/main/java/org/sss/presentation/noui/common/Constants.java
View file @
f5f1108e
package
org
.
sss
.
presentation
.
noui
.
common
;
import
java.nio.charset.Charset
;
public
class
Constants
{
public
final
static
String
PARAMS
=
"params"
;
public
final
static
String
DATA
=
"data"
;
public
final
static
String
DISPLAY
=
"display"
;
public
final
static
String
ENCODING
=
"UTF-8"
;
public
static
final
Charset
ENCODING_CHARSET
=
Charset
.
forName
(
ENCODING
);
public
final
static
String
USERNAME
=
"username"
;
public
final
static
String
PASSWORD
=
"password"
;
public
final
static
String
DNCODE
=
"dncode"
;
...
...
src/main/java/org/sss/presentation/noui/controller/AbstractCommonController.java
View file @
f5f1108e
...
...
@@ -50,7 +50,6 @@ public abstract class AbstractCommonController {
@SuppressWarnings
(
"unchecked"
)
public
Object
event
(
String
mappingUrl
,
String
eventType
,
Map
<
String
,
Object
>
dataMap
,
MultipartFile
file
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
NoUiContext
context
=
null
;
Result
ret
=
null
;
String
serverEnc
=
null
;
...
...
@@ -295,12 +294,9 @@ public abstract class AbstractCommonController {
// 不能修改
for
(
String
key
:
modifyMap
.
keySet
())
{
if
(!
containsKeys
.
contains
(
key
))
{
System
.
out
.
println
(
"modify test:"
+
modifyMap
.
get
(
key
).
getClass
());
System
.
out
.
println
(
"modify datafield:"
+
(
modifyMap
.
get
(
key
)
instanceof
IDatafield
));
System
.
out
.
println
(
"modify module:"
+
(
modifyMap
.
get
(
key
)
instanceof
IModule
));
System
.
out
.
println
(
"modify moduleList:"
+
(
modifyMap
.
get
(
key
)
instanceof
IModuleList
));
if
(
key
==
null
)
if
(
key
==
null
){
continue
;
}
Object
baseObject
=
modifyMap
.
get
(
key
);
if
(
baseObject
instanceof
IModuleList
)
{
...
...
src/main/java/org/sss/presentation/noui/filter/FileTypeInterceptor.java
View file @
f5f1108e
package
org
.
sss
.
presentation
.
noui
.
filter
;
import
com.google.gson.Gson
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
org.sss.presentation.noui.api.response.ErrorCodes
;
import
org.sss.presentation.noui.api.response.NoUiVersion
;
import
org.sss.presentation.noui.api.response.Result
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.PrintWriter
;
import
java.util.Iterator
;
import
java.util.Map
;
/**
* 全局文件类型拦截器
*/
public
class
FileTypeInterceptor
extends
HandlerInterceptorAdapter
{
@Autowired
private
NoUiVersion
noUiVersion
;
private
String
type_list
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
boolean
flag
=
true
;
// 判断是否为文件上传请求
if
(
request
instanceof
MultipartHttpServletRequest
)
{
MultipartHttpServletRequest
multipartRequest
=
(
MultipartHttpServletRequest
)
request
;
Map
<
String
,
MultipartFile
>
files
=
multipartRequest
.
getFileMap
();
Iterator
<
String
>
iterator
=
files
.
keySet
().
iterator
();
//对多部件请求资源进行遍历
while
(
iterator
.
hasNext
())
{
String
formKey
=
(
String
)
iterator
.
next
();
MultipartFile
multipartFile
=
multipartRequest
.
getFile
(
formKey
);
String
filename
=
multipartFile
.
getOriginalFilename
();
//判断是否为限制文件类型
if
(
checkLimitFile
(
filename
))
{
//限制文件类型,请求转发到原始请求页面,并携带错误提示信息
flag
=
false
;
response
.
setContentType
(
"application/json; charset=utf-8"
);
Result
result
=
new
Result
(
ErrorCodes
.
ERROR
,
"不支持的文件类型!"
,
null
,
noUiVersion
.
getVersion
());
PrintWriter
out
=
response
.
getWriter
();
String
json
=
new
Gson
().
toJson
(
result
);
out
.
print
(
json
);
out
.
flush
();
out
.
close
();
}
}
}
return
flag
;
}
/**
* 判断是否为允许的上传文件类型,true表示允许
*/
private
boolean
checkLimitFile
(
String
fileName
)
{
//设置允许上传文件类型
// String suffixList = "jpg,gif,png,ico,bmp,jpeg";
String
suffixList
=
type_list
;
// 获取文件后缀
String
suffix
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
,
fileName
.
length
());
if
(
suffixList
.
contains
(
suffix
.
trim
().
toLowerCase
()))
{
return
true
;
}
return
false
;
}
public
void
setType_list
(
String
type_list
)
{
this
.
type_list
=
type_list
;
}
package
org
.
sss
.
presentation
.
noui
.
filter
;
import
com.google.gson.Gson
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
org.sss.presentation.noui.api.response.ErrorCodes
;
import
org.sss.presentation.noui.api.response.NoUiVersion
;
import
org.sss.presentation.noui.api.response.Result
;
import
org.sss.presentation.noui.common.Constants
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.PrintWriter
;
import
java.util.Iterator
;
import
java.util.Map
;
/**
* 全局文件类型拦截器
*/
public
class
FileTypeInterceptor
extends
HandlerInterceptorAdapter
{
@Autowired
private
NoUiVersion
noUiVersion
;
private
String
type_list
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
boolean
flag
=
true
;
// 判断是否为文件上传请求
if
(
request
instanceof
MultipartHttpServletRequest
)
{
MultipartHttpServletRequest
multipartRequest
=
(
MultipartHttpServletRequest
)
request
;
Map
<
String
,
MultipartFile
>
files
=
multipartRequest
.
getFileMap
();
Iterator
<
String
>
iterator
=
files
.
keySet
().
iterator
();
//对多部件请求资源进行遍历
while
(
iterator
.
hasNext
())
{
String
formKey
=
(
String
)
iterator
.
next
();
MultipartFile
multipartFile
=
multipartRequest
.
getFile
(
formKey
);
String
filename
=
multipartFile
.
getOriginalFilename
();
//判断是否为限制文件类型
if
(
checkLimitFile
(
filename
))
{
//限制文件类型,请求转发到原始请求页面,并携带错误提示信息
flag
=
false
;
response
.
setContentType
(
"application/json; charset="
+
Constants
.
ENCODING
);
Result
result
=
new
Result
(
ErrorCodes
.
ERROR
,
"不支持的文件类型!"
,
null
,
noUiVersion
.
getVersion
());
PrintWriter
out
=
response
.
getWriter
();
String
json
=
new
Gson
().
toJson
(
result
);
out
.
print
(
json
);
out
.
flush
();
out
.
close
();
}
}
}
return
flag
;
}
/**
* 判断是否为允许的上传文件类型,true表示允许
*/
private
boolean
checkLimitFile
(
String
fileName
)
{
//设置允许上传文件类型
// String suffixList = "jpg,gif,png,ico,bmp,jpeg";
String
suffixList
=
type_list
;
// 获取文件后缀
String
suffix
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
,
fileName
.
length
());
if
(
suffixList
.
contains
(
suffix
.
trim
().
toLowerCase
()))
{
return
true
;
}
return
false
;
}
public
void
setType_list
(
String
type_list
)
{
this
.
type_list
=
type_list
;
}
}
\ No newline at end of file
src/main/java/org/sss/presentation/noui/filter/PasswordSM2Filter.java
View file @
f5f1108e
/*
* Create on 2007-11-15
*/
package
org
.
sss
.
presentation
.
noui
.
filter
;
import
cfca.sadk.util.HashUtil
;
import
log.Log
;
import
log.LogFactory
;
import
org.sss.common.model.IFilter
;
import
org.sss.util.ContainerUtils
;
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
{
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
[]
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
));
}
return
buf
.
toString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"encode SM2 error."
,
e
);
return
""
;
}
}
public
String
encode
(
String
value
,
String
salt
)
{
return
encode
(
salt
+
value
);
}
/*
* Create on 2007-11-15
*/
package
org
.
sss
.
presentation
.
noui
.
filter
;
import
cfca.sadk.util.HashUtil
;
import
log.Log
;
import
log.LogFactory
;
import
org.sss.common.model.IFilter
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.util.ContainerUtils
;
/**
* 密码过滤器实现(国密)
*
* @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
[]
encodedPassword
=
null
;
try
{
encodedPassword
=
HashUtil
.
SM2HashMessageByBCWithoutZValue
(
value
.
getBytes
(
Constants
.
ENCODING
));
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
));
}
return
buf
.
toString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"encode SM2 error."
,
e
);
return
""
;
}
}
public
String
encode
(
String
value
,
String
salt
)
{
return
encode
(
salt
+
value
);
}
}
\ No newline at end of file
src/main/java/org/sss/presentation/noui/filter/ResourceAccessFilter.java
View file @
f5f1108e
...
...
@@ -4,6 +4,7 @@ import log.Log;
import
log.LogFactory
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.presentation.noui.util.ResourceAcccessEncryptUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
...
...
@@ -14,14 +15,13 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
public
class
ResourceAccessFilter
implements
Filter
{
public
static
final
String
NO_FOUND_PDF
=
"/WEB-INF/classes/forbidden.pdf"
;
protected
static
final
Log
log
=
LogFactory
.
getLog
(
ResourceAccessFilter
.
class
);
private
static
final
String
_JSON_CONTENT
=
"application/json; charset=
UTF-8"
;
private
static
final
String
_HTML_CONTENT
=
"text/html; charset=
UTF-8"
;
private
static
final
String
_JSON_CONTENT
=
"application/json; charset=
"
+
Constants
.
ENCODING
;
private
static
final
String
_HTML_CONTENT
=
"text/html; charset=
"
+
Constants
.
ENCODING
;
private
static
final
String
_403_JSON
=
"{\"code\": \"403\", \"msg\": \"Access Forbidden, Unauthorized!\"}"
;
private
static
final
String
_403_HTML
=
"<html><body><div style='text-align:center'><h1 style='margin-top: 10px;'>Access Forbidden, Unauthorized!</h1></div></body></html>"
;
private
static
final
String
DSPPTH
=
"/data/dsp/"
;
...
...
@@ -77,7 +77,7 @@ public class ResourceAccessFilter implements Filter {
File
file
=
new
File
(
sb
.
toString
());
if
(
file
.
exists
())
{
response
.
setContentType
(
_JSON_CONTENT
);
response
.
getWriter
().
print
(
FileUtils
.
readFileToString
(
file
,
StandardCharsets
.
UTF_8
));
response
.
getWriter
().
print
(
FileUtils
.
readFileToString
(
file
,
Constants
.
ENCODING
));
return
;
}
else
{
log
.
warn
(
"Dsp Is Not Exists"
);
...
...
src/main/java/org/sss/presentation/noui/jwt/OpenTransInterceptor.java
View file @
f5f1108e
...
...
@@ -36,7 +36,7 @@ public class OpenTransInterceptor implements HandlerInterceptor {
// 拦截每个请求
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
Constants
.
ENCODING
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
""
,
null
);
String
token
=
noUiRequest
.
getToken
();
String
userId
=
noUiRequest
.
getUserId
();
...
...
@@ -79,7 +79,7 @@ public class OpenTransInterceptor implements HandlerInterceptor {
// 请求不通过,返回错误信息给客户端
private
void
responseMessage
(
HttpServletResponse
response
,
PrintWriter
out
,
Result
result
)
{
response
.
setContentType
(
"application/json; charset=
utf-8"
);
response
.
setContentType
(
"application/json; charset=
"
+
Constants
.
ENCODING
);
String
json
=
new
Gson
().
toJson
(
result
);
out
.
print
(
json
);
out
.
flush
();
...
...
src/main/java/org/sss/presentation/noui/jwt/TokenInterceptor.java
View file @
f5f1108e
...
...
@@ -28,7 +28,7 @@ public class TokenInterceptor implements HandlerInterceptor {
// 拦截每个请求
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
Constants
.
ENCODING
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
""
,
null
);
String
token
=
noUiRequest
.
getToken
();
String
userId
=
noUiRequest
.
getUserId
();
...
...
@@ -96,7 +96,7 @@ public class TokenInterceptor implements HandlerInterceptor {
// 请求不通过,返回错误信息给客户端
private
void
responseMessage
(
HttpServletResponse
response
,
PrintWriter
out
,
Result
result
)
{
response
.
setContentType
(
"application/json; charset=
utf-8"
);
response
.
setContentType
(
"application/json; charset=
"
+
Constants
.
ENCODING
);
String
json
=
new
Gson
().
toJson
(
result
);
out
.
print
(
json
);
out
.
flush
();
...
...
src/main/java/org/sss/presentation/noui/util/AESUtil.java
View file @
f5f1108e
This diff is collapsed.
Click to expand it.
src/main/java/org/sss/presentation/noui/util/HttpClientUtil.java
View file @
f5f1108e
...
...
@@ -8,8 +8,8 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.web.client.RestClientException
;
import
org.springframework.web.client.RestTemplate
;
import
org.sss.presentation.noui.common.Constants
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Map
;
public
class
HttpClientUtil
{
...
...
@@ -20,7 +20,7 @@ public class HttpClientUtil {
factory
.
setConnectTimeout
(
15000
);
factory
.
setReadTimeout
(
30000
);
restTemplate
=
new
RestTemplate
(
factory
);
restTemplate
.
getMessageConverters
().
set
(
1
,
new
StringHttpMessageConverter
(
StandardCharsets
.
UTF_8
));
restTemplate
.
getMessageConverters
().
set
(
1
,
new
StringHttpMessageConverter
(
Constants
.
ENCODING_CHARSET
));
}
/**
...
...
src/main/java/org/sss/presentation/noui/util/NoUiPresentationUtil.java
View file @
f5f1108e
...
...
@@ -40,7 +40,6 @@ public class NoUiPresentationUtil {
IBaseObject
baseObject
=
null
;
try
{
System
.
out
.
println
(
"url="
+
url
);
baseObject
=
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
url
);
if
(
null
==
baseObject
)
{
throw
new
NoUiException
(
"not found url :"
+
url
+
" ,alias name is:"
+
aliasKey
);
...
...
@@ -84,7 +83,6 @@ public class NoUiPresentationUtil {
IBaseObject
baseObject
=
null
;
try
{
System
.
out
.
println
(
"url="
+
url
);
baseObject
=
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
url
);
if
(
null
==
baseObject
)
{
throw
new
NoUiException
(
"not found url :"
+
url
+
" ,alias name is:"
+
aliasKey
);
...
...
src/main/java/org/sss/presentation/noui/util/PropertyUtil.java
View file @
f5f1108e
package
org
.
sss
.
presentation
.
noui
.
util
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
import
org.apache.commons.io.IOUtils
;
/**
* Properties文件工具
*
* @author xiaoyuanzhen
*
*/
public
class
PropertyUtil
{
/**
* 从properties文件中获取指定属性名对应的值
*
* @param propertyFile
* @param propertyName
* @return
*/
private
static
Map
<
String
,
Properties
>
map
=
new
HashMap
<
String
,
Properties
>();
public
static
String
getProperty
(
String
propertyFile
,
String
propertyName
)
{
String
propertyValue
=
""
;
InputStream
is
=
null
;
try
{
Properties
propertie
=
new
Properties
();
if
(!
map
.
containsKey
(
propertyFile
))
{
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
propertyFile
);
propertie
.
load
(
is
);
map
.
put
(
propertyFile
,
propertie
);
}
propertyValue
=
map
.
get
(
propertyFile
).
getProperty
(
propertyName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
propertyValue
=
""
;
}
finally
{
try
{
IOUtils
.
closeQuietly
(
is
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
propertyValue
;
}
/**
* 设置properties文件的某个属性值
*
* @param propertyFile
* @param propertyName
* @param propertyValue
* @return
*/
public
synchronized
static
boolean
setProperty
(
String
propertyFile
,
String
propertyName
,
String
propertyValue
)
{
boolean
sav
=
false
;
InputStream
is
=
null
;
OutputStream
os
=
null
;
try
{
Properties
propertie
=
new
Properties
();
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
propertyFile
);
propertie
.
load
(
is
);
propertie
.
setProperty
(
propertyName
,
propertyValue
);
String
path
=
Thread
.
currentThread
().
getContextClassLoader
().
getResource
(
propertyFile
).
getPath
();
os
=
new
FileOutputStream
(
new
File
(
path
));
propertie
.
store
(
os
,
""
);
os
.
flush
();
sav
=
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
sav
=
false
;
}
finally
{
try
{
is
.
close
();
os
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
sav
;
}
public
synchronized
static
boolean
setPropertyValue
(
String
propertyFile
,
String
propertyName
,
String
propertyValue
)
{
boolean
sav
=
false
;
OutputStream
os
=
null
;
InputStream
is
=
null
;
try
{
Properties
propertie
=
new
Properties
();
is
=
new
FileInputStream
(
new
File
(
propertyFile
));
propertie
.
load
(
is
);
propertie
.
setProperty
(
propertyName
,
propertyValue
);
os
=
new
FileOutputStream
(
new
File
(
propertyFile
));
propertie
.
store
(
os
,
""
);
os
.
flush
();
sav
=
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
propertyValue
=
""
;
}
finally
{
try
{
is
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
sav
;
}
private
static
Properties
load
(
File
f
,
String
encoding
)
throws
IOException
{
Properties
propertie
=
new
Properties
();
InputStreamReader
is
=
new
InputStreamReader
(
new
FileInputStream
(
f
),
encoding
);
propertie
.
load
(
is
);
is
.
close
();
return
propertie
;
}
private
static
Properties
load
(
File
f
)
throws
IOException
{
return
load
(
f
,
"GBK"
);
}
public
static
Properties
load
(
String
name
)
throws
IOException
{
InputStream
is
=
null
;
Properties
propertie
=
new
Properties
();
try
{
if
(!
map
.
containsKey
(
name
))
{
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
name
);
propertie
.
load
(
is
);
map
.
put
(
name
,
propertie
);
}
else
{
return
map
.
get
(
name
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
IOUtils
.
closeQuietly
(
is
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
propertie
;
}
public
static
Properties
getProperties
(
String
propertyFile
)
throws
IOException
{
return
getProperties
(
propertyFile
,
"GBK"
);
}
public
static
Properties
getProperties
(
String
propertyFile
,
String
encoding
)
throws
IOException
{
return
load
(
new
File
(
propertyFile
),
encoding
);
}
public
static
String
getPropertyValue
(
String
propertyFile
,
String
propertyName
)
{
String
propertyValue
=
""
;
// InputStream is = null;
try
{
Properties
propertie
=
load
(
new
File
(
propertyFile
));
propertyValue
=
propertie
.
getProperty
(
propertyName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
propertyValue
=
""
;
}
return
propertyValue
;
}
}
package
org
.
sss
.
presentation
.
noui
.
util
;
import
org.apache.commons.io.IOUtils
;
import
org.sss.presentation.noui.common.Constants
;
import
java.io.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
/**
* Properties文件工具
*
* @author xiaoyuanzhen
*
*/
public
class
PropertyUtil
{
/**
* 从properties文件中获取指定属性名对应的值
*
* @param propertyFile
* @param propertyName
* @return
*/
private
static
Map
<
String
,
Properties
>
map
=
new
HashMap
<
String
,
Properties
>();
public
static
String
getProperty
(
String
propertyFile
,
String
propertyName
)
{
String
propertyValue
=
""
;
InputStream
is
=
null
;
try
{
Properties
propertie
=
new
Properties
();
if
(!
map
.
containsKey
(
propertyFile
))
{
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
propertyFile
);
propertie
.
load
(
is
);
map
.
put
(
propertyFile
,
propertie
);
}
propertyValue
=
map
.
get
(
propertyFile
).
getProperty
(
propertyName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
propertyValue
=
""
;
}
finally
{
try
{
IOUtils
.
closeQuietly
(
is
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
propertyValue
;
}
/**
* 设置properties文件的某个属性值
*
* @param propertyFile
* @param propertyName
* @param propertyValue
* @return
*/
public
synchronized
static
boolean
setProperty
(
String
propertyFile
,
String
propertyName
,
String
propertyValue
)
{
boolean
sav
=
false
;
InputStream
is
=
null
;
OutputStream
os
=
null
;
try
{
Properties
propertie
=
new
Properties
();
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
propertyFile
);
propertie
.
load
(
is
);
propertie
.
setProperty
(
propertyName
,
propertyValue
);
String
path
=
Thread
.
currentThread
().
getContextClassLoader
().
getResource
(
propertyFile
).
getPath
();
os
=
new
FileOutputStream
(
new
File
(
path
));
propertie
.
store
(
os
,
""
);
os
.
flush
();
sav
=
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
sav
=
false
;
}
finally
{
try
{
is
.
close
();
os
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
sav
;
}
public
synchronized
static
boolean
setPropertyValue
(
String
propertyFile
,
String
propertyName
,
String
propertyValue
)
{
boolean
sav
=
false
;
OutputStream
os
=
null
;
InputStream
is
=
null
;
try
{
Properties
propertie
=
new
Properties
();
is
=
new
FileInputStream
(
new
File
(
propertyFile
));
propertie
.
load
(
is
);
propertie
.
setProperty
(
propertyName
,
propertyValue
);
os
=
new
FileOutputStream
(
new
File
(
propertyFile
));
propertie
.
store
(
os
,
""
);
os
.
flush
();
sav
=
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
propertyValue
=
""
;
}
finally
{
try
{
is
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
sav
;
}
private
static
Properties
load
(
File
f
,
String
encoding
)
throws
IOException
{
Properties
propertie
=
new
Properties
();
InputStreamReader
is
=
new
InputStreamReader
(
new
FileInputStream
(
f
),
encoding
);
propertie
.
load
(
is
);
is
.
close
();
return
propertie
;
}
private
static
Properties
load
(
File
f
)
throws
IOException
{
return
load
(
f
,
Constants
.
ENCODING
);
}
public
static
Properties
load
(
String
name
)
throws
IOException
{
InputStream
is
=
null
;
Properties
propertie
=
new
Properties
();
try
{
if
(!
map
.
containsKey
(
name
))
{
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
name
);
propertie
.
load
(
is
);
map
.
put
(
name
,
propertie
);
}
else
{
return
map
.
get
(
name
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
IOUtils
.
closeQuietly
(
is
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
propertie
;
}
public
static
Properties
getProperties
(
String
propertyFile
)
throws
IOException
{
return
getProperties
(
propertyFile
,
Constants
.
ENCODING
);
}
public
static
Properties
getProperties
(
String
propertyFile
,
String
encoding
)
throws
IOException
{
return
load
(
new
File
(
propertyFile
),
encoding
);
}
public
static
String
getPropertyValue
(
String
propertyFile
,
String
propertyName
)
{
String
propertyValue
=
""
;
// InputStream is = null;
try
{
Properties
propertie
=
load
(
new
File
(
propertyFile
));
propertyValue
=
propertie
.
getProperty
(
propertyName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
propertyValue
=
""
;
}
return
propertyValue
;
}
}
src/main/java/org/sss/presentation/noui/util/ResourceAcccessEncryptUtil.java
View file @
f5f1108e
package
org
.
sss
.
presentation
.
noui
.
util
;
import
cfca.sadk.algorithm.sm2.SM3Digest
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.jwt.RedisLoginInfo
;
import
java.nio.charset.StandardCharsets
;
public
class
ResourceAcccessEncryptUtil
{
private
static
final
String
KEY
=
"session.##.WEB"
;
private
static
final
String
SALT
=
"1314520@Brilliance;"
;
...
...
@@ -39,7 +38,7 @@ public class ResourceAcccessEncryptUtil {
}
private
static
String
sm3
(
String
msg
)
{
byte
[]
z
=
msg
.
getBytes
(
StandardCharsets
.
UTF_8
);
byte
[]
z
=
msg
.
getBytes
(
Constants
.
ENCODING_CHARSET
);
SM3Digest
sm3
=
new
SM3Digest
();
sm3
.
update
(
z
,
0
,
z
.
length
);
byte
[]
hash
=
new
byte
[
32
];
...
...
src/main/resources/eIBS.xml
View file @
f5f1108e
...
...
@@ -3,7 +3,7 @@
<service
class=
"org.sss.presentation.noui.util.NoUiUtils"
initMethodName=
"init"
deinitMethodName=
"deinit"
>
<property
name=
"datapath"
value=
"D:/"
/>
<property
name=
"fieldencode"
value=
"
tru
e"
class=
"boolean"
/>
<property
name=
"fieldencode"
value=
"
fals
e"
class=
"boolean"
/>
<property
name=
"connectKeeped"
value=
"true"
class=
"boolean"
/>
<property
name=
"debugMode"
value=
"false"
class=
"boolean"
/>
<!-- WAR包本身的目录为变量$ROOT,WAR/WEB-INF/classes目录为变量$HOME -->
...
...
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