Search in sources :

Example 1 with SdkRequestNodeUpdateTopicStatus

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());
}
Also used : ChannelRequest(org.fisco.bcos.channel.dto.ChannelRequest) SdkRequestNodeUpdateTopicStatus(org.fisco.bcos.channel.protocol.SdkRequestNodeUpdateTopicStatus) TopicVerifyRespProtocol(org.fisco.bcos.channel.protocol.TopicVerifyRespProtocol)

Aggregations

ChannelRequest (org.fisco.bcos.channel.dto.ChannelRequest)1 SdkRequestNodeUpdateTopicStatus (org.fisco.bcos.channel.protocol.SdkRequestNodeUpdateTopicStatus)1 TopicVerifyRespProtocol (org.fisco.bcos.channel.protocol.TopicVerifyRespProtocol)1