当前位置: 首页>>代码示例>>Java>>正文


Java StatusCodes.Bad_SecureChannelTokenUnknown方法代码示例

本文整理汇总了Java中com.digitalpetri.opcua.stack.core.StatusCodes.Bad_SecureChannelTokenUnknown方法的典型用法代码示例。如果您正苦于以下问题:Java StatusCodes.Bad_SecureChannelTokenUnknown方法的具体用法?Java StatusCodes.Bad_SecureChannelTokenUnknown怎么用?Java StatusCodes.Bad_SecureChannelTokenUnknown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.digitalpetri.opcua.stack.core.StatusCodes的用法示例。


在下文中一共展示了StatusCodes.Bad_SecureChannelTokenUnknown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateChunkHeaders

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private void validateChunkHeaders(List<ByteBuf> chunkBuffers) throws UaException {
    ChannelSecurity channelSecurity = secureChannel.getChannelSecurity();
    long currentTokenId = channelSecurity.getCurrentToken().getTokenId().longValue();
    long previousTokenId = channelSecurity.getPreviousToken()
            .map(t -> t.getTokenId().longValue())
            .orElse(-1L);

    for (ByteBuf chunkBuffer : chunkBuffers) {
        chunkBuffer.skipBytes(3 + 1 + 4 + 4); // skip messageType, chunkType, messageSize, secureChannelId

        SymmetricSecurityHeader securityHeader = SymmetricSecurityHeader.decode(chunkBuffer);

        if (securityHeader.getTokenId() != currentTokenId) {
            if (securityHeader.getTokenId() != previousTokenId) {
                String message = String.format(
                        "received unknown secure channel token. " +
                                "tokenId=%s, currentTokenId=%s, previousTokenId=%s",
                        securityHeader.getTokenId(), currentTokenId, previousTokenId);

                throw new UaException(StatusCodes.Bad_SecureChannelTokenUnknown, message);
            }
        }

        chunkBuffer.readerIndex(0);
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:27,代码来源:UaTcpServerSymmetricHandler.java

示例2: readSecurityHeader

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void readSecurityHeader(SecureChannel channel, ByteBuf chunkBuffer) throws UaException {
    long receivedTokenId = SymmetricSecurityHeader.decode(chunkBuffer).getTokenId();

    ChannelSecurity channelSecurity = channel.getChannelSecurity();

    if (channelSecurity == null) {
        if (receivedTokenId != 0L) {
            throw new UaException(StatusCodes.Bad_SecureChannelTokenUnknown,
                    "unknown secure channel token: " + receivedTokenId);
        }
    } else {
        long currentTokenId = channelSecurity.getCurrentToken().getTokenId().longValue();

        if (receivedTokenId == currentTokenId) {
            securitySecrets = channelSecurity.getCurrentKeys();
        } else {
            long previousTokenId = channelSecurity.getPreviousToken()
                    .map(t -> t.getTokenId().longValue())
                    .orElse(-1L);

            logger.debug("Attempting to use SecuritySecrets from previousTokenId={}", previousTokenId);

            if (receivedTokenId != previousTokenId) {
                logger.warn("receivedTokenId={} did not match previousTokenId={}", receivedTokenId, previousTokenId);

                throw new UaException(StatusCodes.Bad_SecureChannelTokenUnknown,
                        "unknown secure channel token: " + receivedTokenId);
            }

            if (channel.isSymmetricEncryptionEnabled() && channelSecurity.getPreviousKeys().isPresent()) {
                securitySecrets = channelSecurity.getPreviousKeys().get();
            }
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:37,代码来源:ChunkDecoder.java


注:本文中的com.digitalpetri.opcua.stack.core.StatusCodes.Bad_SecureChannelTokenUnknown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。