本文整理汇总了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);
}
}
示例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();
}
}
}
}