Skip to content

Commit

Permalink
Merge pull request #140 from yg3630536/feature/bar-code-transportation
Browse files Browse the repository at this point in the history
* add barCode transportation code
  • Loading branch information
chaoxinhu committed Mar 17, 2020
2 parents 046f39c + 59be99e commit b9798c8
Show file tree
Hide file tree
Showing 51 changed files with 2,746 additions and 77 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ List mysql_driver = [
]

List zxing = [
"com.google.zxing:core:3.3.0"
"com.google.zxing:core:3.3.3",
"com.google.zxing:javase:3.3.3"
]

List rpc = [
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/webank/weid/constant/AmopMsgType.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ public enum AmopMsgType {
/**
* 请求weIdAuth.
*/
GET_WEID_AUTH(8);
GET_WEID_AUTH(8),

/**
* 新版本amop请求.
*/
COMMON_REQUEST(9);

private Integer value;

Expand Down Expand Up @@ -157,14 +162,19 @@ public String callOnPush(AmopCallback amopCallback, String messageId, String msg
resultBodyStr = DataToolUtils.serialize(result);
break;
}

case REQUEST_VERIFY_CHALLENGE: {
RequestVerifyChallengeArgs args =
DataToolUtils.deserialize(msgBodyStr, RequestVerifyChallengeArgs.class);
RequestVerifyChallengeResponse result = amopCallback.onPush(args);
resultBodyStr = DataToolUtils.serialize(result);
break;
}
case COMMON_REQUEST: {
AmopCommonArgs args = DataToolUtils.deserialize(msgBodyStr, AmopCommonArgs.class);
AmopResponse result = amopCallback.onPush(args);
resultBodyStr = DataToolUtils.serialize(result);
break;
}
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public final class DataDriverConstant {
/**
* 系统默认的domain.
*/
public static final String DOMAIN_DEFAULT = "domain.default";
public static final String DOMAIN_DEFAULT_TIMEOUT = "domain.default.timeout";
public static final String DOMAIN_DEFAULT_INFO = "domain.defaultInfo";
public static final String DOMAIN_DEFAULT_INFO_TIMEOUT = "domain.defaultInfo.timeout";

/**
* 系统domain之私钥存储domainKey.
Expand All @@ -183,4 +183,6 @@ public final class DataDriverConstant {
public static final String DOMAIN_USER_MASTER_SECRET = "domain.masterKey";

public static final String DOMAIN_USER_CREDENTIAL_SIGNATURE = "domain.credentialSignature";

public static final String DOMAIN_RESOURCE_INFO = "domain.resourceInfo";
}
41 changes: 41 additions & 0 deletions src/main/java/com/webank/weid/constant/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,21 @@ public enum ErrorCode {
* pdf transfer error.
*/
TRANSPORTATION_PDF_VERIFY_ERROR(100809, "pdf verify error, please check the error log."),

/**
* the transmission type is invalid.
*/
TRANSPORTATION_TRANSMISSION_TYPE_INVALID(100810, "the transmission type is invalid."),

/**
* the URI type is invalid.
*/
TRANSPORTATION_URI_TYPE_INVALID(100811, "the URI type is invalid."),

/**
* no spcifyer to set.
*/
TRANSPORTATION_NO_SPECIFYER_TO_SET(100812, "no spcifyer to set."),

/**
* Authority issuer main error code.
Expand Down Expand Up @@ -689,6 +704,22 @@ public enum ErrorCode {
100113,
"weIdAuth callback is not registered."
),

/**
* the channelId is null.
*/
WEID_AUTH_CHANNELID_IS_NULL(
100114,
"the channelId is null."
),

/**
* the channelId is invalid.
*/
WEID_AUTH_CHANNELID_INVALID(
100115,
"the channelId is invalid."
),

/**
* transaction timeout.
Expand Down Expand Up @@ -784,6 +815,16 @@ public enum ErrorCode {
*/
CNS_CODE_UNDEFINED(160020, "the code is undefined."),

/**
* the data does not exist.
*/
SQL_DATA_DOES_NOT_EXIST(160021, "the data does not exist."),

/**
* this is be deprecated.
*/
THIS_IS_DEPRECATED(160022, "this is be deprecated."),

/**
* other uncatched exceptions or error.
*/
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/webank/weid/constant/ServiceType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright© (2018-2020) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
* weid-java-sdk is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* weid-java-sdk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with weid-java-sdk. If not, see <https://www.gnu.org/licenses/>.
*/

package com.webank.weid.constant;

public enum ServiceType {
SYS_GET_BARCODE_DATA
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright© (2018-2019) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
* weid-java-sdk is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* weid-java-sdk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with weid-java-sdk. If not, see <https://www.gnu.org/licenses/>.
*/

package com.webank.weid.protocol.amop;

import java.util.Map;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import com.webank.weid.protocol.amop.base.AmopBaseMsgArgs;

/**
* the request body for get EncryptKey.
*
* @author tonychen 2019年5月7日.
*
*/
@Getter
@Setter
@ToString
public class GetBarCodeDataArgs extends AmopBaseMsgArgs {

/**
* the resource Id.
*/
private String resourceId;

/**
* weId信息.
*/
private String weId;

/**
* 签名信息.
*/
private String signValue;

/**
* 扩展字符串字段.
*/
private Map<String, String> extra;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ public class AmopBaseMsgArgs implements IArgs {
* 目的机构id.
*/
protected String toOrgId;

/**
* 业务类型.
*/
protected String serviceType;

/**
* 通道编号.
*/
protected String channelId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import lombok.Data;

import com.webank.weid.constant.ErrorCode;
import com.webank.weid.protocol.inf.IResult;

/**
Expand Down Expand Up @@ -47,9 +48,26 @@ public class AmopResponse implements IResult {
* 错误信息.
*/
protected String errorMessage;

/**
* 消息编号.
*/
protected String messageId;

/**
* 无参构造器.
*/
public AmopResponse() {
super();
}

/**
* ErrorCode造器.
* @param errorCode 错误码
*/
public AmopResponse(ErrorCode errorCode) {
this();
this.errorCode = errorCode.getCode();
this.errorMessage = errorCode.getCodeDesc();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.webank.weid.protocol.response;

import lombok.Getter;
import lombok.Setter;

/**
* the getEncryptKey response.
* @author tonychen 2019年5月7日
*
*/
@Getter
@Setter
public class GetBarCodeDataResponse {

/**
* 返回的消息.
*/
private String result;

/**
* 错误码.
*/
private Integer errorCode;

/**
* 错误信息.
*/
protected String errorMessage;
}
5 changes: 4 additions & 1 deletion src/main/java/com/webank/weid/rpc/AmopService.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,25 @@ ResponseData<RequestIssueCredentialResponse> requestIssueCredential(
String toOrgId,
RequestIssueCredentialArgs args
);

ResponseData<AmopResponse> send(String toOrgId, AmopCommonArgs args);

/**
* get weIdAuth object.
* @param toOrgId target organization id
* @param args random number
* @return return the GetWeIdAuthResponse
*/
ResponseData<GetWeIdAuthResponse> getWeIdAuth(
String toOrgId,
GetWeIdAuthArgs args
);


/**
* verify challenge signature.
* @param toOrgId target organization id
* @param args verify args
* @return return the RequestVerifyChallengeResponse
*/
ResponseData<RequestVerifyChallengeResponse> requestVerifyChallenge(
String toOrgId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public void registAmopCallback(Integer msgType, AmopCallback routeCallBack) {
amopCallBackMap.put(msgType, routeCallBack);
}

public AmopCallback getAmopCallback(Integer msgType) {
return amopCallBackMap.get(msgType);
}

@Override
public void onPush(ChannelPush push) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public class OnNotifyCallbackV2 extends ChannelPushCallback implements RegistCal
public void registAmopCallback(Integer msgType, AmopCallback routeCallBack) {
amopCallBackMap.put(msgType, routeCallBack);
}


public AmopCallback getAmopCallback(Integer msgType) {
return amopCallBackMap.get(msgType);
}

@Override
public void onPush(ChannelPush push) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
public interface RegistCallBack {

public void registAmopCallback(Integer msgType, AmopCallback routeCallBack);

public AmopCallback getAmopCallback(Integer msgType);
}
5 changes: 5 additions & 0 deletions src/main/java/com/webank/weid/service/fisco/WeServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.webank.weid.service.fisco.v1.WeServerV1;
import com.webank.weid.service.fisco.v2.WeServerV2;
import com.webank.weid.service.impl.base.AmopCommonArgs;
import com.webank.weid.service.impl.callback.CommonCallback;
import com.webank.weid.service.impl.callback.KeyManagerCallback;
import com.webank.weid.util.PropertyUtils;

Expand Down Expand Up @@ -130,6 +131,10 @@ private void registDefaultCallback() {
AmopMsgType.GET_ENCRYPT_KEY.getValue(),
new KeyManagerCallback()
);
pushCallBack.registAmopCallback(
AmopMsgType.COMMON_REQUEST.getValue(),
new CommonCallback()
);
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/webank/weid/service/impl/AmopServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,19 @@ public ResponseData<RequestVerifyChallengeResponse> requestVerifyChallenge(Strin

return resp;
}

/**
* 发送通用消息的AMOP请求接口.
*/
public ResponseData<AmopResponse> send(String toOrgId, AmopCommonArgs args) {
return this.getImpl(
fiscoConfig.getCurrentOrgId(),
toOrgId,
args,
AmopCommonArgs.class,
AmopResponse.class,
AmopMsgType.COMMON_REQUEST,
WeServer.AMOP_REQUEST_TIMEOUT
);
}
}

0 comments on commit b9798c8

Please sign in to comment.