Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
3941a160
提交
3941a160
authored
8月 27, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
second commit
上级
99628d31
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
1173 行增加
和
2 行删除
+1173
-2
pom.xml
pom.xml
+18
-0
SecurityConfiguration.java
...com/example/afrishop_v3/config/SecurityConfiguration.java
+3
-2
SearchController.java
...com/example/afrishop_v3/controllers/SearchController.java
+3
-0
TbCfSearch.java
src/main/java/com/example/afrishop_v3/models/TbCfSearch.java
+4
-0
TbCfSearchRepository.java
.../example/afrishop_v3/repository/TbCfSearchRepository.java
+2
-0
AppInfo.java
src/main/java/com/example/afrishop_v3/util/AppInfo.java
+80
-0
BaseState.java
src/main/java/com/example/afrishop_v3/util/BaseState.java
+88
-0
Encoder.java
src/main/java/com/example/afrishop_v3/util/Encoder.java
+24
-0
IdUtil.java
src/main/java/com/example/afrishop_v3/util/IdUtil.java
+50
-0
ListUtil.java
src/main/java/com/example/afrishop_v3/util/ListUtil.java
+32
-0
MessageUtil.java
src/main/java/com/example/afrishop_v3/util/MessageUtil.java
+9
-0
RandomCodeHelper.java
...n/java/com/example/afrishop_v3/util/RandomCodeHelper.java
+22
-0
SortUtil.java
src/main/java/com/example/afrishop_v3/util/SortUtil.java
+73
-0
SpringContextUtil.java
.../java/com/example/afrishop_v3/util/SpringContextUtil.java
+51
-0
State.java
src/main/java/com/example/afrishop_v3/util/State.java
+18
-0
TestBigDecimal.java
...ain/java/com/example/afrishop_v3/util/TestBigDecimal.java
+11
-0
URLUtils.java
src/main/java/com/example/afrishop_v3/util/URLUtils.java
+23
-0
ValidateUtils.java
...main/java/com/example/afrishop_v3/util/ValidateUtils.java
+559
-0
X509TM.java
src/main/java/com/example/afrishop_v3/util/X509TM.java
+44
-0
XmlUtil.java
src/main/java/com/example/afrishop_v3/util/XmlUtil.java
+59
-0
没有找到文件。
pom.xml
浏览文件 @
3941a160
...
...
@@ -56,6 +56,24 @@
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<!--<version>3.8</version>-->
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib -->
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
<version>
2.4
</version>
<classifier>
jdk15
</classifier>
<exclusions>
<exclusion>
<artifactId>
commons-lang
</artifactId>
<groupId>
commons-lang
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
src/main/java/com/example/afrishop_v3/config/SecurityConfiguration.java
浏览文件 @
3941a160
...
...
@@ -7,9 +7,10 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
@Configuration
@EnableWebSecurity
public
class
SecurityConfiguration
extends
WebSecurityConfigurerAdapter
{
public
class
SecurityConfiguration
extends
WebSecurityConfigurerAdapter
{
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
().
antMatchers
(
"/"
).
permitAll
();
http
.
csrf
().
disable
().
authorizeRequests
().
anyRequest
().
permitAll
();
}
}
src/main/java/com/example/afrishop_v3/controllers/SearchController.java
浏览文件 @
3941a160
...
...
@@ -4,6 +4,7 @@ import com.example.afrishop_v3.base.Result;
import
com.example.afrishop_v3.enums.ResultCodeEnum
;
import
com.example.afrishop_v3.models.TbCfSearch
;
import
com.example.afrishop_v3.repository.TbCfSearchRepository
;
import
com.example.afrishop_v3.util.IdUtil
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -20,6 +21,8 @@ public class SearchController {
@PostMapping
(
"/save"
)
public
Result
save
(
@RequestBody
TbCfSearch
tbCfSearch
)
{
tbCfSearch
.
setId
(
IdUtil
.
createIdbyUUID
());
TbCfSearch
entity
=
repository
.
save
(
tbCfSearch
);
return
new
Result
<>(
entity
);
...
...
src/main/java/com/example/afrishop_v3/models/TbCfSearch.java
浏览文件 @
3941a160
...
...
@@ -70,5 +70,9 @@ public class TbCfSearch {
public
String
getUserId
()
{
return
userId
;
}
public
TbCfUserInfo
getUserInfo
()
{
return
userInfo
;
}
}
src/main/java/com/example/afrishop_v3/repository/TbCfSearchRepository.java
浏览文件 @
3941a160
...
...
@@ -4,11 +4,13 @@ import com.example.afrishop_v3.models.TbCfSearch;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
public
interface
TbCfSearchRepository
extends
PagingAndSortingRepository
<
TbCfSearch
,
String
>
{
List
<
TbCfSearch
>
getAllByUserId
(
String
userId
);
@Transactional
void
deleteAllByIdIn
(
String
[]
ids
);
}
src/main/java/com/example/afrishop_v3/util/AppInfo.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
public
final
class
AppInfo
{
public
static
final
int
SUCCESS
=
0
;
public
static
final
int
MAX_SIZE
=
1
;
public
static
final
int
PERMISSION_DENIED
=
2
;
public
static
final
int
FAILED_CREATE_FILE
=
3
;
public
static
final
int
IO_ERROR
=
4
;
public
static
final
int
NOT_MULTIPART_CONTENT
=
5
;
public
static
final
int
PARSE_REQUEST_ERROR
=
6
;
public
static
final
int
NOTFOUND_UPLOAD_DATA
=
7
;
public
static
final
int
NOT_ALLOW_FILE_TYPE
=
8
;
public
static
final
int
INVALID_ACTION
=
101
;
public
static
final
int
CONFIG_ERROR
=
102
;
public
static
final
int
PREVENT_HOST
=
201
;
public
static
final
int
CONNECTION_ERROR
=
202
;
public
static
final
int
REMOTE_FAIL
=
203
;
public
static
final
int
NOT_DIRECTORY
=
301
;
public
static
final
int
NOT_EXIST
=
302
;
public
static
final
int
ILLEGAL
=
401
;
public
static
Map
<
Integer
,
String
>
info
=
new
HashMap
<
Integer
,
String
>();
static
{
info
.
put
(
AppInfo
.
SUCCESS
,
"SUCCESS"
);
// 无效的Action
info
.
put
(
AppInfo
.
INVALID_ACTION
,
"\u65E0\u6548\u7684Action"
);
// 配置文件初始化失败
info
.
put
(
AppInfo
.
CONFIG_ERROR
,
"\u914D\u7F6E\u6587\u4EF6\u521D\u59CB\u5316\u5931\u8D25"
);
// 抓取远程图片失败
info
.
put
(
AppInfo
.
REMOTE_FAIL
,
"\u6293\u53D6\u8FDC\u7A0B\u56FE\u7247\u5931\u8D25"
);
// 被阻止的远程主机
info
.
put
(
AppInfo
.
PREVENT_HOST
,
"\u88AB\u963B\u6B62\u7684\u8FDC\u7A0B\u4E3B\u673A"
);
// 远程连接出错
info
.
put
(
AppInfo
.
CONNECTION_ERROR
,
"\u8FDC\u7A0B\u8FDE\u63A5\u51FA\u9519"
);
// "文件大小超出限制"
info
.
put
(
AppInfo
.
MAX_SIZE
,
"\u6587\u4ef6\u5927\u5c0f\u8d85\u51fa\u9650\u5236"
);
// 权限不足, 多指写权限
info
.
put
(
AppInfo
.
PERMISSION_DENIED
,
"\u6743\u9650\u4E0D\u8DB3"
);
// 创建文件失败
info
.
put
(
AppInfo
.
FAILED_CREATE_FILE
,
"\u521B\u5EFA\u6587\u4EF6\u5931\u8D25"
);
// IO错误
info
.
put
(
AppInfo
.
IO_ERROR
,
"IO\u9519\u8BEF"
);
// 上传表单不是multipart/form-data类型
info
.
put
(
AppInfo
.
NOT_MULTIPART_CONTENT
,
"\u4E0A\u4F20\u8868\u5355\u4E0D\u662Fmultipart/form-data\u7C7B\u578B"
);
// 解析上传表单错误
info
.
put
(
AppInfo
.
PARSE_REQUEST_ERROR
,
"\u89E3\u6790\u4E0A\u4F20\u8868\u5355\u9519\u8BEF"
);
// 未找到上传数据
info
.
put
(
AppInfo
.
NOTFOUND_UPLOAD_DATA
,
"\u672A\u627E\u5230\u4E0A\u4F20\u6570\u636E"
);
// 不允许的文件类型
info
.
put
(
AppInfo
.
NOT_ALLOW_FILE_TYPE
,
"\u4E0D\u5141\u8BB8\u7684\u6587\u4EF6\u7C7B\u578B"
);
// 指定路径不是目录
info
.
put
(
AppInfo
.
NOT_DIRECTORY
,
"\u6307\u5B9A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55"
);
// 指定路径并不存在
info
.
put
(
AppInfo
.
NOT_EXIST
,
"\u6307\u5B9A\u8DEF\u5F84\u5E76\u4E0D\u5B58\u5728"
);
// callback参数名不合法
info
.
put
(
AppInfo
.
ILLEGAL
,
"Callback\u53C2\u6570\u540D\u4E0D\u5408\u6CD5"
);
}
public
static
String
getStateInfo
(
int
key
)
{
return
AppInfo
.
info
.
get
(
key
);
}
}
src/main/java/com/example/afrishop_v3/util/BaseState.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
public
class
BaseState
implements
State
{
private
boolean
state
=
false
;
private
String
info
=
null
;
private
Map
<
String
,
String
>
infoMap
=
new
HashMap
<
String
,
String
>();
public
BaseState
()
{
this
.
state
=
true
;
}
public
BaseState
(
boolean
state
)
{
this
.
setState
(
state
);
}
public
BaseState
(
boolean
state
,
String
info
)
{
this
.
setState
(
state
);
this
.
info
=
info
;
}
public
BaseState
(
boolean
state
,
int
infoCode
)
{
this
.
setState
(
state
);
this
.
info
=
AppInfo
.
getStateInfo
(
infoCode
);
}
public
boolean
isSuccess
()
{
return
this
.
state
;
}
public
void
setState
(
boolean
state
)
{
this
.
state
=
state
;
}
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
public
void
setInfo
(
int
infoCode
)
{
this
.
info
=
AppInfo
.
getStateInfo
(
infoCode
);
}
@Override
public
String
toJSONString
()
{
return
this
.
toString
();
}
public
String
toString
()
{
String
key
=
null
;
String
stateVal
=
this
.
isSuccess
()
?
AppInfo
.
getStateInfo
(
AppInfo
.
SUCCESS
)
:
this
.
info
;
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"{\"state\": \""
+
stateVal
+
"\""
);
Iterator
<
String
>
iterator
=
this
.
infoMap
.
keySet
().
iterator
();
while
(
iterator
.
hasNext
()
)
{
key
=
iterator
.
next
();
builder
.
append
(
",\""
+
key
+
"\": \""
+
this
.
infoMap
.
get
(
key
)
+
"\""
);
}
builder
.
append
(
"}"
);
return
Encoder
.
toUnicode
(
builder
.
toString
()
);
}
@Override
public
void
putInfo
(
String
name
,
String
val
)
{
this
.
infoMap
.
put
(
name
,
val
);
}
@Override
public
void
putInfo
(
String
name
,
long
val
)
{
this
.
putInfo
(
name
,
val
+
""
);
}
}
src/main/java/com/example/afrishop_v3/util/Encoder.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
public
class
Encoder
{
public
static
String
toUnicode
(
String
input
)
{
StringBuilder
builder
=
new
StringBuilder
();
char
[]
chars
=
input
.
toCharArray
();
for
(
char
ch
:
chars
)
{
if
(
ch
<
256
)
{
builder
.
append
(
ch
);
}
else
{
builder
.
append
(
"\\u"
+
Integer
.
toHexString
(
ch
&
0xffff
)
);
}
}
return
builder
.
toString
();
}
}
\ No newline at end of file
src/main/java/com/example/afrishop_v3/util/IdUtil.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.UUID
;
/**
* ID 生成工具类<br>
*/
public
class
IdUtil
{
/**
* 主要功能:生成流水号 yyyyMMddHHmmssSSS + 3位随机数
* 注意事项:无
*
* @return 流水号
*/
public
static
String
createIdByDate
()
{
// 精确到毫秒
SimpleDateFormat
fmt
=
new
SimpleDateFormat
(
"yyyyMMddHHmmssSSS"
);
String
suffix
=
fmt
.
format
(
new
Date
());
suffix
=
suffix
+
Math
.
round
((
Math
.
random
()
*
100000
));
return
suffix
;
}
/**
* 主要功能:生成流水号 yyyyMMddHHmmssSSS + 3位随机数
* 注意事项:不能超出long类型取值范围 9223372036854775807
*
* @return 流水号
*/
public
static
long
createLongIdByDate
()
{
// 精确到毫秒
SimpleDateFormat
fmt
=
new
SimpleDateFormat
(
"yyyyMMddHHmmssSSS"
);
String
suffix
=
fmt
.
format
(
new
Date
());
String
prefix
=
String
.
valueOf
(
Math
.
round
(
Math
.
random
()
*
100
));
return
Long
.
valueOf
(
suffix
+
prefix
);
}
/**
* 主要功能:生成uuid
* 注意事项:无
*
* @return uuid 32 位
*/
public
static
String
createIdbyUUID
()
{
return
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
}
}
src/main/java/com/example/afrishop_v3/util/ListUtil.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
java.util.List
;
/**
* @Auther: wudepeng
* @Date: 2019/11/23
* @Description:
*/
public
class
ListUtil
{
public
static
List
<
String
>
pageBySubList
(
List
list
,
int
pageNum
,
int
pageSize
)
{
int
totalcount
=
list
.
size
();
int
pagecount
=
0
;
List
<
String
>
subList
;
int
m
=
totalcount
%
pageSize
;
if
(
m
>
0
)
{
pagecount
=
totalcount
/
pageSize
+
1
;
}
else
{
pagecount
=
totalcount
/
pageSize
;
}
if
(
m
==
0
)
{
subList
=
list
.
subList
((
pageNum
-
1
)
*
pageSize
,
pageSize
*
(
pageNum
));
}
else
{
if
(
pageNum
==
pagecount
)
{
subList
=
list
.
subList
((
pageNum
-
1
)
*
pageSize
,
totalcount
);
}
else
{
subList
=
list
.
subList
((
pageNum
-
1
)
*
pageSize
,
pageSize
*
(
pageNum
));
}
}
return
subList
;
}
}
src/main/java/com/example/afrishop_v3/util/MessageUtil.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
/**
* @Auther: wudepeng
* @Date: 2019/12/04
* @Description:
*/
public
class
MessageUtil
{
}
src/main/java/com/example/afrishop_v3/util/RandomCodeHelper.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
/**
* 获取指定长度的验证码
*
* @author 何明胜
*
* 2017年10月27日
*/
public
class
RandomCodeHelper
{
public
static
int
producedRandomCode
(
double
length
)
{
int
randomCode
=
(
int
)(
Math
.
random
()
*
Math
.
pow
(
10
,
length
));
//进制系统,这里是10进制
int
decimalSystem
=
10
;
while
(
randomCode
<
Math
.
pow
(
decimalSystem
,
length
-
1
)
||
randomCode
>=
Math
.
pow
(
decimalSystem
,
length
))
{
randomCode
=
(
int
)(
Math
.
random
()
*
Math
.
pow
(
10
,
length
));
}
return
randomCode
;
}
}
\ No newline at end of file
src/main/java/com/example/afrishop_v3/util/SortUtil.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.security.MessageDigest
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.SortedMap
;
public
class
SortUtil
{
/**
* 微信支付签名算法sign
* @param parameters
* @return
*/
public
static
String
createSign
(
SortedMap
<
String
,
Object
>
parameters
,
String
charset
)
throws
UnsupportedEncodingException
{
StringBuffer
sb
=
new
StringBuffer
();
Set
es
=
parameters
.
entrySet
();
//所有参与传参的参数按照accsii排序(升序)
Iterator
it
=
es
.
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
entry
=
(
Map
.
Entry
)
it
.
next
();
String
k
=
(
String
)
entry
.
getKey
();
Object
v
=
entry
.
getValue
();
if
(
null
!=
v
&&
!
""
.
equals
(
v
))
{
v
=
URLEncoder
.
encode
(
v
+
""
,
charset
);
sb
.
append
(
k
+
"="
+
v
+
"&"
);
}
}
sb
.
append
(
"app_key="
);
sb
.
append
(
"uKdEuLIyWu3juHG1"
);
/*sb.append("app_key=");
sb.append("QSz7yUSdnKROdc5k");*/
// System.out.println("签名MD5未变大写:" + MD5Util.MD5Encode(sb.toString(), characterEncoding));
String
sign
=
md5Password
(
sb
.
toString
()).
toUpperCase
();
return
sign
;
}
/**
* 生成32位md5码
*
* @param key
* @return
*/
public
static
String
md5Password
(
String
key
)
{
char
hexDigits
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
try
{
byte
[]
btInput
=
key
.
getBytes
();
// 获得MD5摘要算法的 MessageDigest 对象
MessageDigest
mdInst
=
MessageDigest
.
getInstance
(
"MD5"
);
// 使用指定的字节更新摘要
mdInst
.
update
(
btInput
);
// 获得密文
byte
[]
md
=
mdInst
.
digest
();
// 把密文转换成十六进制的字符串形式
int
j
=
md
.
length
;
char
str
[]
=
new
char
[
j
*
2
];
int
k
=
0
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
byte
byte0
=
md
[
i
];
str
[
k
++]
=
hexDigits
[
byte0
>>>
4
&
0xf
];
str
[
k
++]
=
hexDigits
[
byte0
&
0xf
];
}
return
new
String
(
str
);
}
catch
(
Exception
e
)
{
return
null
;
}
}
}
src/main/java/com/example/afrishop_v3/util/SpringContextUtil.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
@Component
public
class
SpringContextUtil
implements
ApplicationContextAware
{
private
static
ApplicationContext
applicationContext
;
// Spring应用上下文环境
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
SpringContextUtil
.
applicationContext
=
applicationContext
;
}
public
static
ApplicationContext
getApplicationContext
()
{
return
applicationContext
;
}
public
static
Object
getBean
(
String
name
)
throws
BeansException
{
return
applicationContext
.
getBean
(
name
);
}
public
static
Object
getBean
(
String
name
,
Class
requiredType
)
throws
BeansException
{
return
applicationContext
.
getBean
(
name
,
requiredType
);
}
public
static
boolean
containsBean
(
String
name
)
{
return
applicationContext
.
containsBean
(
name
);
}
public
static
boolean
isSingleton
(
String
name
)
throws
NoSuchBeanDefinitionException
{
return
applicationContext
.
isSingleton
(
name
);
}
public
static
Class
getType
(
String
name
)
throws
NoSuchBeanDefinitionException
{
return
applicationContext
.
getType
(
name
);
}
public
static
String
[]
getAliases
(
String
name
)
throws
NoSuchBeanDefinitionException
{
return
applicationContext
.
getAliases
(
name
);
}
}
src/main/java/com/example/afrishop_v3/util/State.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
/**
* 处理状态接口
* @author hancong03@baidu.com
*
*/
public
interface
State
{
public
boolean
isSuccess
();
public
void
putInfo
(
String
name
,
String
val
);
public
void
putInfo
(
String
name
,
long
val
);
public
String
toJSONString
();
}
src/main/java/com/example/afrishop_v3/util/TestBigDecimal.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
public
class
TestBigDecimal
{
public
static
void
main
(
String
[]
args
)
{
// BigDecimal decimal=new BigDecimal("3858");
// BigDecimal de=new BigDecimal("100");
// BigDecimal price = decimal.divide(de, 2, BigDecimal.ROUND_HALF_UP);
// System.out.println(price);
}
}
src/main/java/com/example/afrishop_v3/util/URLUtils.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
javax.servlet.http.HttpServletRequest
;
public
class
URLUtils
{
public
static
String
getBaseURl
(
HttpServletRequest
request
)
{
String
scheme
=
request
.
getScheme
();
String
serverName
=
request
.
getServerName
();
int
serverPort
=
request
.
getServerPort
();
String
contextPath
=
request
.
getContextPath
();
StringBuffer
url
=
new
StringBuffer
();
url
.
append
(
scheme
).
append
(
"://"
).
append
(
serverName
);
if
((
serverPort
!=
80
)
&&
(
serverPort
!=
443
))
{
url
.
append
(
":"
).
append
(
serverPort
);
}
url
.
append
(
contextPath
);
if
(
url
.
toString
().
endsWith
(
"/"
)){
url
.
append
(
"/"
);
}
return
url
.
toString
();
}
}
\ No newline at end of file
src/main/java/com/example/afrishop_v3/util/ValidateUtils.java
0 → 100644
浏览文件 @
3941a160
差异被折叠。
点击展开。
src/main/java/com/example/afrishop_v3/util/X509TM.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
javax.net.ssl.X509TrustManager
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
/**
*
* @author mds
* @DateTime 2018年4月25日 下午2:16:17
* @Comment 证书信任管理类
*/
public
class
X509TM
implements
X509TrustManager
{
/**
* 检查客户端的证书,若不信任该证书则抛出异常
*/
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
// TODO Auto-generated method stub
}
/**
* 检查服务器的证书,若不信任该证书同样抛出异常,如果是空函数体,则信任所有证书
*/
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
// TODO Auto-generated method stub
}
/**
* 返回受信任的X509证书数组。
*/
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
// TODO Auto-generated method stub
return
null
;
}
}
src/main/java/com/example/afrishop_v3/util/XmlUtil.java
0 → 100644
浏览文件 @
3941a160
package
com
.
example
.
afrishop_v3
.
util
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.Element
;
import
org.dom4j.io.SAXReader
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
*
* @author mds
* @DateTime 2018年4月25日 上午11:30:01
* @Comment xml工具类
*/
public
class
XmlUtil
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
XmlUtil
.
class
);
/**
* @author mds
* @DateTime 2018年4月25日 上午11:32:59
* @serverComment
* xml转Map
*
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
static
Map
<
String
,
String
>
xmlToMap
(
InputStream
ins
){
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
SAXReader
reader
=
new
SAXReader
();
Document
doc
=
null
;
try
{
doc
=
reader
.
read
(
ins
);
Element
root
=
doc
.
getRootElement
();
List
<
Element
>
list
=
root
.
elements
();
for
(
Element
e
:
list
)
{
map
.
put
(
e
.
getName
(),
e
.
getText
());
}
return
map
;
}
catch
(
DocumentException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
try
{
ins
.
close
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
return
null
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论