Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api
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
首航-临时账号
api
Commits
a92b51b3
Commit
a92b51b3
authored
Jan 10, 2020
by
Lenovo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加userCode校验
parent
295b4532
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
web.xml
WebContent/WEB-INF/web.xml
+1
-1
BasicVerifyFilter.java
src/com/ejweb/core/filter/BasicVerifyFilter.java
+11
-7
No files found.
WebContent/WEB-INF/web.xml
View file @
a92b51b3
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
<filter-class>
com.ejweb.core.filter.BasicVerifyFilter
</filter-class>
<filter-class>
com.ejweb.core.filter.BasicVerifyFilter
</filter-class>
<init-param>
<init-param>
<param-name>
excludedPages
</param-name>
<param-name>
excludedPages
</param-name>
<param-value>
app
</param-value>
<param-value>
/api/user/login
</param-value>
</init-param>
</init-param>
</filter>
</filter>
<filter-mapping>
<filter-mapping>
...
...
src/com/ejweb/core/filter/BasicVerifyFilter.java
View file @
a92b51b3
...
@@ -5,10 +5,13 @@ import com.ejweb.core.base.BaseBean;
...
@@ -5,10 +5,13 @@ import com.ejweb.core.base.BaseBean;
import
com.ejweb.core.base.BaseUserBean
;
import
com.ejweb.core.base.BaseUserBean
;
import
com.ejweb.core.conf.GConstants
;
import
com.ejweb.core.conf.GConstants
;
import
com.ejweb.core.security.GlobalUtil
;
import
com.ejweb.core.security.GlobalUtil
;
import
com.ejweb.modules.user.entity.User
;
import
com.ejweb.modules.user.entity.UserEntity
;
import
com.ejweb.modules.user.entity.UserEntity
;
import
com.ejweb.modules.user.service.UserService
;
import
com.ejweb.modules.user.service.UserService
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.web.context.support.WebApplicationContextUtils
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -21,7 +24,6 @@ import java.util.Set;
...
@@ -21,7 +24,6 @@ import java.util.Set;
* 对请求接口进行基本信息验证类 excludedPages * .* .+ 三种均为不验证数据
* 对请求接口进行基本信息验证类 excludedPages * .* .+ 三种均为不验证数据
*/
*/
public
class
BasicVerifyFilter
implements
Filter
{
public
class
BasicVerifyFilter
implements
Filter
{
private
String
excludedPages
;
// 例外列表,支持正则匹配,多个地址以分号“;”分隔
private
String
excludedPages
;
// 例外列表,支持正则匹配,多个地址以分号“;”分隔
private
String
[]
excludedPageArray
;
// 例外列表
private
String
[]
excludedPageArray
;
// 例外列表
private
boolean
isExcludedPage
=
false
;
// 是否有例外请求链接
private
boolean
isExcludedPage
=
false
;
// 是否有例外请求链接
...
@@ -115,16 +117,18 @@ public class BasicVerifyFilter implements Filter {
...
@@ -115,16 +117,18 @@ public class BasicVerifyFilter implements Filter {
String
message
=
"content及sign不允许为空"
;
String
message
=
"content及sign不允许为空"
;
if
(
content
!=
null
&&
sign
!=
null
)
{
// 基本参数不为NULL
if
(
content
!=
null
&&
sign
!=
null
)
{
// 基本参数不为NULL
BaseBean
baseBean
=
JSON
.
parseObject
(
content
,
BaseBean
.
class
);
BaseBean
baseBean
=
JSON
.
parseObject
(
content
,
BaseBean
.
class
);
message
=
"
app_code或 userCode不允许为空
"
;
message
=
"
无效请求
"
;
BaseUserBean
baseUserBean
=
JSON
.
parseObject
(
content
,
BaseUserBean
.
class
);
BaseUserBean
baseUserBean
=
JSON
.
parseObject
(
content
,
BaseUserBean
.
class
);
String
userCode
=
baseUserBean
.
getUserCode
();
String
userCode
=
baseUserBean
.
getUserCode
();
if
(
userCode
!=
null
&&
!
""
.
equals
(
userCode
)
&&
!
"undefind"
.
equals
(
userCode
))
{
if
(
userCode
!=
null
&&
!
""
.
equals
(
userCode
)
&&
!
"undefind"
.
equals
(
userCode
))
{
UserService
userService
=
new
UserService
();
ServletContext
context
=
request
.
getServletContext
();
UserEntity
ue
=
new
UserEntity
();
ApplicationContext
ctx
=
WebApplicationContextUtils
.
getWebApplicationContext
(
context
);
UserService
userService
=
ctx
.
getBean
(
UserService
.
class
);
UserEntity
ue
=
new
UserEntity
();
ue
.
setUsercode
(
userCode
);
ue
.
setUsercode
(
userCode
);
String
userIdByCode
=
userService
.
getUserIdByCode
(
userCod
e
);
User
user
=
userService
.
getUserByUserCode
(
u
e
);
message
=
"
用户不存在
"
;
message
=
"
无效请求
"
;
if
(
user
IdByCode
!=
null
)
{
if
(
user
!=
null
)
{
if
(
baseBean
.
getAppCode
()
!=
null
)
{
// 基本必要参数验证通过
if
(
baseBean
.
getAppCode
()
!=
null
)
{
// 基本必要参数验证通过
message
=
"签名验证不匹配"
;
message
=
"签名验证不匹配"
;
if
(
GConstants
.
IS_VERIFY_CONTENT_SIGN
==
false
if
(
GConstants
.
IS_VERIFY_CONTENT_SIGN
==
false
...
...
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