use of org.fisco.bcos.channel.protocol.SdkRequestNodeUpdateTopicStatus in project web3sdk by FISCO-BCOS.
the class Service method checkSignForAmop.
public void checkSignForAmop(String topic, String randValue, String nodeid, ChannelHandlerContext ctx, ChannelResponse response) throws IOException {
if (response.getErrorCode() != 0) {
logger.error("get signature failed :{}:{}", response.getErrorCode(), response.getErrorMessage());
return;
}
logger.info("check signature:{} length:{}", Arrays.toString(response.getContentByteArray()), response.getContentByteArray().length);
String content = topicVerify.parseDataFromPush(response.getContentByteArray().length, response.getContentByteArray());
logger.info("content:{} content:{}", content, Arrays.toString(content.getBytes()));
TopicVerifyRespProtocol topicVerifyRespProtocol = ObjectMapperFactory.getObjectMapper().readValue(content, TopicVerifyRespProtocol.class);
String signature = topicVerifyRespProtocol.getSignature();
logger.info("signature:{} ", signature);
int checkResult = topicVerify.checkSignatureValidate(topic, signature, randValue);
SdkRequestNodeUpdateTopicStatus sdkRequestNodeUpdateTopicStatus = new SdkRequestNodeUpdateTopicStatus();
sdkRequestNodeUpdateTopicStatus.setCheckResult(checkResult);
sdkRequestNodeUpdateTopicStatus.setNodeId(nodeid);
sdkRequestNodeUpdateTopicStatus.setTopic(topic);
String jsonStr = ObjectMapperFactory.getObjectMapper().writeValueAsString(sdkRequestNodeUpdateTopicStatus);
logger.info("check signature result:{}", jsonStr);
ChannelRequest request = new ChannelRequest();
request.setMessageID(newSeq());
request.setToTopic(topic);
request.setTimeout(5000);
request.setContent(jsonStr.getBytes());
sendCheckResultToNode(request, ctx, (short) ChannelMessageType.UPDATE_TOPIICSTATUS.getType());
}
Aggregations