Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
e0c44221
Commit
e0c44221
authored
Jun 11, 2019
by
youjj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实名认证
parent
d381be58
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1503 additions
and
2 deletions
+1503
-2
ObjectRestResponse.java
...ithub/wxiaoqi/security/common/msg/ObjectRestResponse.java
+3
-0
ResultCode.java
...thub/wxiaoqi/security/common/util/process/ResultCode.java
+4
-0
resultcod.properties
...common/src/main/resources/properties/resultcod.properties
+10
-1
UserFeign.java
...va/com/github/wxiaoqi/security/admin/feign/UserFeign.java
+7
-0
IdInformation.java
...ava/com/xxfc/platform/universal/entity/IdInformation.java
+70
-0
CertifHttpUtils.java
...va/com/xxfc/platform/universal/utils/CertifHttpUtils.java
+311
-0
Validation.java
...in/java/com/xxfc/platform/universal/utils/Validation.java
+370
-0
pom.xml
xx-universal/xx-universal-server/pom.xml
+38
-0
UniversalApplication.java
...ava/com/xxfc/platform/universal/UniversalApplication.java
+1
-1
IdInformationBiz.java
...ava/com/xxfc/platform/universal/biz/IdInformationBiz.java
+20
-0
CertificationController.java
...latform/universal/controller/CertificationController.java
+127
-0
IdInformationMapper.java
...m/xxfc/platform/universal/mapper/IdInformationMapper.java
+16
-0
CertificationService.java
...xxfc/platform/universal/service/CertificationService.java
+457
-0
application.properties
...niversal-server/src/main/resources/application.properties
+50
-0
IdInformationMapper.xml
...-server/src/main/resources/mapper/IdInformationMapper.xml
+19
-0
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/msg/ObjectRestResponse.java
View file @
e0c44221
...
...
@@ -24,6 +24,9 @@ public class ObjectRestResponse<T> extends BaseResponse {
this
.
rel
=
rel
;
}
public
boolean
getRel
()
{
return
this
.
rel
;
}
public
ObjectRestResponse
rel
(
boolean
rel
)
{
this
.
setRel
(
rel
);
...
...
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/process/ResultCode.java
View file @
e0c44221
...
...
@@ -175,7 +175,11 @@ public class ResultCode {
// 操作失败
public
static
int
STOCK_CODE
=
Integer
.
valueOf
(
SystemProperty
.
getResultConfig
(
"STOCK_CODE"
));
public
static
int
GET_AUTH_INFO_FAILED_CODE
=
Integer
.
valueOf
(
SystemProperty
.
getResultConfig
(
"GET_AUTH_INFO_FAILED_CODE"
));
public
static
int
WRONG_FORMAT_OF_ID_CARD
=
Integer
.
valueOf
(
SystemProperty
.
getResultConfig
(
"WRONG_FORMAT_OF_ID_CARD"
));
public
static
int
INCOMPLETE_DATA
=
Integer
.
valueOf
(
SystemProperty
.
getResultConfig
(
"INCOMPLETE_DATA"
));
public
static
String
getMsg
(
int
code
)
{
return
SystemProperty
.
getResultConfig
(
String
.
valueOf
(
code
));
}
...
...
ace-common/src/main/resources/properties/resultcod.properties
View file @
e0c44221
...
...
@@ -180,4 +180,13 @@ NO_SELECT_BY_RS=1010
#还未绑定社保卡
NOT_BIND_SOCIAL_CARD
=
3010
#库存不足
STOCK_CODE
=
201
\ No newline at end of file
STOCK_CODE
=
201
#获取用户认证信息失败
GET_AUTH_INFO_FAILED_CODE
=
4004
4004
=
获取用户认证信息失败!
#证件件格式
WRONG_FORMAT_OF_ID_CARD
=
4005
4005
=
证件格式错误!
#资料不全
INCOMPLETE_DATA
=
4006
4006
=
资料不齐全!
\ No newline at end of file
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/feign/UserFeign.java
View file @
e0c44221
...
...
@@ -21,6 +21,13 @@ public interface UserFeign {
public
ObjectRestResponse
<
UserDTO
>
userinfoByToken
(
@RequestParam
(
"token"
)
String
token
);
@RequestMapping
(
value
=
"/public/app/userinfo-by-token"
)
public
ObjectRestResponse
<
AppUserDTO
>
userDetailByToken
(
@RequestParam
(
"token"
)
String
token
);
/**
*status:0-判断是否认证过,1-认证成功后修改用户认证状态
*userId:用户登录时的id,必须
*idNumber:证件号,修改认证状态是必须有
*/
@RequestMapping
(
value
=
"/api/app/user/authentication"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
authentication
(
@RequestParam
(
value
=
"userId"
)
Integer
userId
,
@RequestParam
(
value
=
"idNumber"
)
String
idNumber
,
...
...
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/entity/IdInformation.java
0 → 100644
View file @
e0c44221
package
com
.
xxfc
.
platform
.
universal
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* 证件信息表
*/
@Table
(
name
=
"app_user_login"
)
@Data
public
class
IdInformation
implements
Serializable
{
@Id
@GeneratedValue
(
generator
=
"JDBC"
)
private
Integer
id
;
//证件号
@Column
(
name
=
"id_number"
)
private
String
idNumber
;
//用户真实姓名
private
String
name
;
//用户id
@Column
(
name
=
"user_login_id"
)
private
Integer
userLonginId
;
//证件类型
@Column
(
name
=
"certificate_type"
)
private
Integer
certificateType
;
//正面url
@Column
(
name
=
"front_url"
)
private
String
frontUrl
;
//背面url
@Column
(
name
=
"back_url"
)
private
String
backUrl
;
//到期时间
@Column
(
name
=
"expiration_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyyMMdd"
,
timezone
=
"GMT+8"
)
private
Date
expirationDate
;
//认证方式
@Column
(
name
=
"authentication_methods"
)
private
Integer
authenticationMethods
;
}
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/CertifHttpUtils.java
0 → 100644
View file @
e0c44221
package
com
.
xxfc
.
platform
.
universal
.
utils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.HttpDelete
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpPut
;
import
org.apache.http.conn.ClientConnectionManager
;
import
org.apache.http.conn.scheme.Scheme
;
import
org.apache.http.conn.scheme.SchemeRegistry
;
import
org.apache.http.conn.ssl.SSLSocketFactory
;
import
org.apache.http.entity.ByteArrayEntity
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.message.BasicNameValuePair
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.security.KeyManagementException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.cert.X509Certificate
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
CertifHttpUtils
{
/**
* get
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public
static
HttpResponse
doGet
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpGet
request
=
new
HttpGet
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
return
httpClient
.
execute
(
request
);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public
static
HttpResponse
doPost
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
Map
<
String
,
String
>
bodys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPost
request
=
new
HttpPost
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
bodys
!=
null
)
{
List
<
NameValuePair
>
nameValuePairList
=
new
ArrayList
<
NameValuePair
>();
for
(
String
key
:
bodys
.
keySet
())
{
nameValuePairList
.
add
(
new
BasicNameValuePair
(
key
,
bodys
.
get
(
key
)));
}
UrlEncodedFormEntity
formEntity
=
new
UrlEncodedFormEntity
(
nameValuePairList
,
"utf-8"
);
formEntity
.
setContentType
(
"application/x-www-form-urlencoded; charset=UTF-8"
);
request
.
setEntity
(
formEntity
);
}
return
httpClient
.
execute
(
request
);
}
/**
* Post String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPost
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
String
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPost
request
=
new
HttpPost
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
StringUtils
.
isNotBlank
(
body
))
{
request
.
setEntity
(
new
StringEntity
(
body
,
"utf-8"
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPost
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
byte
[]
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPost
request
=
new
HttpPost
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
body
!=
null
)
{
request
.
setEntity
(
new
ByteArrayEntity
(
body
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Put String
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPut
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
String
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPut
request
=
new
HttpPut
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
StringUtils
.
isNotBlank
(
body
))
{
request
.
setEntity
(
new
StringEntity
(
body
,
"utf-8"
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Put stream
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPut
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
byte
[]
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPut
request
=
new
HttpPut
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
body
!=
null
)
{
request
.
setEntity
(
new
ByteArrayEntity
(
body
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public
static
HttpResponse
doDelete
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpDelete
request
=
new
HttpDelete
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
return
httpClient
.
execute
(
request
);
}
private
static
String
buildUrl
(
String
host
,
String
path
,
Map
<
String
,
String
>
querys
)
throws
UnsupportedEncodingException
{
StringBuilder
sbUrl
=
new
StringBuilder
();
sbUrl
.
append
(
host
);
if
(!
StringUtils
.
isBlank
(
path
))
{
sbUrl
.
append
(
path
);
}
if
(
null
!=
querys
)
{
StringBuilder
sbQuery
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
String
>
query
:
querys
.
entrySet
())
{
if
(
0
<
sbQuery
.
length
())
{
sbQuery
.
append
(
"&"
);
}
if
(
StringUtils
.
isBlank
(
query
.
getKey
())
&&
!
StringUtils
.
isBlank
(
query
.
getValue
()))
{
sbQuery
.
append
(
query
.
getValue
());
}
if
(!
StringUtils
.
isBlank
(
query
.
getKey
()))
{
sbQuery
.
append
(
query
.
getKey
());
if
(!
StringUtils
.
isBlank
(
query
.
getValue
()))
{
sbQuery
.
append
(
"="
);
sbQuery
.
append
(
URLEncoder
.
encode
(
query
.
getValue
(),
"utf-8"
));
}
}
}
if
(
0
<
sbQuery
.
length
())
{
sbUrl
.
append
(
"?"
).
append
(
sbQuery
);
}
}
return
sbUrl
.
toString
();
}
private
static
HttpClient
wrapClient
(
String
host
)
{
HttpClient
httpClient
=
new
DefaultHttpClient
();
if
(
host
.
startsWith
(
"https://"
))
{
sslClient
(
httpClient
);
}
return
httpClient
;
}
private
static
void
sslClient
(
HttpClient
httpClient
)
{
try
{
SSLContext
ctx
=
SSLContext
.
getInstance
(
"TLS"
);
X509TrustManager
tm
=
new
X509TrustManager
()
{
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
public
void
checkClientTrusted
(
X509Certificate
[]
xcs
,
String
str
)
{
}
public
void
checkServerTrusted
(
X509Certificate
[]
xcs
,
String
str
)
{
}
};
ctx
.
init
(
null
,
new
TrustManager
[]
{
tm
},
null
);
SSLSocketFactory
ssf
=
new
SSLSocketFactory
(
ctx
);
ssf
.
setHostnameVerifier
(
SSLSocketFactory
.
ALLOW_ALL_HOSTNAME_VERIFIER
);
ClientConnectionManager
ccm
=
httpClient
.
getConnectionManager
();
SchemeRegistry
registry
=
ccm
.
getSchemeRegistry
();
registry
.
register
(
new
Scheme
(
"https"
,
443
,
ssf
));
}
catch
(
KeyManagementException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
catch
(
NoSuchAlgorithmException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
\ No newline at end of file
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/Validation.java
0 → 100644
View file @
e0c44221
package
com
.
xxfc
.
platform
.
universal
.
utils
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* 验证工具类
* 用正则表达式校验电话号码、身份证号、日期格式、URL、Email等等格式的工具类
* @author admin
*
*/
public
class
Validation
{
//------------------常量定义
/**
* Email正则表达式="^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
*/
//public static final String EMAIL = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";;
public
static
final
String
EMAIL
=
"\\w+(\\.\\w+)*@\\w+(\\.\\w+)+"
;
/**
* 电话号码正则表达式= (^(\d{2,4}[-_-—]?)?\d{3,8}([-_-—]?\d{3,8})?([-_-—]?\d{1,7})?$)|(^0?1[35]\d{9}$)
*/
public
static
final
String
PHONE
=
"(^(\\d{2,4}[-_-—]?)?\\d{3,8}([-_-—]?\\d{3,8})?([-_-—]?\\d{1,7})?$)|(^0?1[35]\\d{9}$)"
;
/**
* 手机号码正则表达式=^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9])\d{8}$
*/
public
static
final
String
MOBILE
=
"^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9])\\d{8}$"
;
/**
* Integer正则表达式 ^-?(([1-9]\d*$)|0)
*/
public
static
final
String
INTEGER
=
"^-?(([1-9]\\d*$)|0)"
;
/**
* 正整数正则表达式 >=0 ^[1-9]\d*|0$
*/
public
static
final
String
INTEGER_NEGATIVE
=
"^[1-9]\\d*|0$"
;
/**
* 负整数正则表达式 <=0 ^-[1-9]\d*|0$
*/
public
static
final
String
INTEGER_POSITIVE
=
"^-[1-9]\\d*|0$"
;
/**
* Double正则表达式 ^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$
*/
public
static
final
String
DOUBLE
=
"^-?([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0)$"
;
/**
* 正Double正则表达式 >=0 ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$
*/
public
static
final
String
DOUBLE_NEGATIVE
=
"^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0$"
;
/**
* 负Double正则表达式 <= 0 ^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$
*/
public
static
final
String
DOUBLE_POSITIVE
=
"^(-([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*))|0?\\.0+|0$"
;
/**
* 年龄正则表达式 ^(?:[1-9][0-9]?|1[01][0-9]|120)$ 匹配0-120岁
*/
public
static
final
String
AGE
=
"^(?:[1-9][0-9]?|1[01][0-9]|120)$"
;
/**
* 邮编正则表达式 [0-9]\d{5}(?!\d) 国内6位邮编
*/
public
static
final
String
CODE
=
"[0-9]\\d{5}(?!\\d)"
;
/**
* 匹配由数字、26个英文字母或者下划线组成的字符串 ^\w+$
*/
public
static
final
String
STR_ENG_NUM_
=
"^\\w+$"
;
/**
* 匹配由数字和26个英文字母组成的字符串 ^[A-Za-z0-9]+$
*/
public
static
final
String
STR_ENG_NUM
=
"^[A-Za-z0-9]+"
;
/**
* 匹配由26个英文字母组成的字符串 ^[A-Za-z]+$
*/
public
static
final
String
STR_ENG
=
"^[A-Za-z]+$"
;
/**
* 过滤特殊字符串正则
* regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
*/
public
static
final
String
STR_SPECIAL
=
"[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"
;
/***
* 日期正则 支持:
* YYYY-MM-DD
* YYYY/MM/DD
* YYYY_MM_DD
* YYYYMMDD
* YYYY.MM.DD的形式
*/
public
static
final
String
DATE_ALL
=
"((^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._]?)(10|12|0?[13578])([-\\/\\._]?)(3[01]|[12][0-9]|0?[1-9])$)"
+
"|(^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._]?)(11|0?[469])([-\\/\\._]?)(30|[12][0-9]|0?[1-9])$)"
+
"|(^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._]?)(0?2)([-\\/\\._]?)(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\\/\\._]?)(0?2)([-\\/\\._]?)(29)$)|(^([3579][26]00)"
+
"([-\\/\\._]?)(0?2)([-\\/\\._]?)(29)$)"
+
"|(^([1][89][0][48])([-\\/\\._]?)(0?2)([-\\/\\._]?)(29)$)|(^([2-9][0-9][0][48])([-\\/\\._]?)"
+
"(0?2)([-\\/\\._]?)(29)$)"
+
"|(^([1][89][2468][048])([-\\/\\._]?)(0?2)([-\\/\\._]?)(29)$)|(^([2-9][0-9][2468][048])([-\\/\\._]?)(0?2)"
+
"([-\\/\\._]?)(29)$)|(^([1][89][13579][26])([-\\/\\._]?)(0?2)([-\\/\\._]?)(29)$)|"
+
"(^([2-9][0-9][13579][26])([-\\/\\._]?)(0?2)([-\\/\\._]?)(29)$))"
;
/***
* 日期正则 支持:
* YYYY-MM-DD
*/
public
static
final
String
DATE_FORMAT1
=
"(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)"
;
/**
* URL正则表达式
* 匹配 http www ftp
*/
public
static
final
String
URL
=
"^(http|www|ftp|)?(://)?(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*((:\\d+)?)(/(\\w+(-\\w+)*))*(\\.?(\\w)*)(\\?)?"
+
"(((\\w*%)*(\\w*\\?)*(\\w*:)*(\\w*\\+)*(\\w*\\.)*(\\w*&)*(\\w*-)*(\\w*=)*(\\w*%)*(\\w*\\?)*"
+
"(\\w*:)*(\\w*\\+)*(\\w*\\.)*"
+
"(\\w*&)*(\\w*-)*(\\w*=)*)*(\\w*)*)$"
;
/**
* 身份证正则表达式
*/
public
static
final
String
IDCARD
=
"((11|12|13|14|15|21|22|23|31|32|33|34|35|36|37|41|42|43|44|45|46|50|51|52|53|54|61|62|63|64|65)[0-9]{4})"
+
"(([1|2][0-9]{3}[0|1][0-9][0-3][0-9][0-9]{3}"
+
"[Xx0-9])|([0-9]{2}[0|1][0-9][0-3][0-9][0-9]{3}))"
;
/**
* 机构代码
*/
public
static
final
String
JIGOU_CODE
=
"^[A-Z0-9]{8}-[A-Z0-9]$"
;
/**
* 匹配数字组成的字符串 ^[0-9]+$
*/
public
static
final
String
STR_NUM
=
"^[0-9]+$"
;
////------------------验证方法
/**
* 判断字段是否为空 符合返回ture
* @param str
* @return boolean
*/
public
static
synchronized
boolean
StrisNull
(
String
str
)
{
return
null
==
str
||
str
.
trim
().
length
()
<=
0
?
true
:
false
;
}
/**
* 判断字段是非空 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
StrNotNull
(
String
str
)
{
return
!
StrisNull
(
str
)
;
}
/**
* 字符串null转空
* @param str
* @return boolean
*/
public
static
String
nulltoStr
(
String
str
)
{
return
StrisNull
(
str
)?
""
:
str
;
}
/**
* 字符串null赋值默认值
* @param str 目标字符串
* @param defaut 默认值
* @return String
*/
public
static
String
nulltoStr
(
String
str
,
String
defaut
)
{
return
StrisNull
(
str
)?
defaut:
str
;
}
/**
* 判断字段是否为Email 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isEmail
(
String
str
)
{
return
Regular
(
str
,
EMAIL
);
}
/**
* 判断是否为电话号码 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isPhone
(
String
str
)
{
return
Regular
(
str
,
PHONE
);
}
/**
* 判断是否为手机号码 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isMobile
(
String
str
)
{
return
Regular
(
str
,
MOBILE
);
}
/**
* 判断是否为Url 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isUrl
(
String
str
)
{
return
Regular
(
str
,
URL
);
}
/**
* 判断字段是否为数字 正负整数 正负浮点数 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isNumber
(
String
str
)
{
return
Regular
(
str
,
DOUBLE
);
}
/**
* 判断字段是否为INTEGER 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isInteger
(
String
str
)
{
return
Regular
(
str
,
INTEGER
);
}
/**
* 判断字段是否为正整数正则表达式 >=0 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isINTEGER_NEGATIVE
(
String
str
)
{
return
Regular
(
str
,
INTEGER_NEGATIVE
);
}
/**
* 判断字段是否为负整数正则表达式 <=0 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isINTEGER_POSITIVE
(
String
str
)
{
return
Regular
(
str
,
INTEGER_POSITIVE
);
}
/**
* 判断字段是否为DOUBLE 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isDouble
(
String
str
)
{
return
Regular
(
str
,
DOUBLE
);
}
/**
* 判断字段是否为正浮点数正则表达式 >=0 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isDOUBLE_NEGATIVE
(
String
str
)
{
return
Regular
(
str
,
DOUBLE_NEGATIVE
);
}
/**
* 判断字段是否为负浮点数正则表达式 <=0 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isDOUBLE_POSITIVE
(
String
str
)
{
return
Regular
(
str
,
DOUBLE_POSITIVE
);
}
/**
* 判断字段是否为日期 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isDate
(
String
str
)
{
return
Regular
(
str
,
DATE_ALL
);
}
/**
* 验证2010-12-10
* @param str
* @return
*/
public
static
boolean
isDate1
(
String
str
)
{
return
Regular
(
str
,
DATE_FORMAT1
);
}
/**
* 判断字段是否为年龄 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isAge
(
String
str
)
{
return
Regular
(
str
,
AGE
)
;
}
/**
* 判断字段是否超长
* 字串为空返回fasle, 超过长度{leng}返回ture 反之返回false
* @param str
* @param leng
* @return boolean
*/
public
static
boolean
isLengOut
(
String
str
,
int
leng
)
{
return
StrisNull
(
str
)?
false
:
str
.
trim
().
length
()
>
leng
;
}
/**
* 判断字段是否为身份证 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isIdCard
(
String
str
)
{
if
(
StrisNull
(
str
))
return
false
;
if
(
str
.
trim
().
length
()
==
15
||
str
.
trim
().
length
()
==
18
)
{
return
Regular
(
str
,
IDCARD
);
}
else
{
return
false
;
}
}
/**
* 判断字段是否为邮编 符合返回ture
* @param str
* @return boolean
*/
public
static
boolean
isCode
(
String
str
)
{
return
Regular
(
str
,
CODE
)
;
}
/**
* 判断字符串是不是全部是英文字母
* @param str
* @return boolean
*/
public
static
boolean
isEnglish
(
String
str
)
{
return
Regular
(
str
,
STR_ENG
)
;
}
/**
* 判断字符串是不是全部是英文字母+数字
* @param str
* @return boolean
*/
public
static
boolean
isENG_NUM
(
String
str
)
{
return
Regular
(
str
,
STR_ENG_NUM
)
;
}
/**
* 判断字符串是不是全部是英文字母+数字+下划线
* @param str
* @return boolean
*/
public
static
boolean
isENG_NUM_
(
String
str
)
{
return
Regular
(
str
,
STR_ENG_NUM_
)
;
}
/**
* 过滤特殊字符串 返回过滤后的字符串
* @param str
* @return boolean
*/
public
static
String
filterStr
(
String
str
)
{
Pattern
p
=
Pattern
.
compile
(
STR_SPECIAL
);
Matcher
m
=
p
.
matcher
(
str
);
return
m
.
replaceAll
(
""
).
trim
();
}
/**
* 校验机构代码格式
* @return
*/
public
static
boolean
isJigouCode
(
String
str
){
return
Regular
(
str
,
JIGOU_CODE
)
;
}
/**
* 判断字符串是不是数字组成
* @param str
* @return boolean
*/
public
static
boolean
isSTR_NUM
(
String
str
)
{
return
Regular
(
str
,
STR_NUM
)
;
}
/**
* 匹配是否符合正则表达式pattern 匹配返回true
* @param str 匹配的字符串
* @param pattern 匹配模式
* @return boolean
*/
private
static
boolean
Regular
(
String
str
,
String
pattern
){
if
(
null
==
str
||
str
.
trim
().
length
()<=
0
)
return
false
;
Pattern
p
=
Pattern
.
compile
(
pattern
);
Matcher
m
=
p
.
matcher
(
str
);
return
m
.
matches
();
}
}
\ No newline at end of file
xx-universal/xx-universal-server/pom.xml
View file @
e0c44221
...
...
@@ -28,6 +28,44 @@
<artifactId>
aliyun-java-sdk-dysmsapi
</artifactId>
<version>
1.1.0
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
4.5.10
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
<dependency>
<groupId>
org.eclipse.jetty
</groupId>
<artifactId>
jetty-util
</artifactId>
<version>
9.3.7.v20160115
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
4.5.10
</version>
</dependency>
<dependency>
<groupId>
com.github.wxiaoqi
</groupId>
<artifactId>
ace-admin-api
</artifactId>
<version>
2.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
<build>
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/UniversalApplication.java
View file @
e0c44221
...
...
@@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAceCache
@EnableTransactionManagement
@tk
.
mybatis
.
spring
.
annotation
.
MapperScan
(
basePackages
=
"com.xxfc.platform.universal.mapper"
)
@EnableFeignClients
({
"com.github.wxiaoqi.security.auth.client.feign"
,
"com.xxfc.platform"
})
@EnableFeignClients
({
"com.github.wxiaoqi.security.auth.client.feign"
,
"com.xxfc.platform"
,
"com.github.wxiaoqi.security.admin.feign"
})
public
class
UniversalApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/IdInformationBiz.java
0 → 100644
View file @
e0c44221
package
com
.
xxfc
.
platform
.
universal
.
biz
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.xxfc.platform.universal.entity.IdInformation
;
import
com.xxfc.platform.universal.mapper.IdInformationMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-08 16:23
*/
@Service
@Slf4j
public
class
IdInformationBiz
extends
BaseBiz
<
IdInformationMapper
,
IdInformation
>
{
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/CertificationController.java
0 → 100644
View file @
e0c44221
package
com
.
xxfc
.
platform
.
universal
.
controller
;
import
com.alibaba.druid.util.StringUtils
;
import
com.github.wxiaoqi.security.admin.feign.UserFeign
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.universal.entity.IdInformation
;
import
com.xxfc.platform.universal.service.CertificationService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
@RestController
@RequestMapping
(
"certif"
)
public
class
CertificationController
{
@Autowired
private
CertificationService
certificationService
;
@Autowired
private
UserFeign
userFeign
;
@PostMapping
(
"/str"
)
public
ObjectRestResponse
stringCertificate
(
@RequestBody
IdInformation
idInformation
,
HttpServletRequest
request
)
{
if
(
idInformation
==
null
)
{
ObjectRestResponse
.
createDefaultFail
();
}
String
token
=
request
.
getHeader
(
"Authorization"
);
if
(
StringUtils
.
isEmpty
(
token
))
{
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
RSTOKEN_NULL_CODE
,
"token为空"
);
}
//获得用户信息
ObjectRestResponse
<
UserDTO
>
userDTOObjectRestResponse
=
userFeign
.
userinfoByToken
(
token
);
if
(
userDTOObjectRestResponse
==
null
||
userDTOObjectRestResponse
.
getData
()==
null
||
userDTOObjectRestResponse
.
getData
().
getId
()==
0
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
GET_APPUSER_FAILED_CODE
,
"获取用户失败"
);
}
UserDTO
userDTO
=
userDTOObjectRestResponse
.
getData
();
idInformation
.
setUserLonginId
(
userDTO
.
getId
());
//获取用户认证信息
ObjectRestResponse
orr
=
userFeign
.
authentication
(
idInformation
.
getUserLonginId
(),
null
,
0
);
if
(
orr
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
GET_AUTH_INFO_FAILED_CODE
,
"获取用户认证信息失败"
);
}
if
(!
orr
.
getRel
()){
return
orr
;
}
Integer
am
=
idInformation
.
getAuthenticationMethods
();
Integer
type
=
idInformation
.
getCertificateType
();
if
(
type
==
0
||
am
==
0
){
return
certificationService
.
stringCertificate
(
idInformation
);
}
if
(
type
==
0
||
am
==
1
){
return
certificationService
.
imageCertificate
(
idInformation
);
}
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
SUCCESS_CODE
,
"该证件件或方式,暂时不能进行实名认证"
);
}
//
// //请求参数jsone对象后台Map接收
// //字段
// // frontImage:正面身份证照片地址,
// // backImage:反面身份证照片地址
// @PostMapping("/image")
// public ObjectRestResponse imageCertificate(@RequestBody IdInformation idInformation, HttpServletRequest request) {
//
//
// String token = request.getHeader("Authorization");
// Integer uid = certificationService.getUid(token);
//
// idInformation.setUserLonginId(uid);
//
// Map resultMap= certificationService.imageCertificate(idInformation);
// ObjectRestResponse orr = new ObjectRestResponse().rel((Boolean) resultMap.get("rel"));
//
// if (!(Boolean) resultMap.get("rel")){
// return (ObjectRestResponse) orr.data(resultMap.get("data")).msg("FAILED").status(ResultCode.FAILED_CODE);
//
// }
// return orr;
// }
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/mapper/IdInformationMapper.java
0 → 100644
View file @
e0c44221
package
com
.
xxfc
.
platform
.
universal
.
mapper
;
import
com.xxfc.platform.universal.entity.IdInformation
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Options
;
import
org.apache.ibatis.annotations.Select
;
import
org.springframework.stereotype.Repository
;
import
tk.mybatis.mapper.common.Mapper
;
@Repository
public
interface
IdInformationMapper
extends
Mapper
<
IdInformation
>
{
@Insert
(
value
=
"insert into id_information (user_login_id,name,id_number,certificate_type,front_url,back_url,expiration_date,authentication_methods) "
+
"values (#{userLonginId},#{name},#{idNumber},#{certificateType},#{frontUrl},#{backUrl},#{expirationDate},#{authenticationMethods})"
)
void
addIdInformation
(
IdInformation
idInformation
);
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/CertificationService.java
0 → 100644
View file @
e0c44221
package
com
.
xxfc
.
platform
.
universal
.
service
;
import
cn.hutool.core.map.MapUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.admin.feign.UserFeign
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.universal.biz.IdInformationBiz
;
import
com.xxfc.platform.universal.entity.IdInformation
;
import
com.xxfc.platform.universal.mapper.IdInformationMapper
;
import
com.xxfc.platform.universal.utils.CertifHttpUtils
;
import
com.xxfc.platform.universal.utils.Validation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.map.HashedMap
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.StatusLine
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
@Service
@Slf4j
public
class
CertificationService
{
/**
* 认证相关的数据
*/
@Value
(
"${certif.cHost}"
)
private
String
cHost
;
@Value
(
"${certif.cPath}"
)
private
String
cPath
;
@Value
(
"${certif.cMethod}"
)
private
String
cMethod
;
@Value
(
"${certif.cAppcode}"
)
private
String
cAppcode
;
//请求:身份证号字段名
@Value
(
"${certif.idCardName}"
)
private
String
idCardName
;
//请求:用户姓名字段名
@Value
(
"${certif.cName}"
)
private
String
cName
;
//响应:认证错误码字段名
@Value
(
"${certif.certifRet}"
)
private
String
certifRet
;
//响应:认证通过码
@Value
(
"${certif.certifResultCode}"
)
private
String
certifResultCode
;
/**
* 图片解析相关的数据
*/
//认证借口host
@Value
(
"${certif.iHost}"
)
private
String
iHost
;
//认证接口path
@Value
(
"${certif.iPath}"
)
private
String
iPath
;
//请求方式
@Value
(
"${certif.iMethod}"
)
private
String
iMethod
;
//认证AppCode(接口商家提供)
@Value
(
"${certif.iAppcode}"
)
private
String
iAppcode
;
//请求:图片url字段名
@Value
(
"${certif.picName}"
)
private
String
picName
;
//请求:方向字段名
@Value
(
"${certif.typeName}"
)
private
String
typeName
;
//请求:反面图片标识
@Value
(
"${certif.frontParameter}"
)
private
String
frontParameter
;
//请求:反面图片标识
@Value
(
"${certif.backParameter}"
)
private
String
backParameter
;
//响应:解析错误码字段名
@Value
(
"${certif.imageRet}"
)
private
String
imageRet
;
//响应:图片解析错误码
@Value
(
"${certif.imageResultCode}"
)
private
String
imageResultCode
;
//响应:响应内容字段名
@Value
(
"${certif.dataNam}"
)
private
String
dataNam
;
//响应:正面身份证号字段名
@Value
(
"${certif.numberName}"
)
private
String
numberName
;
//响应:正面姓名字段名
@Value
(
"${certif.iName}"
)
private
String
iName
;
//响应:背面到期时间字段名
@Value
(
"${certif.expirationDateName}"
)
private
String
expirationDateName
;
@Autowired
private
IdInformationMapper
idInformationMapper
;
@Autowired
private
UserFeign
userFeign
;
//身份证号+姓名认证
public
ObjectRestResponse
stringCertificate
(
IdInformation
idInformation
)
{
HashedMap
hashMap
=
new
HashedMap
();
// 认证状态:true是认证过
Integer
certificateType
=
idInformation
.
getCertificateType
();
if
(
certificateType
==
0
)
{
if
(!
Validation
.
isIdCard
(
idInformation
.
getIdNumber
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
WRONG_FORMAT_OF_ID_CARD
,
"身份证格式错误"
);
}
}
if
(
idInformation
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"未填写"
);
}
if
(
idInformation
.
getExpirationDate
()
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请填写证件到期时间"
);
}
//判断是否有填写身份证号
if
(
StringUtils
.
isBlank
(
idInformation
.
getIdNumber
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请填写身份证号"
);
}
//判断是有否填写名字
if
(
StringUtils
.
isBlank
(
idInformation
.
getName
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请填写姓名"
);
}
//获取查询参数
Map
<
String
,
String
>
querys
=
new
HashMap
<
String
,
String
>();
querys
.
put
(
idCardName
,
idInformation
.
getIdNumber
());
querys
.
put
(
cName
,
idInformation
.
getName
());
//认证
String
result
=
certificate
(
querys
);
System
.
out
.
println
(
result
);
//判断返回的值是否为空
if
(!
StringUtils
.
isBlank
(
result
))
{
Map
<
String
,
String
>
resultMap
=
(
Map
<
String
,
String
>)
JSONObject
.
parse
(
result
);
if
(
resultMap
!=
null
)
{
//认证成功
if
(
certifResultCode
.
equals
(
resultMap
.
get
(
certifRet
)))
{
Boolean
aBoolean
=
addIdInformation
(
idInformation
);
if
(
aBoolean
)
{
return
ObjectRestResponse
.
succ
();
}
}
}
}
return
ObjectRestResponse
.
createDefaultFail
();
}
// 身份证图片进行实名认证
public
ObjectRestResponse
imageCertificate
(
IdInformation
idInformation
)
{
//1.判断
//携带返回参数的map
HashedMap
hashMap
=
new
HashedMap
();
// 认证状态:true是认证过
//判断是否map是否为null
if
(
idInformation
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请上传证件照"
);
}
//判断是否有正面照片
if
(
StringUtils
.
isBlank
(
idInformation
.
getFrontUrl
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请上传正面照"
);
}
//判断是否有背面照片
if
(
StringUtils
.
isBlank
(
idInformation
.
getBackUrl
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请上传背面照"
);
}
//2.解析
//正面进行解析
String
front
=
imageParse
(
idInformation
.
getFrontUrl
(),
frontParameter
);
Map
frontMap
=
(
Map
)
JSONObject
.
parse
(
front
);
//反面进行解析
String
back
=
imageParse
(
idInformation
.
getBackUrl
(),
backParameter
);
Map
backMap
=
(
Map
)
JSONObject
.
parse
(
back
);
Map
frontData
=
(
Map
)
frontMap
.
get
(
dataNam
);
Map
backData
=
(
Map
)
backMap
.
get
(
dataNam
);
//判断是否调用图片解析的接口是否异常,若果两个次认证都没结果
if
(
MapUtil
.
isEmpty
(
frontMap
)
||
MapUtil
.
isEmpty
(
backMap
)
||
!(
frontMap
.
get
(
imageRet
).
equals
(
imageResultCode
))
||
MapUtil
.
isEmpty
(
frontData
)
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"正面照认证失败"
);
}
if
(
MapUtil
.
isEmpty
(
frontMap
)
||
MapUtil
.
isEmpty
(
backMap
)
||
!(
backMap
.
get
(
imageRet
).
equals
(
imageResultCode
))
||
MapUtil
.
isEmpty
(
backData
)
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"背面照认证失败"
);
}
//图片解析没问提,进行身份认证
;
Map
<
String
,
String
>
authMap
=
new
HashMap
<>();
authMap
.
put
(
idCardName
,
(
String
)
frontData
.
get
(
numberName
));
authMap
.
put
(
cName
,
(
String
)
frontData
.
get
(
cName
));
//3.认证
String
result
=
certificate
(
authMap
);
//认证返回的参数是否为空
if
(!
StringUtils
.
isBlank
(
result
))
{
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
JSONObject
.
parse
(
result
);
System
.
out
.
println
(
map
.
get
(
certifRet
));
if
(
MapUtil
.
isNotEmpty
(
map
)
||
certifResultCode
.
equals
(
map
.
get
(
certifRet
)))
{
//认证成功后存入保存到数据库
//获得身份证正面记录的身份证号和真实姓名
//设置姓名
idInformation
.
setName
((
String
)
frontData
.
get
(
iName
));
//设置身份证号
idInformation
.
setIdNumber
((
String
)
frontData
.
get
(
numberName
));
//获得到期时间
String
endDate
=
(
String
)
backData
.
get
(
expirationDateName
);
System
.
out
.
println
(
endDate
);
if
(
StringUtils
.
isBlank
(
endDate
))
{
return
ObjectRestResponse
.
succ
();
}
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
formatter
.
setLenient
(
false
);
Date
expirationDate
=
null
;
try
{
expirationDate
=
formatter
.
parse
(
endDate
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
createDefaultFail
();
}
idInformation
.
setExpirationDate
(
expirationDate
);
Boolean
aBoolean
=
addIdInformation
(
idInformation
);
if
(
aBoolean
)
{
return
ObjectRestResponse
.
succ
();
}
}
}
return
ObjectRestResponse
.
succ
();
}
//认证
public
String
certificate
(
Map
<
String
,
String
>
querys
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
"APPCODE "
+
cAppcode
);
//
//
try
{
System
.
out
.
println
(
querys
);
HttpResponse
response
=
CertifHttpUtils
.
doGet
(
cHost
,
cPath
,
cMethod
,
headers
,
querys
);
StatusLine
statusLine
=
response
.
getStatusLine
();
int
statusCode
=
statusLine
.
getStatusCode
();
//状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误
//获取response的body
if
(
statusCode
==
200
)
{
return
EntityUtils
.
toString
(
response
.
getEntity
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
//身份证照片解析
public
String
imageParse
(
String
imageUrl
,
String
type
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
headers
.
put
(
"Authorization"
,
"APPCODE "
+
iAppcode
);
Map
<
String
,
String
>
querys
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
bodys
=
new
HashMap
<
String
,
String
>();
bodys
.
put
(
picName
,
imageUrl
);
//默认正面front,背面请传back
bodys
.
put
(
typeName
,
type
);
try
{
HttpResponse
response
=
CertifHttpUtils
.
doPost
(
iHost
,
iPath
,
iMethod
,
headers
,
querys
,
bodys
);
StatusLine
statusLine
=
response
.
getStatusLine
();
int
statusCode
=
statusLine
.
getStatusCode
();
System
.
out
.
println
(
statusCode
);
//状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误
//获取response的body
if
(
statusCode
==
200
)
{
return
EntityUtils
.
toString
(
response
.
getEntity
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
//认证通过保存到数据库当中
public
Boolean
addIdInformation
(
IdInformation
idInformation
)
{
System
.
out
.
println
(
idInformation
);
//保存认证信息
try
{
idInformationMapper
.
addIdInformation
(
idInformation
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
false
;
}
//认证成功后修改用户,用户认证状态
ObjectRestResponse
authentication
=
userFeign
.
authentication
(
idInformation
.
getUserLonginId
(),
idInformation
.
getIdNumber
(),
1
);
return
authentication
.
getRel
();
}
}
xx-universal/xx-universal-server/src/main/resources/application.properties
0 → 100644
View file @
e0c44221
#\u8BA4\u8BC1\u63A5\u53E3\u9700\u8981\u643A\u5E26\u7684\u53C2\u6570
#A\u8BA4\u8BC1
certif.cHost
=
https://idcert.market.alicloudapi.com
certif.cPath
=
/idcard
certif.cMethod
=
GET
certif.cAppcode
=
acea1c8811f748b3a65815f11db357c4
#1.\u8BF7\u6C42
#\u8EAB\u4EFD\u8BC1\u53F7\u5B57\u6BB5\u540D\u79F0
certif.idCardName
=
idCard
#\u59D3\u540D\u5B57\u6BB5\u540D\u79F0
certif.cName
=
name
#2.\u54CD\u5E94
#\u9519\u8BEF\u7801\u5B57\u6BB5\u540D
certif.certifRet
=
status
#\u8BA4\u8BC1\u6210\u529F\u7801
certif.certifResultCode
=
01
#B\u56FE\u7247\u89E3\u6790
certif.iHost
=
https://ocridcard.market.alicloudapi.com
certif.iPath
=
/idimages
certif.iMethod
=
POST
certif.iAppcode
=
acea1c8811f748b3a65815f11db357c4
#1.\u8BF7\u6C42
#\u56FE\u7247url\u5B57\u6BB5\u540D
certif.picName
=
image
#\u65B9\u5411\u5B57\u6BB5\u540D
certif.typeName
=
idCardSide
#\u56FE\u7247\u6B63\u9762\u6807\u8BC6\u53C2\u6570
certif.frontParameter
=
front
#\u56FE\u7247\u80CC\u9762\u6807\u8BC6\u53C2\u6570
certif.backParameter
=
back
#2.\u54CD\u5E94
#\u56FE\u7247\u89E3\u6790\u54CD\u5E94\u643A\u5E26\u9519\u8BEF\u7801\u5B57\u6BB5\u540D
certif.imageRet
=
code
#\u56FE\u7247\u89E3\u6790\u6210\u529F\u7801
certif.imageResultCode
=
1
#\u5185\u5BB9\u5B57\u6BB5\u540D
certif.dataNam
=
result
#\u8EAB\u4EFD\u8BC1\u53F7\u5B57\u6BB5\u540D
certif.numberName
=
code
#\u7528\u6237\u59D3\u540D\u5B57\u6BB5\u540D
certif.iName
=
name
#\u8EAB\u4EFD\u8BC1\u5230\u671F\u65F6\u95F4\u5B57\u6BB5\u540D
certif.expirationDateName
=
expiryDate
xx-universal/xx-universal-server/src/main/resources/mapper/IdInformationMapper.xml
0 → 100644
View file @
e0c44221
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxfc.platform.universal.mapper.IdInformationMapper"
>
<resultMap
type=
"com.xxfc.platform.universal.entity.IdInformation"
id=
"IdInformation"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"idNumber"
column=
"id_number"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"userLonginId"
column=
"user_login_id"
/>
<result
property=
"certificateType"
column=
"certificate_type"
/>
<result
property=
"frontUrl"
column=
"front_url"
/>
<result
property=
"backUrl"
column=
"back_url"
/>
<result
property=
"expirationDate"
column=
"expiration_date"
/>
<result
property=
"authenticationMethods"
column=
"authentication_methods"
/>
</resultMap>
</mapper>
\ No newline at end of file
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