初始化
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
import com.chinaums.open.api.constants.ConfigBean;
|
||||
import com.chinaums.open.api.internal.util.OpenApiLogger;
|
||||
import com.chinaums.open.api.internal.util.http.HttpTransport;
|
||||
import com.chinaums.open.api.parser.json.ObjectJsonParser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 14:22
|
||||
* 所属模块:
|
||||
* 功能说明:开放平台客户端
|
||||
*/
|
||||
public class DefaultOpenApiClient implements OpenApiClient {
|
||||
private static final String constant_classname=DefaultOpenApiClient.class.getSimpleName();
|
||||
/**
|
||||
* 开放平台URL
|
||||
*/
|
||||
private String serverUrl;
|
||||
/**
|
||||
* appId
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* appKey
|
||||
*/
|
||||
private String appKey;
|
||||
/**
|
||||
* 字符集格式
|
||||
*/
|
||||
private String encodeCharSet;
|
||||
|
||||
public DefaultOpenApiClient(String serverUrl, String appId, String appKey) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.appId = appId;
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
public DefaultOpenApiClient(String serverUrl, String appId, String appKey, String encodeCharSet) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.appId = appId;
|
||||
this.appKey = appKey;
|
||||
this.encodeCharSet = encodeCharSet;
|
||||
}
|
||||
|
||||
public <T extends OpenApiResponse> T execute(OpenApiRequest<T> openApiRequest) throws OpenApiException {
|
||||
return execute(openApiRequest,null,null);
|
||||
}
|
||||
|
||||
public <T extends OpenApiResponse> T execute(OpenApiRequest<T> openApiRequest, String token) throws OpenApiException {
|
||||
return execute(openApiRequest,token,null);
|
||||
}
|
||||
|
||||
public <T extends OpenApiResponse> T execute(OpenApiRequest<T> openApiRequest, String token,String encodeCharSet) throws OpenApiException {
|
||||
OpenApiParser<T> openApiParser = new ObjectJsonParser<T>(openApiRequest.responseClass());
|
||||
return execute_(openApiRequest,openApiParser,token,encodeCharSet);
|
||||
}
|
||||
|
||||
public <T extends OpenApiResponse> T execute_(OpenApiRequest<T> openApiRequest,OpenApiParser<T> openApiParser,String token,String encodeCharSet){
|
||||
ConfigBean configBean = new ConfigBean();
|
||||
OpenApiContext context = new OpenApiContext();
|
||||
T trsp = null;
|
||||
String response = "";
|
||||
try {
|
||||
if(StringUtils.isBlank(serverUrl)) throw new OpenApiException("通讯地址未设置");
|
||||
if(StringUtils.isBlank(appId)) throw new OpenApiException("开发者appId未设置");
|
||||
if(StringUtils.isBlank(appKey)) throw new OpenApiException("开发者appKey未设置");
|
||||
String request = openApiParser.validRequest(openApiRequest);
|
||||
context.setStartTime(System.currentTimeMillis());
|
||||
context.setRequestId(UUID.randomUUID().toString().replace("-",""));
|
||||
context.setOpenServUrl(serverUrl);
|
||||
String url = serverUrl.concat(openApiRequest.apiVersion()).concat(openApiRequest.serviceCode());
|
||||
context.setApiServiceUrl(url);
|
||||
context.setApiMethodName(openApiRequest.apiMethodName());
|
||||
context.setVersion(openApiRequest.apiVersion());
|
||||
context.setAppId(appId);
|
||||
context.setAppKey(appKey);
|
||||
context.setConfigBean(configBean);
|
||||
context.setServiceCode(openApiRequest.serviceCode());
|
||||
if(openApiRequest.needToken()){
|
||||
OpenApiCache.getCurrentToken(context);
|
||||
response = HttpTransport.getInstance().doPost(context,request);
|
||||
}else{
|
||||
response = HttpTransport.getInstance().doPost(configBean.isProd(),url,token,request);
|
||||
}
|
||||
if(StringUtils.isBlank(response)) throw new OpenApiException("服务提供方未返回");
|
||||
if(StringUtils.isNotBlank(encodeCharSet)){
|
||||
//encodeCharSet = configBean.getCharSet();
|
||||
trsp = openApiParser.parse(new String(response.getBytes(),encodeCharSet));
|
||||
}else{
|
||||
trsp = openApiParser.parse(response);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError(constant_classname +" SDK异常:"+e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
}
|
||||
context.setEndTime(System.currentTimeMillis());
|
||||
return trsp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
import com.chinaums.open.api.internal.util.OpenTokenUtil;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/6
|
||||
* Time: 11:01
|
||||
* 所属模块:
|
||||
* 功能说明:cache缓存
|
||||
*/
|
||||
public class OpenApiCache {
|
||||
|
||||
public final static int MAX_PROCESS_TIMEOUT = 3600;
|
||||
|
||||
public static Cache<String, Object> contextCache = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(MAX_PROCESS_TIMEOUT, TimeUnit.SECONDS).build();
|
||||
|
||||
/**
|
||||
* 获取当前有效的token
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static TokenResponse getCurrentToken(OpenApiContext context){
|
||||
String appId = context.getAppId();
|
||||
TokenResponse token = (TokenResponse)contextCache.getIfPresent(appId);
|
||||
if(token==null){
|
||||
token = OpenTokenUtil.getToken(context);
|
||||
contextCache.put(context.getAppId(), token);
|
||||
}
|
||||
context.setCurrentToken(token);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 14:18
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public abstract interface OpenApiClient {
|
||||
public abstract <T extends OpenApiResponse> T execute(OpenApiRequest<T> openApiRequest) throws OpenApiException;
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
import com.chinaums.open.api.constants.ConfigBean;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/6
|
||||
* Time: 10:17
|
||||
* 所属模块:
|
||||
* 功能说明:api 处理报文上下文
|
||||
*/
|
||||
public class OpenApiContext {
|
||||
private String requestId;
|
||||
private TokenResponse currentToken;
|
||||
private long startTime;
|
||||
private long endTime;
|
||||
private String request;
|
||||
private String response;
|
||||
private Map<String,Object> params;
|
||||
private String apiMethodName;
|
||||
private String serviceCode;
|
||||
private String openServUrl;
|
||||
private String version;
|
||||
private String appId;
|
||||
private String appKey;
|
||||
private ConfigBean configBean;
|
||||
private String apiServiceUrl;
|
||||
public String getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
public void setRequestId(String requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public TokenResponse getCurrentToken() {
|
||||
return currentToken;
|
||||
}
|
||||
|
||||
public void setCurrentToken(TokenResponse currentToken) {
|
||||
this.currentToken = currentToken;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(String request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public String getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public String getServiceCode() {
|
||||
return serviceCode;
|
||||
}
|
||||
|
||||
public void setServiceCode(String serviceCode) {
|
||||
this.serviceCode = serviceCode;
|
||||
}
|
||||
|
||||
public String getApiMethodName() {
|
||||
return apiMethodName;
|
||||
}
|
||||
|
||||
public void setApiMethodName(String apiMethodName) {
|
||||
this.apiMethodName = apiMethodName;
|
||||
}
|
||||
|
||||
public String getOpenServUrl() {
|
||||
return openServUrl;
|
||||
}
|
||||
|
||||
public void setOpenServUrl(String openServUrl) {
|
||||
this.openServUrl = openServUrl;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
public ConfigBean getConfigBean() {
|
||||
return configBean;
|
||||
}
|
||||
|
||||
public void setConfigBean(ConfigBean configBean) {
|
||||
this.configBean = configBean;
|
||||
}
|
||||
|
||||
public String getApiServiceUrl() {
|
||||
return apiServiceUrl;
|
||||
}
|
||||
|
||||
public void setApiServiceUrl(String apiServiceUrl) {
|
||||
this.apiServiceUrl = apiServiceUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 10:11
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class OpenApiException extends Exception implements Serializable{
|
||||
private String errCode;
|
||||
private String errInfo;
|
||||
public OpenApiException() {}
|
||||
|
||||
public OpenApiException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public OpenApiException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public OpenApiException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public OpenApiException(String errCode, String errInfo)
|
||||
{
|
||||
super(errCode + ":" + errInfo);
|
||||
this.errCode = errCode;
|
||||
this.errInfo = errInfo;
|
||||
}
|
||||
|
||||
public String getErrCode()
|
||||
{
|
||||
return this.errCode;
|
||||
}
|
||||
|
||||
public String getErrMsg()
|
||||
{
|
||||
return this.errInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 14:27
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public abstract interface OpenApiParser<T extends OpenApiResponse> {
|
||||
/**
|
||||
* 返回内容格式转换
|
||||
* @param paramString
|
||||
* @return
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
public abstract T parse(String paramString) throws OpenApiException;
|
||||
|
||||
/**
|
||||
* 请求参数检查
|
||||
* @param openApiRequest
|
||||
* @return
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
public abstract String validRequest(OpenApiRequest<T> openApiRequest) throws OpenApiException;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
/**
|
||||
* Created by ZHANGWEI on 2016/12/2.
|
||||
*/
|
||||
public abstract interface OpenApiRequest<T extends OpenApiResponse> {
|
||||
public abstract Class<T> responseClass();
|
||||
/*
|
||||
api版本号
|
||||
*/
|
||||
public abstract String apiVersion();
|
||||
/*
|
||||
api接口名称定义
|
||||
*/
|
||||
public abstract String apiMethodName();
|
||||
/*
|
||||
开放平台分配servicecode
|
||||
*/
|
||||
public abstract String serviceCode();
|
||||
|
||||
/*
|
||||
是否需要获取token
|
||||
*/
|
||||
public abstract boolean needToken();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.chinaums.open.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by ZHANGWEI on 2016/12/2.
|
||||
*/
|
||||
public abstract class OpenApiResponse implements Serializable{
|
||||
private String errCode;
|
||||
private String errInfo;
|
||||
|
||||
public String getErrCode() {
|
||||
return errCode;
|
||||
}
|
||||
|
||||
public void setErrCode(String errCode) {
|
||||
this.errCode = errCode;
|
||||
}
|
||||
|
||||
public String getErrInfo() {
|
||||
return errInfo;
|
||||
}
|
||||
|
||||
public void setErrInfo(String errInfo) {
|
||||
this.errInfo = errInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.chinaums.open.api.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Created by ZHANGWEI on 2016/12/2.
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApiField {
|
||||
String key() default "";
|
||||
String name() default "";
|
||||
boolean required() default false;
|
||||
int length() default -1;
|
||||
int minLength() default -1;
|
||||
int maxLength() default -1;
|
||||
String index() default "0";
|
||||
String desc() default "";
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.chinaums.open.api.constants;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/4
|
||||
* Time: 21:22
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class ConfigBean {
|
||||
/*
|
||||
字符集格式
|
||||
*/
|
||||
private String charSet = "UTF-8";
|
||||
/*
|
||||
是否是生产环境
|
||||
*/
|
||||
private boolean isProd = false;
|
||||
|
||||
private String version = "v2";
|
||||
/**
|
||||
* token申请失效后,重试次数
|
||||
*/
|
||||
private int tokenAcquireReties = 3;
|
||||
/**
|
||||
* token提前申请的时间
|
||||
*/
|
||||
private int tokenAcquireAheadInterval = 600;
|
||||
/*
|
||||
获取token servicecode
|
||||
*/
|
||||
private String tokenServiceCode="/token/access";
|
||||
|
||||
public String getCharSet() {
|
||||
return charSet;
|
||||
}
|
||||
|
||||
public void setCharSet(String charSet) {
|
||||
this.charSet = charSet;
|
||||
}
|
||||
|
||||
public boolean isProd() {
|
||||
return isProd;
|
||||
}
|
||||
|
||||
public void setProd(boolean prod) {
|
||||
isProd = prod;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public int getTokenAcquireReties() {
|
||||
return tokenAcquireReties;
|
||||
}
|
||||
|
||||
public void setTokenAcquireReties(int tokenAcquireReties) {
|
||||
this.tokenAcquireReties = tokenAcquireReties;
|
||||
}
|
||||
|
||||
public int getTokenAcquireAheadInterval() {
|
||||
return tokenAcquireAheadInterval;
|
||||
}
|
||||
|
||||
public void setTokenAcquireAheadInterval(int tokenAcquireAheadInterval) {
|
||||
this.tokenAcquireAheadInterval = tokenAcquireAheadInterval;
|
||||
}
|
||||
|
||||
public String getTokenServiceCode() {
|
||||
return tokenServiceCode;
|
||||
}
|
||||
|
||||
public void setTokenServiceCode(String tokenServiceCode) {
|
||||
this.tokenServiceCode = tokenServiceCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.chinaums.open.api.constants;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/5
|
||||
* Time: 18:46
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class Constants {
|
||||
public static class ERR_CODE {
|
||||
public static final String NORMAL = "0000";
|
||||
public static final String ILLEGAL_CALL = "9000";
|
||||
public static final String ILLEGAL_PARAMETER = "9001";
|
||||
public static final String FATAL = "9999";
|
||||
}
|
||||
public static class ERR_INFO {
|
||||
public static final String NORMAL = "正常";
|
||||
public static final String ILLEGAL_CALL = "非法访问";
|
||||
public static final String ILLEGAL_PARAMETER = "请求参数校验失败";
|
||||
public static final String FATAL = "系统错误";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Project:TODO ADD PROJECT NAME
|
||||
* Modify Information:
|
||||
* ================================================================
|
||||
* Author Date Description
|
||||
* ------------ ---------- --------------------------------
|
||||
* wmshen 2022/10/20 TODO:
|
||||
* ================================================================
|
||||
* Copyright (c) 银联商务股份有限公司 www.chinaums.com
|
||||
*/
|
||||
package com.chinaums.open.api.internal.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Desc: TODO ADD DESC
|
||||
* <p>
|
||||
* Function:
|
||||
* <dl>
|
||||
* <dt>核心功能点1</dt>
|
||||
* <dd>核心功能点1说明</dd>
|
||||
* <dt>核心功能点2</dt>
|
||||
* <dd>核心功能点2说明</dd>
|
||||
* </dl>
|
||||
*
|
||||
* @app <服务名称英文缩写>
|
||||
* @layer <代码所在分层>
|
||||
* @refApp <依赖服务的英文缩写>
|
||||
* @author <a href="mailto:wmshen@chinaums.com">wmshen</a>
|
||||
* @since 2022/10/20
|
||||
* @version 2022/10/20
|
||||
*/
|
||||
public class DateUtils {
|
||||
public static String getFormatDate(){
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
return sdf.format(date);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.chinaums.open.api.internal.util;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 16:17
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class FieldUtils {
|
||||
public static Object getFieldValueByTypeAndFormat(Field field, Object bean,
|
||||
String format) throws ParseException, IllegalArgumentException,
|
||||
IllegalAccessException {
|
||||
field.setAccessible(true);
|
||||
Object objValue = field.get(bean);
|
||||
Object ret = null;
|
||||
if (objValue == null)
|
||||
return ret;
|
||||
String type = field.getType().getName();
|
||||
if ("java.lang.String".equals(type)) {
|
||||
ret = field.get(bean).toString().trim();
|
||||
} else if ("java.lang.Integer".equals(type) || "int".equals(type)) {
|
||||
if (objValue instanceof Integer) {
|
||||
ret = ((Integer) objValue).toString();
|
||||
}
|
||||
} else if ("java.lang.Float".equals(type) || "float".equals(type)) {
|
||||
if (objValue instanceof Float) {
|
||||
ret = ((Float) objValue).toString();
|
||||
}
|
||||
} else if ("java.lang.Double".equals(type) || "double".equals(type)) {
|
||||
if (objValue instanceof Double) {
|
||||
ret = ((Double) objValue).toString();
|
||||
}
|
||||
} else if ("java.math.BigDecimal".equals(type)) {
|
||||
if (objValue instanceof BigDecimal) {
|
||||
ret = ((BigDecimal) objValue).toString();
|
||||
}
|
||||
} else if ("java.util.Date".equals(type)) {
|
||||
if (objValue instanceof Date) {
|
||||
Date dateValue = (Date) objValue;
|
||||
ret = new SimpleDateFormat(format).format(dateValue);
|
||||
}
|
||||
} else if ("java.lang.Boolean".equals(type)) {
|
||||
if (objValue instanceof Boolean) {
|
||||
ret = ((Boolean) objValue).toString();
|
||||
}
|
||||
} else if ("java.lang.Long".equals(type) || "long".equals(type)) {
|
||||
if (objValue instanceof Long) {
|
||||
ret = ((Long) objValue).toString();
|
||||
}
|
||||
} else {
|
||||
ret = objValue;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void setFieldValueByType(Field field, Object bean,
|
||||
String value) throws IllegalArgumentException,
|
||||
IllegalAccessException, ParseException, ClassNotFoundException {
|
||||
setFieldValueByTypeAndFormat(field,bean,value,null);
|
||||
}
|
||||
|
||||
public static void setFieldValueByTypeAndFormat(Field field, Object bean,
|
||||
String value, String format) throws IllegalArgumentException,
|
||||
IllegalAccessException, ParseException, ClassNotFoundException {
|
||||
if (value == null)
|
||||
return;
|
||||
field.setAccessible(true);
|
||||
String type = field.getType().getName();
|
||||
if ("java.lang.String".equals(type)) {
|
||||
field.set(bean, value);
|
||||
} else if ("java.lang.Integer".equals(type)) {
|
||||
field.set(bean, Integer.valueOf(value));
|
||||
} else if ("int".equals(type)) {
|
||||
field.set(bean, Integer.valueOf(value).intValue());
|
||||
} else if ("java.lang.Float".equals(type)) {
|
||||
field.set(bean, Float.valueOf(value));
|
||||
} else if ("float".equals(type)) {
|
||||
field.set(bean, Float.valueOf(value).floatValue());
|
||||
} else if ("java.lang.Double".equals(type)) {
|
||||
field.set(bean, Double.valueOf(value));
|
||||
} else if ("double".equals(type)) {
|
||||
field.set(bean, Double.valueOf(value).doubleValue());
|
||||
} else if ("java.math.BigDecimal".equals(type)) {
|
||||
field.set(bean, new BigDecimal(value));
|
||||
} else if ("java.util.Date".equals(type)) {
|
||||
Date date = new SimpleDateFormat(format).parse(value.toString());
|
||||
field.set(bean, date);
|
||||
} else if ("java.lang.Boolean".equals(type)) {
|
||||
field.set(bean, Boolean.valueOf(value));
|
||||
} else if ("java.lang.Long".equals(type)) {
|
||||
field.set(bean, Long.valueOf(value));
|
||||
} else if ("java.lang.Object".equals(type)) {
|
||||
field.set(bean, value);
|
||||
} else if ("long".equals(type)) {
|
||||
field.set(bean, Long.valueOf(value).longValue());
|
||||
} else if ("java.util.Map".equals(type)) {
|
||||
JSONObject mapObj = JSONObject.fromObject(value);
|
||||
field.set(bean,mapObj);
|
||||
} else if ("java.util.List".equals(type)) {
|
||||
JSONArray arr = JSONArray.fromObject(value);
|
||||
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
|
||||
Type listType = genericType.getActualTypeArguments()[0];
|
||||
if (listType instanceof ParameterizedType) {
|
||||
ParameterizedType paraType = (ParameterizedType) listType;
|
||||
if ("java.util.Map".equals(((Class<?>)paraType.getRawType()).getName())) {
|
||||
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
Map<String,String> classMap = new HashMap<String,String>();
|
||||
Map<String, String> map = (Map<String, String>) JSONObject
|
||||
.toBean(JSONObject.fromObject(arr.optString(i)),
|
||||
Map.class, classMap);
|
||||
list.add(map);
|
||||
}
|
||||
field.set(bean, list);
|
||||
}
|
||||
} else if(List.class.isAssignableFrom(field.getType())){
|
||||
String argCalssName = listType.toString().substring(listType.toString().lastIndexOf(" ") + 1);
|
||||
Class<?> clazz = Class.forName(argCalssName);
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
for (int index = 0; index < arr.size(); index++) {
|
||||
Object element = arr.get(index);
|
||||
if (clazz == element.getClass()) {
|
||||
list.add(element);
|
||||
} else {
|
||||
Object obj = JSONObject.toBean(JSONObject.fromObject(arr.optString(index)), clazz);
|
||||
list.add(obj);
|
||||
}
|
||||
}
|
||||
field.set(bean, list);
|
||||
} else {
|
||||
field.set(bean, arr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Field getFieldByName(Object obj, String key) {
|
||||
if (obj == null || key == null)
|
||||
return null;
|
||||
for (Class clazz = obj.getClass(); !clazz.getName().equals(Object.class.getName()); clazz = clazz
|
||||
.getSuperclass()) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
if (f.getName().equals(key)) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static Field getFieldByNameIgnoreCase(Class<?> clazz, String key) {
|
||||
if (clazz == null || key == null)
|
||||
return null;
|
||||
for (; !clazz.getName().equals(Object.class.getName()); clazz = clazz
|
||||
.getSuperclass()) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
if (f.getName().equalsIgnoreCase(key)) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static Object getFieldValueByNameIgnoreCase(Object obj, String key) {
|
||||
if (obj == null || key == null)
|
||||
return null;
|
||||
Class<? extends Object> clazz = obj.getClass();
|
||||
for (; !clazz.getName().equals(Object.class.getName()); clazz = clazz
|
||||
.getSuperclass()) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
if (f.getName().equalsIgnoreCase(key)) {
|
||||
f.setAccessible(true);
|
||||
try {
|
||||
return f.get(obj);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.chinaums.open.api.internal.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 10:21
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class OpenApiLogger {
|
||||
private static final Log blog = LogFactory.getLog("sdk.biz.err");
|
||||
private static final Log clog = LogFactory.getLog("sdk.biz.info");
|
||||
private static boolean needEnableLogger = true;
|
||||
|
||||
public static void logInfo(String rsp){
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
df.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(df.format(new Date()));
|
||||
sb.append("#");
|
||||
sb.append(rsp);
|
||||
clog.info(sb.toString());
|
||||
}
|
||||
|
||||
public static void logError(String rsp)
|
||||
{
|
||||
if (!needEnableLogger) {
|
||||
return;
|
||||
}
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
df.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(df.format(new Date()));
|
||||
sb.append("###");
|
||||
sb.append(rsp);
|
||||
blog.error(sb.toString());
|
||||
}
|
||||
|
||||
public static void logError(Throwable t)
|
||||
{
|
||||
if (!needEnableLogger) {
|
||||
return;
|
||||
}
|
||||
blog.error(t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.chinaums.open.api.internal.util;
|
||||
|
||||
import com.chinaums.open.api.OpenApiContext;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User:
|
||||
* Date:
|
||||
* Time:
|
||||
* 所属模块:
|
||||
* 功能说明:Open body sig相关
|
||||
*/
|
||||
public class OpenBodySigUtil {
|
||||
|
||||
/**
|
||||
* open-body-sig算法
|
||||
* @param context
|
||||
* @param request
|
||||
* @param method
|
||||
* @return
|
||||
*/
|
||||
public static String generateSignature(OpenApiContext context, String request,String method) {
|
||||
|
||||
try {
|
||||
String appId=context.getAppId();
|
||||
String appKey=context.getAppKey();
|
||||
String timestamp = new SimpleDateFormat("yyyyMMddHHmmss")
|
||||
.format(new Date());
|
||||
String nonce = UUID.randomUUID().toString().replace("-", "");
|
||||
String testSH = DigestUtils.sha256Hex(request);
|
||||
|
||||
String s1 = appId+timestamp+nonce+testSH;
|
||||
|
||||
String algorithm = "HmacSHA256";
|
||||
Mac mac = Mac.getInstance(algorithm);
|
||||
mac.init(new SecretKeySpec(appKey.getBytes(), algorithm));
|
||||
byte[] localSignature =mac.doFinal(s1.getBytes("utf-8"));
|
||||
|
||||
String localSignatureStr = Base64.encodeBase64String(localSignature);
|
||||
OpenApiLogger.logInfo("SHA256(签名内容):"+testSH);
|
||||
OpenApiLogger.logInfo("s1"+s1);
|
||||
|
||||
if(method.equals("POST")){
|
||||
OpenApiLogger.logInfo( "OPEN-BODY-SIG AppId=" + "\"" + appId + "\"" + ", Timestamp=" + "\"" + timestamp + "\"" + ", Nonce=" + "\"" + nonce + "\"" + ", Signature=" + "\"" + localSignatureStr + "\"");
|
||||
return "OPEN-BODY-SIG AppId=" + "\"" + appId + "\"" + ", Timestamp=" + "\"" + timestamp + "\"" + ", Nonce=" + "\"" + nonce + "\"" + ", Signature=" + "\"" + localSignatureStr + "\"";
|
||||
}
|
||||
return "authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "×tamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(request.toString(), "UTF-8") + "&signature=" + URLEncoder.encode(localSignatureStr, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError(e.getCause());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.chinaums.open.api.internal.util;
|
||||
|
||||
import com.chinaums.open.api.OpenApiContext;
|
||||
import com.chinaums.open.api.constants.ConfigBean;
|
||||
import com.chinaums.open.api.internal.util.converter.Converter;
|
||||
import com.chinaums.open.api.internal.util.converter.JsonConverter;
|
||||
import com.chinaums.open.api.internal.util.http.HttpTransport;
|
||||
import com.chinaums.open.api.request.TokenRequest;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/5
|
||||
* Time: 15:41
|
||||
* 所属模块:
|
||||
* 功能说明:Open Token相关
|
||||
*/
|
||||
public class OpenTokenUtil {
|
||||
private static final String constant_classname=OpenTokenUtil.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* token sha256签名算法
|
||||
* @param appId
|
||||
* @param timestamp
|
||||
* @param nonce
|
||||
* @param appKey
|
||||
* @return
|
||||
*/
|
||||
public static String generateSignature(String appId, String timestamp,
|
||||
String nonce, String appKey) {
|
||||
String plaintext = appId + timestamp + nonce + appKey;
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
digest.update(plaintext.getBytes());
|
||||
byte messageDigest[] = digest.digest();
|
||||
StringBuffer hexString = new StringBuffer();
|
||||
for (int i = 0; i < messageDigest.length; i++) {
|
||||
String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
|
||||
if (shaHex.length() < 2) {
|
||||
hexString.append(0);
|
||||
}
|
||||
hexString.append(shaHex);
|
||||
}
|
||||
return hexString.toString();
|
||||
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError(e.getCause());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static TokenResponse getToken(OpenApiContext context){
|
||||
int retry = 0;
|
||||
ConfigBean configBean = context.getConfigBean();
|
||||
TokenResponse acquiredToken = null;
|
||||
if (isTokenValid(context.getCurrentToken())
|
||||
&& !isTokenTimeout(context.getCurrentToken())) {
|
||||
return context.getCurrentToken();
|
||||
}
|
||||
while (retry++ < configBean.getTokenAcquireReties()) {
|
||||
acquiredToken = acquireAccessToken(context);
|
||||
if (null != acquiredToken) { //如果想根据请求token是否成功 用于重试 判断用if (null != acquiredToken.getAccessToken())
|
||||
break;
|
||||
} else if (retry < configBean.getTokenAcquireReties()) {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError(constant_classname +" 重试token申请出错:"+e.getCause());
|
||||
}
|
||||
} else {
|
||||
OpenApiLogger.logError(constant_classname +" 申请token超过重试次数 bye-bye");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return acquiredToken;
|
||||
}
|
||||
|
||||
private static TokenResponse acquireAccessToken(OpenApiContext context){
|
||||
String appId = context.getAppId();
|
||||
String appKey = context.getAppKey();
|
||||
ConfigBean configBean = context.getConfigBean();
|
||||
TokenRequest tokenRequest = new TokenRequest(appId,appKey);
|
||||
JSONObject jsonObj = JSONObject.fromObject(tokenRequest);
|
||||
TokenResponse tokenResponse;
|
||||
String url = context.getOpenServUrl().concat(configBean.getVersion()).concat(configBean.getTokenServiceCode());
|
||||
try {
|
||||
String response = HttpTransport.getInstance().doPost(configBean.isProd(),url,null,jsonObj.toString());
|
||||
if(StringUtils.isBlank(response)) throw new Exception(constant_classname+":服务提供方未返回");
|
||||
Converter converter = new JsonConverter();
|
||||
tokenResponse = converter.toResponse(response,TokenResponse.class);
|
||||
tokenResponse.setEffectTime(new Date());
|
||||
tokenResponse.setTimeout(tokenResponse.getExpiresIn());
|
||||
tokenResponse.setAheadInterval(configBean.getTokenAcquireAheadInterval());
|
||||
return tokenResponse;
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError(constant_classname +" exception:"+e.getCause());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isTokenValid(TokenResponse tokenBean) {
|
||||
return (null != tokenBean
|
||||
&& org.apache.commons.lang.StringUtils.isNotBlank(tokenBean.getAccessToken())
|
||||
&& null != tokenBean.getEffectTime()
|
||||
&& tokenBean.getTimeout() > 0
|
||||
&& tokenBean.getAheadInterval() > 0 && tokenBean.getTimeout() > tokenBean
|
||||
.getAheadInterval());
|
||||
}
|
||||
|
||||
private static boolean isTokenTimeout(TokenResponse tokenBean) {
|
||||
int elapseInterval = (int) ((new Date().getTime() - tokenBean
|
||||
.getEffectTime().getTime()) / 1000);
|
||||
int maxEffectiveInterval = tokenBean.getTimeout()
|
||||
- tokenBean.getAheadInterval();
|
||||
boolean isTimeout = (elapseInterval > maxEffectiveInterval);
|
||||
if (isTimeout) {
|
||||
OpenApiLogger.logError(constant_classname +" exception:token过期了");
|
||||
}
|
||||
return isTimeout;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.chinaums.open.api.internal.util.converter;
|
||||
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* Created by ZHANGWEI on 2016/12/2.
|
||||
*/
|
||||
public abstract interface Converter {
|
||||
public abstract <T extends OpenApiResponse> T toResponse(String paramString, Class<T> paramClass)
|
||||
throws OpenApiException, IllegalAccessException, InstantiationException, ParseException, ClassNotFoundException;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.chinaums.open.api.internal.util.converter;
|
||||
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
import com.chinaums.open.api.internal.util.FieldUtils;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 14:50
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class JsonConverter implements Converter {
|
||||
public <T extends OpenApiResponse> T toResponse(String paramString, Class<T> paramClass) throws OpenApiException, IllegalAccessException, InstantiationException, ParseException, ClassNotFoundException {
|
||||
JSONObject jsonObj = JSONObject.fromObject(paramString);
|
||||
Object bean = paramClass.newInstance();
|
||||
for (Class clazz = bean.getClass(); !clazz.getName().equals(
|
||||
Object.class.getName()); clazz = clazz.getSuperclass()) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
String fieldName = field.getName();
|
||||
String name = fieldName;
|
||||
String key = fieldName;
|
||||
String value = jsonObj.get(key) == null ? null : jsonObj
|
||||
.get(key).toString().trim();
|
||||
FieldUtils.setFieldValueByTypeAndFormat(field, bean, value, null);
|
||||
}
|
||||
}
|
||||
return (T) bean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.chinaums.open.api.internal.util.http;
|
||||
|
||||
import com.chinaums.open.api.OpenApiContext;
|
||||
import com.chinaums.open.api.constants.ConfigBean;
|
||||
import com.chinaums.open.api.internal.util.OpenApiLogger;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import static com.chinaums.open.api.internal.util.OpenBodySigUtil.generateSignature;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/5
|
||||
* Time: 13:56
|
||||
* 所属模块:
|
||||
* 功能说明:http通用处理
|
||||
*/
|
||||
public class HttpTransport implements IHttpTransport {
|
||||
|
||||
private static OkHttpClient okHttpClient;
|
||||
private static HttpTransport httpUtils;
|
||||
public static final MediaType JSON=MediaType.parse("application/json; charset=utf-8");
|
||||
|
||||
private HttpTransport() {
|
||||
}
|
||||
|
||||
public static synchronized HttpTransport getInstance() {
|
||||
if (httpUtils == null) {
|
||||
httpUtils = new HttpTransport();
|
||||
initialize();
|
||||
}
|
||||
return httpUtils;
|
||||
}
|
||||
|
||||
private static void initialize() {
|
||||
okHttpClient = new OkHttpClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* http post
|
||||
* @param isProd
|
||||
* @param url
|
||||
* @param token
|
||||
* @param requestString
|
||||
* @return
|
||||
*/
|
||||
public String doPost(boolean isProd,String url, String token, String requestString) throws Exception {
|
||||
Request request = null;
|
||||
RequestBody requestBody = RequestBody.create(JSON,requestString);
|
||||
Response response;
|
||||
String responseInfo = "";
|
||||
if(!isProd){
|
||||
OpenApiLogger.logInfo("url:"+url);
|
||||
OpenApiLogger.logInfo("requst params:"+requestString);
|
||||
}
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
request = new Request.Builder().url(url).addHeader("Authorization", "OPEN-ACCESS-TOKEN AccessToken=" + token).post(requestBody).build();
|
||||
}else{
|
||||
request = new Request.Builder().url(url).post(requestBody).build();
|
||||
}
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
responseInfo = response.body().source().readUtf8();
|
||||
OpenApiLogger.logInfo("response :"+responseInfo);
|
||||
return responseInfo;
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError("通讯网络异常: "+e.getStackTrace());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* http post token方式
|
||||
* @param context
|
||||
* @param resquest_
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
public String doPost(OpenApiContext context, String resquest_) throws Exception {
|
||||
String url = context.getApiServiceUrl();
|
||||
String appId=context.getAppId();
|
||||
ConfigBean configBean = context.getConfigBean();
|
||||
context.setRequest(resquest_);
|
||||
Request request = null;
|
||||
RequestBody requestBody = RequestBody.create(JSON,resquest_);
|
||||
Response response;
|
||||
String responseInfo = "";
|
||||
if(!configBean.isProd()){
|
||||
OpenApiLogger.logInfo("url:"+url);
|
||||
OpenApiLogger.logInfo("requst params:"+resquest_);
|
||||
|
||||
}
|
||||
TokenResponse token = context.getCurrentToken();
|
||||
request = new Request.Builder().url(url).
|
||||
addHeader("Authorization","OPEN-ACCESS-TOKEN AccessToken=" + token.getAccessToken()+",AppId="+appId)
|
||||
// .addHeader("X-Access-Model","NEW")
|
||||
.post(requestBody).build();
|
||||
OpenApiLogger.logInfo("requst header:"+"OPEN-ACCESS-TOKEN AccessToken=" + token.getAccessToken()+",AppId="+appId);
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
OpenApiLogger.logInfo("服务端返回code:"+response.code()+" message:"+response.message());
|
||||
responseInfo = response.body().source().readUtf8();
|
||||
context.setResponse(responseInfo);
|
||||
OpenApiLogger.logInfo("response :"+responseInfo);
|
||||
return responseInfo;
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError("通讯网络异常: "+e.getStackTrace());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* http post signature方式
|
||||
* @param context
|
||||
* @param resquest_
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
public String doPostSignature(OpenApiContext context, String resquest_) throws Exception {
|
||||
String url = context.getApiServiceUrl();
|
||||
ConfigBean configBean = context.getConfigBean();
|
||||
context.setRequest(resquest_);
|
||||
Request request = null;
|
||||
RequestBody requestBody = RequestBody.create(JSON,resquest_);
|
||||
Response response;
|
||||
String responseInfo = "";
|
||||
if(!configBean.isProd()){
|
||||
OpenApiLogger.logInfo("url:"+url);
|
||||
OpenApiLogger.logInfo("requst params:"+resquest_);
|
||||
|
||||
}
|
||||
String authoriztion=generateSignature(context,resquest_,"POST");
|
||||
request = new Request.Builder().url(url).
|
||||
addHeader("Authorization",authoriztion)
|
||||
.post(requestBody).build();
|
||||
OpenApiLogger.logInfo("requst header:"+authoriztion);
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
OpenApiLogger.logInfo("服务端返回code:"+response.code()+" message:"+response.message());
|
||||
responseInfo = response.body().source().readUtf8();
|
||||
context.setResponse(responseInfo);
|
||||
OpenApiLogger.logInfo("response :"+responseInfo);
|
||||
return responseInfo;
|
||||
} catch (Exception e) {
|
||||
OpenApiLogger.logError("通讯网络异常: "+e.getStackTrace());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public String doGet(OpenApiContext context, String request) {
|
||||
String url = context.getApiServiceUrl();
|
||||
String authoriztion=generateSignature(context,request,"GET");
|
||||
OpenApiLogger.logInfo("拼接的url :"+url+"?"+authoriztion);
|
||||
return url+"?"+authoriztion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.chinaums.open.api.internal.util.http;
|
||||
|
||||
import com.chinaums.open.api.OpenApiContext;
|
||||
|
||||
/**
|
||||
* Created by ZHANGWEI on 2016/12/4.
|
||||
*/
|
||||
public interface IHttpTransport {
|
||||
public abstract String doPost(boolean isDebug,String url, String token, String request) throws Throwable;
|
||||
public abstract String doPost(OpenApiContext context, String request) throws Throwable;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.chinaums.open.api.parser.json;
|
||||
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.OpenApiParser;
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.internal.util.OpenApiLogger;
|
||||
import com.chinaums.open.api.internal.util.converter.Converter;
|
||||
import com.chinaums.open.api.internal.util.converter.JsonConverter;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 14:37
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class ObjectJsonParser<T extends OpenApiResponse> implements OpenApiParser<T> {
|
||||
|
||||
private Class<T> class_;
|
||||
|
||||
public ObjectJsonParser(Class<T> tClass) {
|
||||
this.class_ = tClass;
|
||||
}
|
||||
|
||||
public T parse(String paramString) throws OpenApiException {
|
||||
Converter converter = new JsonConverter();
|
||||
try {
|
||||
return converter.toResponse(paramString,this.class_);
|
||||
} catch (IllegalAccessException e) {
|
||||
OpenApiLogger.logError(e.getCause());
|
||||
} catch (InstantiationException e) {
|
||||
OpenApiLogger.logError(e.getCause());
|
||||
} catch (ParseException e) {
|
||||
OpenApiLogger.logError(e.getCause());
|
||||
} catch (ClassNotFoundException e) {
|
||||
OpenApiLogger.logError(e.getCause());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String validRequest(OpenApiRequest<T> openApiRequest) throws OpenApiException {
|
||||
JSONObject jsonObj = JSONObject.fromObject(openApiRequest);
|
||||
for (Class clazz = openApiRequest.getClass(); !clazz.getName().equals(
|
||||
Object.class.getName()); clazz = clazz.getSuperclass()) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
String fieldName = field.getName();
|
||||
String name = fieldName;
|
||||
String key = fieldName;
|
||||
boolean required = false;
|
||||
int length = -1;
|
||||
int minLength = -1;
|
||||
int maxLength = -1;
|
||||
if (field.isAnnotationPresent(ApiField.class)) {
|
||||
ApiField requestMark = field
|
||||
.getAnnotation(ApiField.class);
|
||||
String markKey = requestMark.key();
|
||||
if (markKey != null && !markKey.equals("")) {
|
||||
key = markKey;
|
||||
}
|
||||
name = requestMark.name();
|
||||
required = requestMark.required();
|
||||
length = requestMark.length();
|
||||
minLength = requestMark.minLength();
|
||||
maxLength = requestMark.maxLength();
|
||||
String value = jsonObj.get(key) == null ? null : jsonObj
|
||||
.get(key).toString().trim();
|
||||
if (StringUtils.isBlank(value) && required)
|
||||
throw new OpenApiException(name + "[" + key + "]不能为空");
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
if (length != -1) {
|
||||
if (value.length() != length)
|
||||
throw new OpenApiException(name + "[" + key
|
||||
+ "]长度必须为:" + length);
|
||||
}
|
||||
if (minLength != -1) {
|
||||
if (value.length() < minLength)
|
||||
throw new OpenApiException(name + "[" + key
|
||||
+ "]长度必须大于等于:" + minLength);
|
||||
}
|
||||
if (maxLength != -1) {
|
||||
if (value.length() > maxLength)
|
||||
throw new OpenApiException(name + "[" + key
|
||||
+ "]长度必须小于等于:" + maxLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsonObj.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.AcpInstallmentResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/12/12
|
||||
* Time: 14:51
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class AcpInstallmentRequest implements OpenApiRequest<AcpInstallmentResponse> {
|
||||
@ApiField(key = "merchantCode",required = true,desc = "商户号")
|
||||
private String merchantCode;
|
||||
@ApiField(key = "terminalCode",required = true,desc = "终端号")
|
||||
private String terminalCode;
|
||||
@ApiField(key = "systemTraceNum",required = true,desc = "系统跟踪号")
|
||||
private String systemTraceNum;
|
||||
@ApiField(key = "transactionAmount",required = true,desc = "交易金额")
|
||||
private String transactionAmount;
|
||||
@ApiField(key = "transactionCurrencyCode",required = true,desc = "交易币种")
|
||||
private String transactionCurrencyCode;
|
||||
@ApiField(key = "encryptedData",required = true,desc = "加密数据")
|
||||
private String encryptedData;
|
||||
|
||||
public Class<AcpInstallmentResponse> responseClass() {
|
||||
return AcpInstallmentResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "一次性分期";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/unionpay/acp/installment/request";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getMerchantCode() {
|
||||
return merchantCode;
|
||||
}
|
||||
|
||||
public void setMerchantCode(String merchantCode) {
|
||||
this.merchantCode = merchantCode;
|
||||
}
|
||||
|
||||
public String getTerminalCode() {
|
||||
return terminalCode;
|
||||
}
|
||||
|
||||
public void setTerminalCode(String terminalCode) {
|
||||
this.terminalCode = terminalCode;
|
||||
}
|
||||
|
||||
public String getSystemTraceNum() {
|
||||
return systemTraceNum;
|
||||
}
|
||||
|
||||
public void setSystemTraceNum(String systemTraceNum) {
|
||||
this.systemTraceNum = systemTraceNum;
|
||||
}
|
||||
|
||||
public String getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(String transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
|
||||
public String getTransactionCurrencyCode() {
|
||||
return transactionCurrencyCode;
|
||||
}
|
||||
|
||||
public void setTransactionCurrencyCode(String transactionCurrencyCode) {
|
||||
this.transactionCurrencyCode = transactionCurrencyCode;
|
||||
}
|
||||
|
||||
public String getEncryptedData() {
|
||||
return encryptedData;
|
||||
}
|
||||
|
||||
public void setEncryptedData(String encryptedData) {
|
||||
this.encryptedData = encryptedData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.response.BankVerifyResponse;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 14:17
|
||||
* 所属模块:
|
||||
* 功能说明:银行卡验证
|
||||
*/
|
||||
public class BankVerifyRequest implements OpenApiRequest<BankVerifyResponse> {
|
||||
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
|
||||
public Class<BankVerifyResponse> responseClass() {
|
||||
return BankVerifyResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "银行卡实名认证";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/bankcard/verify";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.CourtQueryResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/6
|
||||
* Time: 15:21
|
||||
* 所属模块:
|
||||
* 功能说明:法院信息查询
|
||||
*/
|
||||
public class CourtQueryRequest implements OpenApiRequest<CourtQueryResponse> {
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
public Class<CourtQueryResponse> responseClass() {
|
||||
return CourtQueryResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "法院信息查询";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/court/query";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.EducationInfoVerifyResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/5/8
|
||||
* Time: 17:02
|
||||
* 所属模块:
|
||||
* 功能说明:学历信息验证
|
||||
*/
|
||||
public class EducationInfoVerifyRequest implements OpenApiRequest<EducationInfoVerifyResponse> {
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
public Class<EducationInfoVerifyResponse> responseClass() {
|
||||
return EducationInfoVerifyResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "学历信息验证查询";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/education/query";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.FacerecognitionParamComposeResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 14:33
|
||||
* 所属模块:
|
||||
* 功能说明:人脸识别参数拼装
|
||||
*/
|
||||
public class FacerecognitionParamComposeRequest implements OpenApiRequest<FacerecognitionParamComposeResponse> {
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
public Class<FacerecognitionParamComposeResponse> responseClass() {
|
||||
return FacerecognitionParamComposeResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "人脸识别参数拼装";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/facerecognition/param/compose";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.FacerecognitionParamResultQueryResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 14:34
|
||||
* 所属模块:
|
||||
* 功能说明:人脸识别结果查询
|
||||
*/
|
||||
public class FacerecognitionParamResultQueryRequest implements OpenApiRequest<FacerecognitionParamResultQueryResponse> {
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
public Class<FacerecognitionParamResultQueryResponse> responseClass() {
|
||||
return FacerecognitionParamResultQueryResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "人脸识别结果查询";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/facerecognition/result/query";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.FacerecognitionParamResultSetResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 14:35
|
||||
* 所属模块:
|
||||
* 功能说明:人脸识别结果获取
|
||||
*/
|
||||
public class FacerecognitionParamResultSetRequest implements OpenApiRequest<FacerecognitionParamResultSetResponse> {
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
public Class<FacerecognitionParamResultSetResponse> responseClass() {
|
||||
return FacerecognitionParamResultSetResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "人脸识别结果获取";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/facerecognition/result/set";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.GenericTagQueryResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/6
|
||||
* Time: 15:18
|
||||
* 所属模块:
|
||||
* 功能说明:实时标签查询
|
||||
*/
|
||||
public class GenericTagQueryRequest implements OpenApiRequest<GenericTagQueryResponse>{
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
public Class<GenericTagQueryResponse> responseClass() {
|
||||
return GenericTagQueryResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "实时标签查询";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/tag/generic/query";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.IdCardVerifyResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/13
|
||||
* Time: 14:07
|
||||
* 所属模块:
|
||||
* 功能说明:身份证核查
|
||||
*/
|
||||
public class IdCardVerifyRequest implements OpenApiRequest<IdCardVerifyResponse>{
|
||||
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
public Class<IdCardVerifyResponse> responseClass() {
|
||||
return IdCardVerifyResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "身份证核查(政通实名认证)";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/idcard/verify";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.IdCheckSimpleInfoResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/2/21
|
||||
* Time: 14:49
|
||||
* 所属模块:
|
||||
* 功能说明:简项公民身份证信息核查请求报文
|
||||
*/
|
||||
public class IdCheckSimpleInfoRequest implements OpenApiRequest<IdCheckSimpleInfoResponse> {
|
||||
|
||||
@ApiField(name = "certifId",required = true ,desc = "公民身份号码")
|
||||
private String certifId;
|
||||
@ApiField(name = "name",required = true ,desc = "姓名")
|
||||
private String name;
|
||||
public Class<IdCheckSimpleInfoResponse> responseClass() {
|
||||
return IdCheckSimpleInfoResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "身份证验证";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/creditcheck/idcheck/simpleinfo";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getCertifId() {
|
||||
return certifId;
|
||||
}
|
||||
|
||||
public void setCertifId(String certifId) {
|
||||
this.certifId = certifId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.Mobile3factorVerifyResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/13
|
||||
* Time: 14:11
|
||||
* 所属模块:
|
||||
* 功能说明:运营商三要素验证
|
||||
*/
|
||||
public class Mobile3factorVerifyRequest implements OpenApiRequest<Mobile3factorVerifyResponse>{
|
||||
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
|
||||
public Class<Mobile3factorVerifyResponse> responseClass() {
|
||||
return Mobile3factorVerifyResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "运营商三要素验证";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/mobile/3factor/verify";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.NyBankCardTagResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/3/21
|
||||
* Time: 18:07
|
||||
* 所属模块:
|
||||
* 功能说明:楠云银行卡标签提取
|
||||
*/
|
||||
public class NyBankCardTagRequest implements OpenApiRequest<NyBankCardTagResponse> {
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
|
||||
public Class<NyBankCardTagResponse> responseClass() {
|
||||
return NyBankCardTagResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "楠云银行卡标签提取查询";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/bankcardtag/query";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.response.RealNameVerifyResponse;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/6
|
||||
* Time: 15:23
|
||||
* 所属模块:
|
||||
* 功能说明:实名认证
|
||||
*/
|
||||
public class RealNameVerifyRequest implements OpenApiRequest<RealNameVerifyResponse> {
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
|
||||
public Class<RealNameVerifyResponse> responseClass() {
|
||||
return RealNameVerifyResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "实名认证";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/realname/verify";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.internal.util.OpenTokenUtil;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/5
|
||||
* Time: 15:42
|
||||
* 所属模块:
|
||||
* 功能说明:token
|
||||
*/
|
||||
public class TokenRequest implements OpenApiRequest<TokenResponse> {
|
||||
@ApiField(name = "appId",required = true ,desc = "开放平台开发者id")
|
||||
private String appId;
|
||||
@ApiField(name = "appKey",required = true,desc = "开放平台开发者key")
|
||||
private String appKey;
|
||||
@ApiField(name = "时间戳",required = true)
|
||||
private String timestamp;
|
||||
@ApiField(name = "随机数",required = true)
|
||||
private String nonce;
|
||||
@ApiField(name = "加密方法",required = true)
|
||||
private String signMethod;
|
||||
@ApiField(name = "SHA256签名字符",required = true)
|
||||
private String signature;
|
||||
|
||||
public Class<TokenResponse> responseClass() {
|
||||
return TokenResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v2";
|
||||
} //新入驻商户需要使用v2方式
|
||||
|
||||
public String apiMethodName() {
|
||||
return "获取开放平台token";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/token/access";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public TokenRequest(String appId, String appKey) {
|
||||
this.appId = appId;
|
||||
this.appKey = appKey;
|
||||
this.timestamp = new SimpleDateFormat("yyyyMMddHHmmss")
|
||||
.format(new Date());
|
||||
this.nonce = UUID.randomUUID().toString();
|
||||
this.signMethod = "SHA256";
|
||||
this.signature = OpenTokenUtil.generateSignature(getAppId(),getTimestamp(),getNonce(),getAppKey());
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getNonce() {
|
||||
return nonce;
|
||||
}
|
||||
|
||||
public void setNonce(String nonce) {
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
public String getSignMethod() {
|
||||
return signMethod;
|
||||
}
|
||||
|
||||
public void setSignMethod(String signMethod) {
|
||||
this.signMethod = signMethod;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.chinaums.open.api.request;
|
||||
|
||||
import com.chinaums.open.api.OpenApiRequest;
|
||||
import com.chinaums.open.api.annotation.ApiField;
|
||||
import com.chinaums.open.api.response.YsBankCardTagResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/5/3
|
||||
* Time: 18:21
|
||||
* 所属模块:
|
||||
* 功能说明:盐商科技用户标签查询
|
||||
*/
|
||||
public class YsBankCardTagRequest implements OpenApiRequest<YsBankCardTagResponse> {
|
||||
|
||||
@ApiField(key = "data",required = true,desc = "json格式字符")
|
||||
private Object data;
|
||||
|
||||
public Class<YsBankCardTagResponse> responseClass() {
|
||||
return YsBankCardTagResponse.class;
|
||||
}
|
||||
|
||||
public String apiVersion() {
|
||||
return "v1";
|
||||
}
|
||||
|
||||
public String apiMethodName() {
|
||||
return "盐商科技用户标签查询";
|
||||
}
|
||||
|
||||
public String serviceCode() {
|
||||
return "/datacenter/smartverification/ysbankcardtag/query";
|
||||
}
|
||||
|
||||
public boolean needToken() {
|
||||
return true;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/12/12
|
||||
* Time: 14:51
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class AcpInstallmentResponse extends OpenApiResponse {
|
||||
/**
|
||||
* 错误代码
|
||||
*/
|
||||
private String errCode;
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
private String errInfo;
|
||||
/**
|
||||
* 交易时间 HHmmss
|
||||
*/
|
||||
private String transactionTime;
|
||||
/**
|
||||
* 交易日期 MMdd
|
||||
*/
|
||||
private String transactionDate;
|
||||
/**
|
||||
* 结算日期 MMdd
|
||||
*/
|
||||
private String settlementDate;
|
||||
/**
|
||||
* 检索参考号
|
||||
*/
|
||||
private String retrievalRefNum;
|
||||
|
||||
@Override
|
||||
public String getErrCode() {
|
||||
return errCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrCode(String errCode) {
|
||||
this.errCode = errCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrInfo() {
|
||||
return errInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrInfo(String errInfo) {
|
||||
this.errInfo = errInfo;
|
||||
}
|
||||
|
||||
public String getTransactionTime() {
|
||||
return transactionTime;
|
||||
}
|
||||
|
||||
public void setTransactionTime(String transactionTime) {
|
||||
this.transactionTime = transactionTime;
|
||||
}
|
||||
|
||||
public String getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(String transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public String getSettlementDate() {
|
||||
return settlementDate;
|
||||
}
|
||||
|
||||
public void setSettlementDate(String settlementDate) {
|
||||
this.settlementDate = settlementDate;
|
||||
}
|
||||
|
||||
public String getRetrievalRefNum() {
|
||||
return retrievalRefNum;
|
||||
}
|
||||
|
||||
public void setRetrievalRefNum(String retrievalRefNum) {
|
||||
this.retrievalRefNum = retrievalRefNum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/2
|
||||
* Time: 14:14
|
||||
* 所属模块:
|
||||
* 功能说明:银行卡验证
|
||||
*/
|
||||
public class BankVerifyResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
private Object data;
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/6
|
||||
* Time: 15:21
|
||||
* 所属模块:
|
||||
* 功能说明:法院信息查询
|
||||
*/
|
||||
public class CourtQueryResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/5/8
|
||||
* Time: 17:03
|
||||
* 所属模块:
|
||||
* 功能说明:学历信息验证
|
||||
*/
|
||||
public class EducationInfoVerifyResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 14:34
|
||||
* 所属模块:
|
||||
* 功能说明:人脸识别参数拼装
|
||||
*/
|
||||
public class FacerecognitionParamComposeResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 14:34
|
||||
* 所属模块:
|
||||
* 功能说明:人脸识别结果查询
|
||||
*/
|
||||
public class FacerecognitionParamResultQueryResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 14:35
|
||||
* 所属模块:
|
||||
* 功能说明:人脸识别结果获取
|
||||
*/
|
||||
public class FacerecognitionParamResultSetResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/6
|
||||
* Time: 15:18
|
||||
* 所属模块:
|
||||
* 功能说明:实时标签查询
|
||||
*/
|
||||
public class GenericTagQueryResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/13
|
||||
* Time: 14:06
|
||||
* 所属模块:
|
||||
* 功能说明:身份证核查
|
||||
*/
|
||||
public class IdCardVerifyResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/2/21
|
||||
* Time: 14:49
|
||||
* 所属模块:
|
||||
* 功能说明:核查平台-身份证验证
|
||||
*/
|
||||
public class IdCheckSimpleInfoResponse extends OpenApiResponse {
|
||||
/**
|
||||
* 公民身份号码核查结果
|
||||
*/
|
||||
private String resultCertifId;
|
||||
|
||||
/**
|
||||
* 姓名核查结果
|
||||
*/
|
||||
private String resultName;
|
||||
|
||||
/**
|
||||
* base64编码的照片
|
||||
*/
|
||||
private String photo;
|
||||
|
||||
public String getResultCertifId() {
|
||||
return resultCertifId;
|
||||
}
|
||||
|
||||
public void setResultCertifId(String resultCertifId) {
|
||||
this.resultCertifId = resultCertifId;
|
||||
}
|
||||
|
||||
public String getResultName() {
|
||||
return resultName;
|
||||
}
|
||||
|
||||
public void setResultName(String resultName) {
|
||||
this.resultName = resultName;
|
||||
}
|
||||
|
||||
public String getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
|
||||
public void setPhoto(String photo) {
|
||||
this.photo = photo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/13
|
||||
* Time: 16:58
|
||||
* 所属模块:
|
||||
* 功能说明:运营商三要素验证
|
||||
*/
|
||||
public class Mobile3factorVerifyResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/3/21
|
||||
* Time: 18:07
|
||||
* 所属模块:
|
||||
* 功能说明:楠云银行卡标签提取
|
||||
*/
|
||||
public class NyBankCardTagResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/6
|
||||
* Time: 15:23
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class RealNameVerifyResponse extends OpenApiResponse{
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/5
|
||||
* Time: 15:42
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class TokenResponse extends OpenApiResponse{
|
||||
/**
|
||||
* 服务授权令牌
|
||||
*/
|
||||
private String accessToken;
|
||||
/**
|
||||
* 有效期
|
||||
*/
|
||||
private int expiresIn;
|
||||
/**
|
||||
* 令牌开始生效的时间,以收到时间为准
|
||||
*/
|
||||
private Date effectTime;
|
||||
|
||||
/**
|
||||
* 令牌的过期时间,单位为秒,由数据中心返回
|
||||
*/
|
||||
private int timeout;
|
||||
|
||||
/**
|
||||
* 在令牌过期前,要提前重新申请
|
||||
*/
|
||||
private int aheadInterval;
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public int getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public void setExpiresIn(int expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
|
||||
public Date getEffectTime() {
|
||||
return effectTime;
|
||||
}
|
||||
|
||||
public void setEffectTime(Date effectTime) {
|
||||
this.effectTime = effectTime;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public int getAheadInterval() {
|
||||
return aheadInterval;
|
||||
}
|
||||
|
||||
public void setAheadInterval(int aheadInterval) {
|
||||
this.aheadInterval = aheadInterval;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.chinaums.open.api.response;
|
||||
|
||||
import com.chinaums.open.api.OpenApiResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/5/3
|
||||
* Time: 18:21
|
||||
* 所属模块:
|
||||
* 功能说明:盐商科技用户标签查询
|
||||
*/
|
||||
public class YsBankCardTagResponse extends OpenApiResponse {
|
||||
private String resultCode;
|
||||
private String resultInfo;
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultInfo() {
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
public void setResultInfo(String resultInfo) {
|
||||
this.resultInfo = resultInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.chinaums.open.api.internal.util.http;
|
||||
|
||||
import com.chinaums.open.api.OpenApiCache;
|
||||
import com.chinaums.open.api.OpenApiContext;
|
||||
import com.chinaums.open.api.constants.ConfigBean;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Project:TODO ADD PROJECT NAME
|
||||
* Modify Information:
|
||||
* ================================================================
|
||||
* Author Date Description
|
||||
* ------------ ---------- --------------------------------
|
||||
* wmshen 2022/10/20 TODO:
|
||||
* ================================================================
|
||||
* Copyright (c) 银联商务股份有限公司 www.chinaums.com
|
||||
*/
|
||||
public class HttpTransportTest {
|
||||
|
||||
@Test
|
||||
public void doGet() throws Exception {
|
||||
|
||||
String url = "https://test-api-open.chinaums.com/v1/netpay/trade/h5-pay";
|
||||
//开发者ID
|
||||
String appId = "10037e6f6a4e6da4016a670fd4530012";
|
||||
//开发者秘钥
|
||||
String appKey = "f7a74b6c02ae4e1e94aaba311c04acf2";
|
||||
//实例化客户端
|
||||
ConfigBean configBean = new ConfigBean();
|
||||
OpenApiContext context = new OpenApiContext();
|
||||
String request = "{\"tid\":\"88880001\",\"totalAmount\":\"1\",\"mid\":\"898310148160568\",\"merOrderId\":\"wf12421741298471284\"}";
|
||||
context.setStartTime(System.currentTimeMillis());
|
||||
context.setRequestId(UUID.randomUUID().toString().replace("-", ""));
|
||||
context.setOpenServUrl(url.split("/v")[0].concat("/"));
|
||||
context.setApiServiceUrl(url);
|
||||
context.setVersion(url.split("/")[3]);
|
||||
context.setAppId(appId);
|
||||
context.setAppKey(appKey);
|
||||
context.setConfigBean(configBean);
|
||||
context.setServiceCode(url.split("/v")[1].substring(1));
|
||||
OpenApiCache.getCurrentToken(context);
|
||||
System.out.println(HttpTransport.getInstance().doGet(context, request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.NyBankCardTagRequest;
|
||||
import com.chinaums.open.api.request.YsBankCardTagRequest;
|
||||
import com.chinaums.open.api.response.NyBankCardTagResponse;
|
||||
import com.chinaums.open.api.response.YsBankCardTagResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/3/21
|
||||
* Time: 19:08
|
||||
* 所属模块:
|
||||
* 功能说明:标签查询相关testcase
|
||||
*/
|
||||
public class BankCardTagTestCase {
|
||||
@org.junit.Test
|
||||
public void testNyBankCardTag() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
NyBankCardTagRequest nyBankCardTagRequest = new NyBankCardTagRequest();
|
||||
nyBankCardTagRequest.setData("{\"userNo\":\"\",\"priAcctNo\":\"\",\"riskflag\":\"1\"}");
|
||||
NyBankCardTagResponse nyBankCardTagResponse;
|
||||
nyBankCardTagResponse = openApiClient.execute(nyBankCardTagRequest);
|
||||
System.out.println(nyBankCardTagResponse.getData());
|
||||
System.out.println(nyBankCardTagResponse.getResultCode());
|
||||
System.out.println(nyBankCardTagResponse.getResultInfo());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testYsBankCardTag() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
YsBankCardTagRequest ysBankCardTagRequest = new YsBankCardTagRequest();
|
||||
ysBankCardTagRequest.setData("{\"phoneNo\":\"\",\"priAcctNo\":\"\"}");
|
||||
YsBankCardTagResponse ysBankCardTagResponse;
|
||||
ysBankCardTagResponse = openApiClient.execute(ysBankCardTagRequest);
|
||||
System.out.println(ysBankCardTagResponse.getData());
|
||||
System.out.println(ysBankCardTagResponse.getResultCode());
|
||||
System.out.println(ysBankCardTagResponse.getResultInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.FacerecognitionParamComposeRequest;
|
||||
import com.chinaums.open.api.request.FacerecognitionParamResultQueryRequest;
|
||||
import com.chinaums.open.api.request.FacerecognitionParamResultSetRequest;
|
||||
import com.chinaums.open.api.response.FacerecognitionParamComposeResponse;
|
||||
import com.chinaums.open.api.response.FacerecognitionParamResultQueryResponse;
|
||||
import com.chinaums.open.api.response.FacerecognitionParamResultSetResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 14:41
|
||||
* 所属模块:
|
||||
* 功能说明:人脸识别相关测试案例
|
||||
*/
|
||||
public class FacerecognitionTest {
|
||||
@org.junit.Test
|
||||
public void testFacerecognitionParamCompose() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
FacerecognitionParamComposeRequest facerecognitionParamComposeRequest = new FacerecognitionParamComposeRequest();
|
||||
facerecognitionParamComposeRequest.setData("{\"certNo\" : \"\",\"idCardUserName\" : \"\",\"orderId\" : '',\"orderDate\" : '',\"deviceID\" : '',\"deviceOs\" : ''}");
|
||||
FacerecognitionParamComposeResponse response = openApiClient.execute(facerecognitionParamComposeRequest);
|
||||
System.out.println(response.getErrCode());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testFacerecognitionParamResultQuery() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
FacerecognitionParamResultQueryRequest request = new FacerecognitionParamResultQueryRequest();
|
||||
request.setData("{\"orderId\":\"\",\"deviceID\":\"\",\"orderDate\":\"\"}");
|
||||
FacerecognitionParamResultQueryResponse response = openApiClient.execute(request);
|
||||
System.out.println(response.getErrCode());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testFacerecognitionParamResultSet() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
FacerecognitionParamResultSetRequest request = new FacerecognitionParamResultSetRequest();
|
||||
request.setData("{\"signature\":\"\",\"merNo\":\"\",\"respData\":\"\"}");
|
||||
FacerecognitionParamResultSetResponse response = openApiClient.execute(request);
|
||||
System.out.println(response.getErrCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.EducationInfoVerifyRequest;
|
||||
import com.chinaums.open.api.request.IdCheckSimpleInfoRequest;
|
||||
import com.chinaums.open.api.response.EducationInfoVerifyResponse;
|
||||
import com.chinaums.open.api.response.IdCheckSimpleInfoResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/2/21
|
||||
* Time: 15:00
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class IdCheckSimpleInfoTestCase {
|
||||
@org.junit.Test
|
||||
public void testIdCheck() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
IdCheckSimpleInfoRequest request = new IdCheckSimpleInfoRequest();
|
||||
request.setCertifId("");
|
||||
request.setName("");
|
||||
IdCheckSimpleInfoResponse response = openApiClient.execute(request);
|
||||
System.out.println(response.getErrCode());
|
||||
}
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void testEducation() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
EducationInfoVerifyRequest ysBankCardTagRequest = new EducationInfoVerifyRequest();
|
||||
ysBankCardTagRequest.setData("{\"certNo\":\"\",\"name\":\"\"}");
|
||||
EducationInfoVerifyResponse ysBankCardTagResponse;
|
||||
ysBankCardTagResponse = openApiClient.execute(ysBankCardTagRequest);
|
||||
System.out.println(ysBankCardTagResponse.getData());
|
||||
System.out.println(ysBankCardTagResponse.getResultCode());
|
||||
System.out.println(ysBankCardTagResponse.getResultInfo());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testface001() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
EducationInfoVerifyRequest ysBankCardTagRequest = new EducationInfoVerifyRequest();
|
||||
ysBankCardTagRequest.setData("{\"orderId\":\"\",\"deviceID\":\"\"}");
|
||||
EducationInfoVerifyResponse ysBankCardTagResponse;
|
||||
ysBankCardTagResponse = openApiClient.execute(ysBankCardTagRequest);
|
||||
System.out.println(ysBankCardTagResponse.getData());
|
||||
System.out.println(ysBankCardTagResponse.getResultCode());
|
||||
System.out.println(ysBankCardTagResponse.getResultInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.AcpInstallmentRequest;
|
||||
import com.chinaums.open.api.response.AcpInstallmentResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/12/12
|
||||
* Time: 15:05
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class InstallmentTest {
|
||||
@org.junit.Test
|
||||
public void testVerifyBankCard() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url, appId, appKey);
|
||||
AcpInstallmentRequest acpInstallmentRequest = new AcpInstallmentRequest();
|
||||
acpInstallmentRequest.setMerchantCode("");
|
||||
acpInstallmentRequest.setTerminalCode("");
|
||||
acpInstallmentRequest.setSystemTraceNum("");
|
||||
acpInstallmentRequest.setTransactionCurrencyCode("156");
|
||||
acpInstallmentRequest.setTransactionAmount("");
|
||||
acpInstallmentRequest.setEncryptedData("");
|
||||
AcpInstallmentResponse acpInstallmentResponse = openApiClient.execute(acpInstallmentRequest);
|
||||
System.out.println(acpInstallmentResponse.getErrCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.TokenRequest;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/8/2
|
||||
* Time: 11:06
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class PosLinkTestCase {
|
||||
@org.junit.Test
|
||||
public void testGetToken() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
TokenRequest tokenRequest = new TokenRequest(appId,appKey);
|
||||
TokenResponse response = openApiClient.execute(tokenRequest);
|
||||
System.out.print(response.getAccessToken());
|
||||
}
|
||||
@Test
|
||||
public void testCreateRadom(){
|
||||
Random random = new Random();
|
||||
System.out.println(System.currentTimeMillis()+random.nextInt());
|
||||
System.out.println((int)((Math.random()*9+1)*100000));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.BankVerifyRequest;
|
||||
import com.chinaums.open.api.request.IdCardVerifyRequest;
|
||||
import com.chinaums.open.api.request.Mobile3factorVerifyRequest;
|
||||
import com.chinaums.open.api.request.RealNameVerifyRequest;
|
||||
import com.chinaums.open.api.response.BankVerifyResponse;
|
||||
import com.chinaums.open.api.response.IdCardVerifyResponse;
|
||||
import com.chinaums.open.api.response.Mobile3factorVerifyResponse;
|
||||
import com.chinaums.open.api.response.RealNameVerifyResponse;
|
||||
import org.junit.Test;
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/13
|
||||
* Time: 17:10
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class RealNameVerifyTestCase {
|
||||
@Test
|
||||
public void testVerifyBankCard() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
BankVerifyRequest bankVerifyRequest = new BankVerifyRequest();
|
||||
bankVerifyRequest.setData("{\"cardNo\":\"\",\"phoneNo\":\"\"}");
|
||||
BankVerifyResponse bankVerifyResponse;
|
||||
for(int i=0;i<5;i++){
|
||||
bankVerifyResponse = openApiClient.execute(bankVerifyRequest);
|
||||
System.out.println(bankVerifyResponse.getData());
|
||||
System.out.println(bankVerifyResponse.getResultCode());
|
||||
System.out.println(bankVerifyResponse.getResultInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRealNameVerify() throws OpenApiException {
|
||||
String url = "http://116.228.21.162:29015/";
|
||||
String appId = "10037e6f57c304d2015824085de80058";
|
||||
String appKey = "4e921d76ffc045d98e14999a1f67d1ea";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
RealNameVerifyRequest realNameVerifyRequest = new RealNameVerifyRequest();
|
||||
realNameVerifyRequest.setData("{\"userNo\":\"370203\",\"acctNo\":\"6214852107267879\",\"acctName\":\"李铁柱\",\"certNo\":\"370203199809012323\",\"certType\":\"00\",\"phone\":\"18970718908\"}");
|
||||
RealNameVerifyResponse realNameVerifyResponse = openApiClient.execute(realNameVerifyRequest);
|
||||
}
|
||||
@Test
|
||||
public void carreopratorVerify() throws OpenApiException {
|
||||
String url = "http://116.228.21.162:29015/";
|
||||
String appId = "10037e6f57c304d2015824085de80058";
|
||||
String appKey = "4e921d76ffc045d98e14999a1f67d1ea";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
Mobile3factorVerifyRequest request = new Mobile3factorVerifyRequest();
|
||||
request.setData("{\"userNo\":\"370203\",\"userName\":\"李铁柱\",\"certCode\":\"370203199809012323\",\"certType\":\"01\",\"phoneNo\":\"18970718908\"}");
|
||||
Mobile3factorVerifyResponse response = openApiClient.execute(request);
|
||||
System.out.println(response.getData());
|
||||
System.out.println(response.getResultInfo());
|
||||
System.out.println(response.getResultInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void idcardVerify() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "9ed4dfed9540423fa04842916c54e0d1";
|
||||
String appKey = "20f00a8b37aa4ddda56e7eed2ef6fe2b";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
IdCardVerifyRequest request = new IdCardVerifyRequest();
|
||||
request.setData("{\"userNo\":\"370203\",\"userName\":\"李铁柱\",\"certCode\":\"370203199809012323\"}");
|
||||
IdCardVerifyResponse response = openApiClient.execute(request);
|
||||
System.out.println(response.getData());
|
||||
System.out.println(response.getResultInfo());
|
||||
System.out.println(response.getResultInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.*;
|
||||
import com.chinaums.open.api.response.*;
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/6/5
|
||||
* Time: 16:18
|
||||
* 所属模块:
|
||||
* 功能说明:智慧验证相关接口验证测试
|
||||
*/
|
||||
public class SmartverificationTestCase {
|
||||
|
||||
/**
|
||||
* 银行卡验证
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
@org.junit.Test
|
||||
public void testVerifyBankCard() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url, appId, appKey);
|
||||
BankVerifyRequest bankVerifyRequest = new BankVerifyRequest();
|
||||
bankVerifyRequest.setData("{\"userNo\":\"\",\"acctNo\":\"\",\"acctName\":\"\",\"certNo\":\"\",\"certType\":\"\",\"phone\":\"\"}");
|
||||
BankVerifyResponse bankVerifyResponse;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
bankVerifyResponse = openApiClient.execute(bankVerifyRequest);
|
||||
System.out.println(bankVerifyResponse.getData());
|
||||
System.out.println(bankVerifyResponse.getResultCode());
|
||||
System.out.println(bankVerifyResponse.getResultInfo());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 实名验证
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
@org.junit.Test
|
||||
public void testRealNameVerify() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "9ed4dfed9540423fa04842916c54e0d1";
|
||||
String appKey = "20f00a8b37aa4ddda56e7eed2ef6fe2b";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url, appId, appKey);
|
||||
RealNameVerifyRequest request = new RealNameVerifyRequest();
|
||||
request.setData("{\"userNo\":\"370203\",\"acctNo\":\"6214852107267879\",\"acctName\":\"李铁柱\",\"certNo\":\"370203199809012323\",\"certType\":\"00\",\"phone\":\"18970718908\"}");
|
||||
RealNameVerifyResponse response;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
response = openApiClient.execute(request);
|
||||
System.out.println(response.getData());
|
||||
System.out.println(response.getResultCode());
|
||||
System.out.println(response.getResultInfo());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动3要素
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
@Test
|
||||
public void carreopratorVerify() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "9ed4dfed9540423fa04842916c54e0d1";
|
||||
String appKey = "20f00a8b37aa4ddda56e7eed2ef6fe2b";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
Mobile3factorVerifyRequest request = new Mobile3factorVerifyRequest();
|
||||
request.setData("{\"userNo\":\"370203\",\"userName\":\"李铁柱\",\"certCode\":\"370203199809012323\",\"certType\":\"01\",\"phoneNo\":\"18970718908\"}");
|
||||
Mobile3factorVerifyResponse response = openApiClient.execute(request);
|
||||
System.out.println(response.getData());
|
||||
System.out.println(response.getResultInfo());
|
||||
System.out.println(response.getResultInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证验证
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
@Test
|
||||
public void idcardVerify() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "9ed4dfed9540423fa04842916c54e0d1";
|
||||
String appKey = "20f00a8b37aa4ddda56e7eed2ef6fe2b";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
IdCardVerifyRequest request = new IdCardVerifyRequest();
|
||||
request.setData("{\"userNo\":\"370203\",\"userName\":\"李铁柱\",\"certCode\":\"370203199809012323\"}");
|
||||
IdCardVerifyResponse response = openApiClient.execute(request);
|
||||
System.out.println(response.getData());
|
||||
System.out.println(response.getResultInfo());
|
||||
System.out.println(response.getResultInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 楠云标签查询
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
@org.junit.Test
|
||||
public void testNyBankCardTag() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "9ed4dfed9540423fa04842916c54e0d1";
|
||||
String appKey = "20f00a8b37aa4ddda56e7eed2ef6fe2b";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
NyBankCardTagRequest nyBankCardTagRequest = new NyBankCardTagRequest();
|
||||
nyBankCardTagRequest.setData("{\"userNo\":\"000000003\",\"priAcctNo\":\"6228480028307505074\",\"riskflag\":\"1\"}");
|
||||
NyBankCardTagResponse nyBankCardTagResponse;
|
||||
nyBankCardTagResponse = openApiClient.execute(nyBankCardTagRequest);
|
||||
System.out.println(nyBankCardTagResponse.getData());
|
||||
System.out.println(nyBankCardTagResponse.getResultCode());
|
||||
System.out.println(nyBankCardTagResponse.getResultInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 盐商标签查询
|
||||
* @throws OpenApiException
|
||||
*/
|
||||
@org.junit.Test
|
||||
public void testYsBankCardTag() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "9ed4dfed9540423fa04842916c54e0d1";
|
||||
String appKey = "20f00a8b37aa4ddda56e7eed2ef6fe2b";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
YsBankCardTagRequest ysBankCardTagRequest = new YsBankCardTagRequest();
|
||||
ysBankCardTagRequest.setData("{\"phoneNo\":\"18771059056\",\"priAcctNo\":\"3568570112914437\"}");
|
||||
YsBankCardTagResponse ysBankCardTagResponse;
|
||||
ysBankCardTagResponse = openApiClient.execute(ysBankCardTagRequest);
|
||||
System.out.println(ysBankCardTagResponse.getData());
|
||||
System.out.println(ysBankCardTagResponse.getResultCode());
|
||||
System.out.println(ysBankCardTagResponse.getResultInfo());
|
||||
}
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void testEducation() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "9ed4dfed9540423fa04842916c54e0d1";
|
||||
String appKey = "20f00a8b37aa4ddda56e7eed2ef6fe2b";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
EducationInfoVerifyRequest ysBankCardTagRequest = new EducationInfoVerifyRequest();
|
||||
ysBankCardTagRequest.setData("{\"certNo\":\"342529198702131248\",\"name\":\"徐紫燕\"}");
|
||||
EducationInfoVerifyResponse ysBankCardTagResponse;
|
||||
ysBankCardTagResponse = openApiClient.execute(ysBankCardTagRequest);
|
||||
System.out.println(ysBankCardTagResponse.getData());
|
||||
System.out.println(ysBankCardTagResponse.getResultCode());
|
||||
System.out.println(ysBankCardTagResponse.getResultInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
import com.chinaums.open.api.request.TokenRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/5
|
||||
* Time: 17:05
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class TokenTestCase {
|
||||
@Test
|
||||
public void getToken() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
TokenRequest tokenRequest = new TokenRequest(appId,appKey);
|
||||
TokenResponse response = openApiClient.execute(tokenRequest);
|
||||
System.out.print(response.getAccessToken());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.TokenRequest;
|
||||
import com.chinaums.open.api.response.TokenResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2016/12/5
|
||||
* Time: 17:05
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class TokenTestCaseDev {
|
||||
@Test
|
||||
public void getToken() throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
TokenRequest tokenRequest = new TokenRequest(appId,appKey);
|
||||
TokenResponse response = openApiClient.execute(tokenRequest);
|
||||
System.out.print(response.getAccessToken());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.chinaums.test;
|
||||
|
||||
import com.chinaums.open.api.DefaultOpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiClient;
|
||||
import com.chinaums.open.api.OpenApiException;
|
||||
import com.chinaums.open.api.request.BankVerifyRequest;
|
||||
import com.chinaums.open.api.response.BankVerifyResponse;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: ZHANGWEI
|
||||
* Date: 2017/2/13
|
||||
* Time: 14:13
|
||||
* 所属模块:
|
||||
* 功能说明:
|
||||
*/
|
||||
public class UniqueTestCase {
|
||||
public static void main(String[]args) throws OpenApiException {
|
||||
String url = "https://api-mop.chinaums.com/";
|
||||
String appId = "";
|
||||
String appKey = "";
|
||||
OpenApiClient openApiClient = new DefaultOpenApiClient(url,appId,appKey);
|
||||
BankVerifyRequest bankVerifyRequest = new BankVerifyRequest();
|
||||
bankVerifyRequest.setData("{\"cardNo\":\"\",\"phoneNo\":\"\"}");
|
||||
BankVerifyResponse bankVerifyResponse;
|
||||
for(int i=0;i<5;i++){
|
||||
bankVerifyResponse = openApiClient.execute(bankVerifyRequest);
|
||||
System.out.println(bankVerifyResponse.getData());
|
||||
System.out.println(bankVerifyResponse.getResultCode());
|
||||
System.out.println(bankVerifyResponse.getResultInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user