Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Q
queueForTicket_bl
Project
Project
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
mengmeng
queueForTicket_bl
Commits
6d37d496
Commit
6d37d496
authored
Mar 04, 2021
by
lings
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
浙里办
parent
155ab080
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1075 additions
and
4 deletions
+1075
-4
pom.xml
hmit-api/pom.xml
+18
-1
ZhelibanAPP.java
hmit-api/src/main/java/io/hmit/config/ZhelibanAPP.java
+30
-0
ZhelibanUtils.java
hmit-api/src/main/java/io/hmit/config/ZhelibanUtils.java
+584
-0
ApiLoginController.java
.../src/main/java/io/hmit/controller/ApiLoginController.java
+73
-1
AppointmentOrderController.java
...es/appointment/controller/AppointmentOrderController.java
+30
-1
YynumberDTO.java
...ain/java/io/hmit/modules/appointment/dto/YynumberDTO.java
+32
-0
AppointmentOrderService.java
.../modules/appointment/service/AppointmentOrderService.java
+2
-0
AppointmentOrderServiceImpl.java
...appointment/service/impl/AppointmentOrderServiceImpl.java
+2
-0
pom.xml
hmit-common/pom.xml
+8
-1
HttpRequestUtil.java
...n/src/main/java/io/hmit/common/utils/HttpRequestUtil.java
+211
-0
MD5.java
hmit-common/src/main/java/io/hmit/common/utils/MD5.java
+61
-0
MyX509TrustManager.java
...rc/main/java/io/hmit/common/utils/MyX509TrustManager.java
+24
-0
No files found.
hmit-api/pom.xml
View file @
6d37d496
...
@@ -17,6 +17,23 @@
...
@@ -17,6 +17,23 @@
<artifactId>
hmit-common
</artifactId>
<artifactId>
hmit-common
</artifactId>
<version>
1.0.0
</version>
<version>
1.0.0
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.60
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
<version>
2.4
</version>
</dependency>
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
<version>
2.4
</version>
<classifier>
jdk15
</classifier>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
hmit-api/src/main/java/io/hmit/config/ZhelibanAPP.java
0 → 100644
View file @
6d37d496
package
io
.
hmit
.
config
;
public
class
ZhelibanAPP
{
// 获取请求app_secret的地址
public
static
final
String
APP_REQUEST_SECRET_URL
=
"http://10.68.138.194/gateway/app/refreshTokenByKey.htm"
;
public
static
final
String
APP_KEY
=
"6465b05327cc4a41897907bf81382c29"
;
public
static
final
String
APP_SECRET
=
"fe07f9be363c46449ffae97ae2ad2bda"
;
public
static
final
String
SIGN
=
""
;
public
static
final
String
APP_ID
=
"4438763045"
;
public
static
final
String
APP_KEY_T
=
"249f09c69fe38bf51fe73976cbed2ead"
;
public
static
final
String
TOKEN_URL
=
""
;
public
static
final
String
BASE_URL
=
"http://a.com/"
;
public
static
final
String
AUTH_LOGIN_URL
=
BASE_URL
+
""
;
public
static
final
String
PUSH_MESSAGE_SIMPLE
=
BASE_URL
+
""
;
public
static
final
String
GET_USER_INFO_BY_MOBILE
=
BASE_URL
+
""
;
public
static
final
String
COMMIT_DATA
=
BASE_URL
+
""
;
//手机
public
static
final
String
SERVICE_CODE
=
"fhcjrzdpyc"
;
public
static
final
String
SERVICE_PASS
=
"fhcjrzdpycpwd"
;
public
static
final
String
APP_BASE_URL
=
"https://puser.zjzwfw.gov.cn/sso/servlet/simpleauth?method="
;
public
static
final
String
VALIDATION_TICKET
=
"ticketValidation"
;
public
static
final
String
USER_INFO
=
"getUserInfo"
;
}
hmit-api/src/main/java/io/hmit/config/ZhelibanUtils.java
0 → 100644
View file @
6d37d496
This diff is collapsed.
Click to expand it.
hmit-api/src/main/java/io/hmit/controller/ApiLoginController.java
View file @
6d37d496
...
@@ -4,7 +4,9 @@ package io.hmit.controller;
...
@@ -4,7 +4,9 @@ package io.hmit.controller;
import
io.hmit.annotation.Login
;
import
io.hmit.annotation.Login
;
import
io.hmit.common.utils.Result
;
import
io.hmit.common.utils.Result
;
import
io.hmit.common.validator.ValidatorUtils
;
import
io.hmit.common.validator.ValidatorUtils
;
import
io.hmit.config.ZhelibanUtils
;
import
io.hmit.dto.LoginDTO
;
import
io.hmit.dto.LoginDTO
;
import
io.hmit.entity.UserEntity
;
import
io.hmit.service.TokenService
;
import
io.hmit.service.TokenService
;
import
io.hmit.service.UserService
;
import
io.hmit.service.UserService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -13,7 +15,12 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -13,7 +15,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
/**
/**
* 登录接口
* 登录接口
...
@@ -53,4 +60,69 @@ public class ApiLoginController {
...
@@ -53,4 +60,69 @@ public class ApiLoginController {
return
new
Result
();
return
new
Result
();
}
}
//个人登录 - 单点登陆
@RequestMapping
(
value
=
"/check_user"
)
@ResponseBody
public
void
checkUser
(
@RequestParam
Map
<
String
,
Object
>
map
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
UnsupportedEncodingException
{
// 获取到票据信息ticket
System
.
out
.
println
(
"开始进入这个checkuser了————————————————————"
);
System
.
out
.
println
(
map
);
String
redirectUrl
=
""
;
String
Token
=
""
;
if
(
map
.
get
(
"ticket"
)
!=
null
){
System
.
out
.
println
(
"Ticket 是"
+
map
.
get
(
"ticket"
)+
"——————————————————————"
);
Map
<
String
,
Object
>
user_map
=
ZhelibanUtils
.
getUserInfo
(
map
);
System
.
out
.
println
(
"UserMap是——————————————————————————————"
);
System
.
out
.
println
(
user_map
);
if
(
user_map
.
get
(
"idnum"
)
!=
null
){
System
.
out
.
println
(
user_map
.
get
(
"idnum"
));
String
params
=
"idnum="
+
URLEncoder
.
encode
(
user_map
.
get
(
"idnum"
).
toString
(),
"UTF8"
)+
"&mobile="
+
URLEncoder
.
encode
(
user_map
.
get
(
"mobile"
).
toString
(),
"UTF8"
)+
"&username="
+
URLEncoder
.
encode
(
user_map
.
get
(
"username"
).
toString
(),
"UTF8"
);
if
(
map
.
get
(
"sp"
)
!=
null
)
{
redirectUrl
=
map
.
get
(
"sp"
)
+
"?"
+
params
;
}
//判断是否已经存在了这条信息
// UserEntity oldUser=userService.queryByIdnum(URLEncoder.encode(user_map.get("idnum").toString(), "UTF8"));
UserEntity
oldUser
=
userService
.
getUserByUserId
(
222L
);
if
(
oldUser
==
null
){
//将获得的信息保存到个人登陆表
UserEntity
user
=
new
UserEntity
();
user
.
setUsername
(
user_map
.
get
(
"username"
).
toString
());
user
.
setMobile
(
URLEncoder
.
encode
(
user_map
.
get
(
"mobile"
).
toString
(),
"UTF8"
));
user
.
setPassword
(
URLEncoder
.
encode
(
user_map
.
get
(
"idnum"
).
toString
(),
"UTF8"
));
// userService.save(user);
// //将获得的信息保存到个人信息表
// CjroneDisabledPersonEntity disabledPersonEntity=new CjroneDisabledPersonEntity();
// disabledPersonEntity.setName(user_map.get("username").toString());
// // disabledPersonEntity.setMobilePhone(URLEncoder.encode(user_map.get("mobile").toString(), "UTF8"));
// disabledPersonEntity.setIdCard(URLEncoder.encode(user_map.get("idnum").toString(), "UTF8"));
// // disabledPersonEntity.setSex(URLEncoder.encode(user_map.get("sex").toString(), "UTF8"));
// disabledPersonEntity.setPostcode(URLEncoder.encode(user_map.get("postcode").toString(), "UTF8"));
// disabledPersonEntity.setBirthday(URLEncoder.encode(user_map.get("birthday").toString(), "UTF8"));
// disabledPersonEntity.setPresentAddress(user_map.get("homeaddress").toString());
// cjroneDisabledPersonService.save(disabledPersonEntity);
}
//生成token返回
// UserEntity tbuser=userService.queryByIdnum(URLEncoder.encode(user_map.get("idnum").toString(), "UTF8"));
// Token = jwtUtils.generateToken(tbuser.getUserId());
}
}
else
{
//return R.error().put("msg","票据信息不能为空!");
if
(
map
.
get
(
"sp"
)
!=
null
)
{
redirectUrl
=
map
.
get
(
"sp"
).
toString
()+
"?1=1"
;
}
}
String
record_id
=
UUID
.
randomUUID
().
toString
();
System
.
out
.
println
(
"Url: "
+
redirectUrl
+
"&recordId="
+
record_id
+
"&token="
+
Token
);
response
.
setHeader
(
"refresh"
,
"1;URL="
+
redirectUrl
+
"&recordId="
+
record_id
+
"&token="
+
Token
);
}
}
}
hmit-api/src/main/java/io/hmit/modules/appointment/controller/AppointmentOrderController.java
View file @
6d37d496
package
io
.
hmit
.
modules
.
appointment
.
controller
;
package
io
.
hmit
.
modules
.
appointment
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.JsonObject
;
import
io.hmit.common.constant.Constant
;
import
io.hmit.common.constant.Constant
;
import
io.hmit.common.page.PageData
;
import
io.hmit.common.page.PageData
;
import
io.hmit.common.utils.DateUtils
;
import
io.hmit.common.utils.DateUtils
;
import
io.hmit.common.utils.HttpRequestUtil
;
import
io.hmit.common.utils.MD5
;
import
io.hmit.common.utils.Result
;
import
io.hmit.common.utils.Result
;
import
io.hmit.common.validator.AssertUtils
;
import
io.hmit.common.validator.AssertUtils
;
import
io.hmit.common.validator.ValidatorUtils
;
import
io.hmit.common.validator.ValidatorUtils
;
...
@@ -19,7 +23,9 @@ import io.swagger.annotations.ApiImplicitParam;
...
@@ -19,7 +23,9 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -115,8 +121,29 @@ public class AppointmentOrderController {
...
@@ -115,8 +121,29 @@ public class AppointmentOrderController {
//根据appointmentOrderId获取到订单实体
//根据appointmentOrderId获取到订单实体
AppointmentOrderDTO
appointmentOrderDTO
=
appointmentOrderService
.
get
(
appointmentOrderId
);
AppointmentOrderDTO
appointmentOrderDTO
=
appointmentOrderService
.
get
(
appointmentOrderId
);
//判断签到时间是否在预约时间前
if
(
appointmentOrderDTO
.
getAppointmentTime
().
getTime
()
>
new
Date
().
getTime
())
{
if
(
appointmentOrderDTO
.
getAppointmentTime
().
getTime
()
>
new
Date
().
getTime
())
{
String
appointmentIdCard
=
appointmentOrderDTO
.
getAppointmentIdCard
();
String
appointmentPhone
=
appointmentOrderDTO
.
getAppointmentPhone
();
String
serviceId
=
appointmentOrderDTO
.
getServiceId
().
toString
();
String
appointmentPerson
=
appointmentOrderDTO
.
getAppointmentPerson
();
String
sign
=
"hjfhsdjfueytRwYSdsa%hdf^jdshfh*KGh$e"
+
serviceId
+
new
Date
().
getTime
();
//判断签到时间是否在预约时间前
//调用取号机取号接口,获取取号信息,并更新预约号。
// http://IP:8223/smartqueue/yynumber?sQueueInfoID=24&time=1613389800&sign=ee2c3fc1bdabf439f00aa90af6a0a68f&sTel=13988888888&sName=王小二&sCardID=333111123456
String
url
=
"http://IP:8223/smartqueue/yynumber?"
+
"sQueueInfoID="
+
serviceId
+
"&time="
+
new
Date
().
getTime
()+
"&sign="
+
MD5
.
md5
(
sign
)+
"&sTel="
+
appointmentPhone
+
"&sName="
+
appointmentPerson
+
"&sCardID="
+
appointmentIdCard
;
String
Url
=
"http://www.nb-fh.cn/getAllarticleCast"
;
String
s
=
HttpRequestUtil
.
sendGetAndRetrieveContent
(
Url
);
JSONObject
json
=
JSONObject
.
parseObject
(
s
);
//根据接口返回的结果更新预约单号
appointmentOrderDTO
.
setStatus
(
2
);
appointmentOrderDTO
.
setStatus
(
2
);
appointmentOrderDTO
.
setStatusName
(
"签到"
);
appointmentOrderDTO
.
setStatusName
(
"签到"
);
appointmentOrderDTO
.
setUpdateDate
(
new
Date
());
appointmentOrderDTO
.
setUpdateDate
(
new
Date
());
...
@@ -178,4 +205,6 @@ public class AppointmentOrderController {
...
@@ -178,4 +205,6 @@ public class AppointmentOrderController {
return
new
Result
();
return
new
Result
();
}
}
}
}
hmit-api/src/main/java/io/hmit/modules/appointment/dto/YynumberDTO.java
0 → 100644
View file @
6d37d496
package
io
.
hmit
.
modules
.
appointment
.
dto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
YynumberDTO
{
/**
* nStatus : 0
* sMsg :
* sPaperNumber : Z1001
* nWait : 1
* nid : 4322
* sRegTime : 2018-12-21 13:49:21
* sQueueName : 预约-交通违法处理
* listWin : ["B03","B04","B05","B06"]
*/
private
int
nStatus
;
private
String
sMsg
;
private
String
sPaperNumber
;
private
int
nWait
;
private
int
nid
;
private
String
sRegTime
;
private
String
sCallTime
;
private
String
sQueueName
;
private
List
<
String
>
listWin
;
}
hmit-api/src/main/java/io/hmit/modules/appointment/service/AppointmentOrderService.java
View file @
6d37d496
...
@@ -21,4 +21,6 @@ public interface AppointmentOrderService extends CrudService<AppointmentOrderEnt
...
@@ -21,4 +21,6 @@ public interface AppointmentOrderService extends CrudService<AppointmentOrderEnt
Integer
serviceWaitingNum
(
Long
serviceId
);
Integer
serviceWaitingNum
(
Long
serviceId
);
}
}
hmit-api/src/main/java/io/hmit/modules/appointment/service/impl/AppointmentOrderServiceImpl.java
View file @
6d37d496
...
@@ -74,4 +74,6 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde
...
@@ -74,4 +74,6 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde
return
appointmentOrderDao
.
serviceWaitingNum
(
serviceId
)
;
return
appointmentOrderDao
.
serviceWaitingNum
(
serviceId
)
;
}
}
}
}
hmit-common/pom.xml
View file @
6d37d496
...
@@ -14,5 +14,12 @@
...
@@ -14,5 +14,12 @@
<build>
<build>
<finalName>
${project.artifactId}
</finalName>
<finalName>
${project.artifactId}
</finalName>
</build>
</build>
<dependencies>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<version>
1.2.17
</version>
</dependency>
</dependencies>
</project>
</project>
hmit-common/src/main/java/io/hmit/common/utils/HttpRequestUtil.java
0 → 100644
View file @
6d37d496
package
io
.
hmit
.
common
.
utils
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.log4j.Logger
;
import
javax.net.ssl.*
;
import
java.io.BufferedReader
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.PrintWriter
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
public
class
HttpRequestUtil
{
private
static
Logger
mailAndLyncFailLogger
=
Logger
.
getLogger
(
"MailAndLyncFailLogger"
);
/***
* 向指定URL发送POST方法的请求
* @param url 发送请求的URL
* @return URL所代表远程资源的响应
*/
public
static
int
sendGet
(
String
url
)
{
int
resultCode
=
0
;
try
{
URL
realUrl
=
new
URL
(
url
);
// 打开和URL之间的连接
HttpURLConnection
conn
=
(
HttpURLConnection
)
realUrl
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
//设置post方式连接
// 设置通用的请求属性
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
conn
.
setUseCaches
(
false
);
// 建立实际的连接
conn
.
connect
();
// 获取响应状态
resultCode
=
conn
.
getResponseCode
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
);
}
return
resultCode
;
}
/***
* 向指定URL发送GET方法的请求
* @param url 发送请求的URL
* @return URL所代表远程资源的响应
*/
public
static
String
sendGetAndRetrieveContent
(
String
url
)
{
String
result
=
null
;
StringBuffer
resultBuffer
=
new
StringBuffer
();
try
{
URL
realUrl
=
new
URL
(
url
);
// 打开和URL之间的连接
HttpURLConnection
conn
=
(
HttpURLConnection
)
realUrl
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
//设置post方式连接
// 设置通用的请求属性
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
conn
.
setUseCaches
(
false
);
// 建立实际的连接
conn
.
connect
();
// 获取响应状态
InputStream
in
=
conn
.
getInputStream
();
InputStreamReader
reader
=
new
InputStreamReader
(
in
,
"UTF-8"
);
BufferedReader
breader
=
new
BufferedReader
(
reader
);
String
str
=
null
;
while
((
str
=
breader
.
readLine
())!=
null
){
resultBuffer
.
append
(
str
);
}
breader
.
close
();
reader
.
close
();
in
.
close
();
conn
.
disconnect
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
);
}
return
result
=
resultBuffer
.
toString
();
}
/***
* 向指定URL发送POST方法的请求
* @param url 发送请求的URL
* @param param 请求参数,请求参数应该是name1=value1&name2=value2的形式
* @return URL所代表远程资源的响应
*/
public
static
int
sendPost
(
String
url
,
String
param
)
{
PrintWriter
out
=
null
;
int
resultCode
=
0
;
try
{
URL
realUrl
=
new
URL
(
url
);
mailAndLyncFailLogger
.
info
(
"realUrl:"
+
realUrl
);
mailAndLyncFailLogger
.
info
(
"param:"
+
param
);
// 打开和URL之间的连接
HttpURLConnection
conn
=
(
HttpURLConnection
)
realUrl
.
openConnection
();
conn
.
setRequestMethod
(
"POST"
);
//设置post方式连接
// 设置通用的请求属性
conn
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
// 发送POST请求必须设置如下两行
conn
.
setDoOutput
(
true
);
conn
.
setDoInput
(
true
);
conn
.
setUseCaches
(
false
);
// 获取URLConnection对象对应的输出流
out
=
new
PrintWriter
(
conn
.
getOutputStream
());
// 发送请求参数
out
.
print
(
param
);
// flush输出流的缓冲
out
.
flush
();
// 定义BufferedReader输入流来读取URL的响应
resultCode
=
conn
.
getResponseCode
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
mailAndLyncFailLogger
.
error
(
e
.
getMessage
());
}
finally
{
try
{
if
(
out
!=
null
)
{
out
.
close
();
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
mailAndLyncFailLogger
.
error
(
ex
.
getMessage
());
}
}
return
resultCode
;
}
/***
* 向指定URL发送POST方法的请求
* @param url 发送请求的URL
* @param param 请求参数,请求参数应该是name1=value1&name2=value2的形式
* @param userName 新品系统发送数据账号名
* @param passWord 新品系统发送数据账号密码
* @return URL所代表远程资源的响应
*/
public
static
int
sendPostExtend
(
String
url
,
String
param
,
String
userName
,
String
passWord
)
{
PrintWriter
out
=
null
;
int
resultCode
=
-
1
;
String
base64Str
=
null
;
String
userInfo
=
null
;
try
{
URL
realUrl
=
new
URL
(
url
);
mailAndLyncFailLogger
.
info
(
"realUrl:"
+
realUrl
);
mailAndLyncFailLogger
.
info
(
"param:"
+
param
+
"; from userName="
+
userName
);
// 打开和URL之间的连接
HttpsURLConnection
conn
=
(
HttpsURLConnection
)
realUrl
.
openConnection
();
//SSLContext sslcontext = SSLContext.getInstance("SSL","SunJSSE");
SSLContext
sslcontext
=
SSLContext
.
getInstance
(
"SSL"
);
sslcontext
.
init
(
null
,
new
TrustManager
[]{
new
MyX509TrustManager
()},
new
java
.
security
.
SecureRandom
());
HostnameVerifier
ignoreHostnameVerifier
=
new
HostnameVerifier
()
{
public
boolean
verify
(
String
s
,
SSLSession
sslsession
)
{
mailAndLyncFailLogger
.
info
(
"WARNING: Hostname is not matched for cert."
);
return
true
;
}
};
conn
.
setHostnameVerifier
(
ignoreHostnameVerifier
);
conn
.
setSSLSocketFactory
(
sslcontext
.
getSocketFactory
());
conn
.
setRequestMethod
(
"POST"
);
//设置post方式连接
// 设置通用的请求属性
conn
.
setRequestProperty
(
"Accept"
,
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
);
conn
.
setRequestProperty
(
"Accept-Language"
,
"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"
);
conn
.
setRequestProperty
(
"Accept-Encoding"
,
"gzip, deflate, br"
);
conn
.
setRequestProperty
(
"Connection"
,
"keep-alive"
);
conn
.
setRequestProperty
(
"Upgrade-Insecure-Requests"
,
"1"
);
//柳汽通 需要包含指定头部,用于临时授权
Base64
base64
=
new
Base64
();
userInfo
=
userName
+
":"
+
passWord
;
base64Str
=
base64
.
encodeToString
(
userInfo
.
getBytes
(
"UTF-8"
));
conn
.
setRequestProperty
(
"Authorization"
,
"Basic "
+
base64Str
);
// 发送POST请求必须设置如下两行
conn
.
setDoOutput
(
true
);
conn
.
setDoInput
(
true
);
conn
.
setUseCaches
(
false
);
//不校验
// conn.setHostnameVerifier(DO_NOT_VERIFY);
// 获取URLConnection对象对应的输出流
out
=
new
PrintWriter
(
conn
.
getOutputStream
());
// 发送请求参数
out
.
print
(
param
);
// flush输出流的缓冲
out
.
flush
();
// 定义BufferedReader输入流来读取URL的响应
conn
.
getResponseCode
();
resultCode
=
conn
.
getResponseCode
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
mailAndLyncFailLogger
.
error
(
e
.
getMessage
());
}
finally
{
try
{
if
(
out
!=
null
)
{
out
.
close
();
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
mailAndLyncFailLogger
.
error
(
ex
.
getMessage
());
}
}
return
resultCode
;
}
}
hmit-common/src/main/java/io/hmit/common/utils/MD5.java
0 → 100644
View file @
6d37d496
package
io
.
hmit
.
common
.
utils
;
import
sun.misc.BASE64Encoder
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
/**
* 说明:MD5处理
* 创建人:hmit
* 修改时间:
* @version
*/
public
class
MD5
{
public
static
String
md5
(
String
str
)
{
try
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
md
.
update
(
str
.
getBytes
());
byte
b
[]
=
md
.
digest
();
int
i
;
StringBuffer
buf
=
new
StringBuffer
(
""
);
for
(
int
offset
=
0
;
offset
<
b
.
length
;
offset
++)
{
i
=
b
[
offset
];
if
(
i
<
0
)
i
+=
256
;
if
(
i
<
16
)
buf
.
append
(
"0"
);
buf
.
append
(
Integer
.
toHexString
(
i
));
}
str
=
buf
.
toString
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
str
;
}
/**利用MD5进行加密
* @param str 待加密的字符串
* @return 加密后的字符串
* @throws NoSuchAlgorithmException 没有这种产生消息摘要的算法
* @throws UnsupportedEncodingException
*/
public
static
String
EncoderByMd5
(
String
str
)
throws
NoSuchAlgorithmException
,
UnsupportedEncodingException
{
//确定计算方法
MessageDigest
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
BASE64Encoder
base64en
=
new
BASE64Encoder
();
//加密后的字符串
String
newstr
=
base64en
.
encode
(
md5
.
digest
(
str
.
getBytes
(
"utf-8"
)));
return
newstr
;
}
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
,
NoSuchAlgorithmException
{
System
.
out
.
println
(
md5
(
"hjfhsdjfueytRwYSdsa%hdf^jdshfh*KGh$e241613389800"
));
System
.
out
.
println
(
md5
(
"kkk"
));
System
.
out
.
println
(
EncoderByMd5
(
"180@qq.com"
+
"123456"
));
}
}
hmit-common/src/main/java/io/hmit/common/utils/MyX509TrustManager.java
0 → 100644
View file @
6d37d496
package
io
.
hmit
.
common
.
utils
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
import
javax.net.ssl.X509TrustManager
;
public
class
MyX509TrustManager
implements
X509TrustManager
{
@Override
public
void
checkClientTrusted
(
X509Certificate
certificates
[],
String
authType
)
throws
CertificateException
{
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
ax509certificate
,
String
s
)
throws
CertificateException
{
}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
}
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