Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Skyeye云
Skyeye
提交
df91c2b8
S
Skyeye
项目概览
Skyeye云
/
Skyeye
通知
1437
Star
162
Fork
130
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Skyeye
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
df91c2b8
编写于
10月 08, 2018
作者:
Skyeye云
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加黑名单过滤
上级
f4620da8
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
163 addition
and
5 deletion
+163
-5
skyeye-common/src/main/java/com/skyeye/common/constans/Constants.java
...n/src/main/java/com/skyeye/common/constans/Constants.java
+5
-0
skyeye-common/src/main/java/com/skyeye/common/interceptor/HandlerInterceptorMain.java
...com/skyeye/common/interceptor/HandlerInterceptorMain.java
+45
-3
skyeye-common/src/main/java/com/skyeye/common/pojo/SearchItem.java
...mmon/src/main/java/com/skyeye/common/pojo/SearchItem.java
+5
-0
skyeye-common/src/main/java/com/skyeye/common/util/PropertiesUtil.java
.../src/main/java/com/skyeye/common/util/PropertiesUtil.java
+89
-0
skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java
...common/src/main/java/com/skyeye/common/util/ToolUtil.java
+15
-1
skyeye-web/src/main/resources/properties/ip.properties
skyeye-web/src/main/resources/properties/ip.properties
+2
-0
skyeye-web/src/main/webapp/toolUtil.txt
skyeye-web/src/main/webapp/toolUtil.txt
+2
-1
未找到文件。
skyeye-common/src/main/java/com/skyeye/common/constans/Constants.java
浏览文件 @
df91c2b8
...
@@ -25,6 +25,11 @@ public class Constants {
...
@@ -25,6 +25,11 @@ public class Constants {
".js"
,
".gif"
,
".jpg"
,
".eot"
,
".svg"
,
".ttf"
,
".woff"
,
".woff2"
,
".js"
,
".gif"
,
".jpg"
,
".eot"
,
".svg"
,
".ttf"
,
".woff"
,
".woff2"
,
".mp4"
,
".rmvb"
,
".avi"
,
"3gp"
,
".html"
,
".less"
,
".otf"
,
".scss"
,
".mp4"
,
".rmvb"
,
".avi"
,
"3gp"
,
".html"
,
".less"
,
".otf"
,
".scss"
,
".ico"
};
".ico"
};
/**
* IP过滤
*/
public
static
final
String
[]
FILTER_FILE_IP_OPTION
=
{
"0:0:0:0:0:0:0:1"
,
"127.0.0.1"
};
/**
/**
* 过滤器过滤请求类型项
* 过滤器过滤请求类型项
...
...
skyeye-common/src/main/java/com/skyeye/common/interceptor/HandlerInterceptorMain.java
浏览文件 @
df91c2b8
package
com.skyeye.common.interceptor
;
package
com.skyeye.common.interceptor
;
import
java.io.BufferedInputStream
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.util.Iterator
;
import
java.util.Properties
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.skyeye.common.constans.Constants
;
import
com.skyeye.common.object.ObjectConstant
;
import
com.skyeye.common.object.ObjectConstant
;
import
com.skyeye.common.object.OutputObject
;
import
com.skyeye.common.object.OutputObject
;
import
com.skyeye.common.object.PutObject
;
import
com.skyeye.common.object.PutObject
;
import
com.skyeye.common.util.ToolUtil
;
/**
/**
...
@@ -23,10 +28,47 @@ public class HandlerInterceptorMain implements HandlerInterceptor{
...
@@ -23,10 +28,47 @@ public class HandlerInterceptorMain implements HandlerInterceptor{
//在进入Handler方法之前执行
//在进入Handler方法之前执行
//用于身份认证、身份授权、
//用于身份认证、身份授权、
//比如身份认证,如果认证不通过表示当前用户没有登录,需要此方法拦截不再向下执行
//比如身份认证,
IP黑名单过滤,
如果认证不通过表示当前用户没有登录,需要此方法拦截不再向下执行
@Override
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
new
PutObject
(
request
,
response
);
new
PutObject
(
request
,
response
);
/**IP黑名单过滤开始**/
String
ip
;
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
// 针对IP是否使用代理访问进行处理
if
(
ToolUtil
.
isBlank
(
ip
)
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ToolUtil
.
isBlank
(
ip
)
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ToolUtil
.
isBlank
(
ip
)
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
}
if
(
ip
!=
null
&&
ip
.
indexOf
(
","
)
!=
-
1
)
{
ip
=
ip
.
substring
(
0
,
ip
.
indexOf
(
","
));
}
for
(
String
str
:
Constants
.
FILTER_FILE_IP_OPTION
)
{
if
(
ip
.
indexOf
(
str
)
!=
-
1
)
{
ip
=
request
.
getParameter
(
"loginPCIp"
);
break
;
}
}
Properties
prop
=
new
Properties
();
String
path
=
ToolUtil
.
getIPPropertiesPath
();
InputStream
in
=
new
BufferedInputStream
(
new
FileInputStream
(
path
));
prop
.
load
(
in
);
/// 加载属性列表
Iterator
<
String
>
it
=
prop
.
stringPropertyNames
().
iterator
();
while
(
it
.
hasNext
())
{
String
key
=
it
.
next
();
if
(
prop
.
getProperty
(
key
).
equals
(
ip
))
{
return
false
;
}
}
in
.
close
();
/**IP黑名单过滤结束**/
HttpServletRequest
servletRequest
=
(
HttpServletRequest
)
request
;
HttpServletRequest
servletRequest
=
(
HttpServletRequest
)
request
;
request
.
setCharacterEncoding
(
"UTF-8"
);
request
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
...
...
skyeye-common/src/main/java/com/skyeye/common/pojo/SearchItem.java
浏览文件 @
df91c2b8
...
@@ -4,6 +4,11 @@ import java.io.Serializable;
...
@@ -4,6 +4,11 @@ import java.io.Serializable;
public
class
SearchItem
implements
Serializable
{
public
class
SearchItem
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
String
id
;
private
String
id
;
private
String
title
;
private
String
title
;
private
String
sell_point
;
private
String
sell_point
;
...
...
skyeye-common/src/main/java/com/skyeye/common/util/PropertiesUtil.java
0 → 100644
浏览文件 @
df91c2b8
package
com.skyeye.common.util
;
import
java.io.BufferedInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.util.Iterator
;
import
java.util.Properties
;
/**
*
* @ClassName: PropertiesUtil
* @Description: 读写配置文件
* @author 卫志强
* @date 2018年10月08日
*
*/
public
class
PropertiesUtil
{
public
static
Properties
prop
=
new
Properties
();
/**
* 取出值
*
* @param k key键
* @param filepath properties文件路径
* @return
*/
public
static
String
getValue
(
String
k
,
String
filepath
)
{
InputStream
in
;
try
{
in
=
new
BufferedInputStream
(
new
FileInputStream
(
filepath
));
prop
.
load
(
in
);
/// 加载属性列表
Iterator
<
String
>
it
=
prop
.
stringPropertyNames
().
iterator
();
while
(
it
.
hasNext
())
{
String
key
=
it
.
next
();
if
(
key
.
equals
(
k
))
{
return
prop
.
getProperty
(
key
);
}
}
in
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 获取文件中的key-value的size
*
* @param filepath properties文件路径
* @return
*/
public
static
int
getPropertiesSize
(
String
filepath
)
{
InputStream
in
;
int
size
=
0
;
try
{
in
=
new
BufferedInputStream
(
new
FileInputStream
(
filepath
));
prop
.
load
(
in
);
/// 加载属性列表
Iterator
<
String
>
it
=
prop
.
stringPropertyNames
().
iterator
();
while
(
it
.
hasNext
())
{
size
++;
}
in
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
size
;
}
/**
* 设置键值
* @param filepath properties文件路径
* @param key key键
* @param value value值
*/
public
static
void
writeProperties
(
String
filepath
,
String
key
,
String
value
){
///保存属性到properties文件
FileOutputStream
oFile
;
try
{
oFile
=
new
FileOutputStream
(
filepath
,
true
);
//true表示追加打开
prop
.
setProperty
(
key
,
value
);
prop
.
store
(
oFile
,
"Update IPproperties value"
);
oFile
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java
浏览文件 @
df91c2b8
...
@@ -392,7 +392,21 @@ public class ToolUtil {
...
@@ -392,7 +392,21 @@ public class ToolUtil {
}
}
return
treeNode
;
return
treeNode
;
}
}
/**
* 获取ip.properties路径
* @return
*/
public
static
String
getIPPropertiesPath
(){
String
contextPath
=
new
Object
()
{
public
String
getPath
()
{
return
this
.
getClass
().
getResource
(
"/"
).
getPath
();
}
}.
getPath
().
substring
(
1
);
System
.
out
.
println
(
contextPath
);
String
path
=
contextPath
+
"/properties/ip.properties"
;
return
path
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
str
=
"123456"
;
String
str
=
"123456"
;
...
...
skyeye-web/src/main/resources/properties/ip.properties
0 → 100644
浏览文件 @
df91c2b8
ip1
=
0:0:0:0:0:0:0:1
ip2
=
127.0.0.1
skyeye-web/src/main/webapp/toolUtil.txt
浏览文件 @
df91c2b8
...
@@ -17,4 +17,5 @@ getProperties(); 读取.properties 结尾的配置文件用,getP, getPara
...
@@ -17,4 +17,5 @@ getProperties(); 读取.properties 结尾的配置文件用,getP, getPara
getSurFaceId(); 获取ID
getSurFaceId(); 获取ID
MD5(); 加密
MD5(); 加密
allMenuToTree(); 使用递归方法建树
allMenuToTree(); 使用递归方法建树
findChildren(); 递归查找子节点
findChildren(); 递归查找子节点
\ No newline at end of file
getIPPropertiesPath(); 获取ip.properties路径
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录