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


Java SecurityTokenRequestType类代码示例

本文整理汇总了Java中com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType的典型用法代码示例。如果您正苦于以下问题:Java SecurityTokenRequestType类的具体用法?Java SecurityTokenRequestType怎么用?Java SecurityTokenRequestType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SecurityTokenRequestType类属于com.digitalpetri.opcua.stack.core.types.enumerated包,在下文中一共展示了SecurityTokenRequestType类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handlerAdded

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
    SecurityTokenRequestType requestType = secureChannel.getChannelId() == 0 ?
            SecurityTokenRequestType.Issue : SecurityTokenRequestType.Renew;

    secureChannelTimeout = client.getConfig().getWheelTimer().newTimeout(
            timeout -> {
                if (!timeout.isCancelled()) {
                    handshakeFuture.completeExceptionally(
                            new UaException(
                                    StatusCodes.Bad_Timeout,
                                    "timed out waiting for secure channel"));
                    ctx.close();
                }
            },
            5, TimeUnit.SECONDS
    );

    logger.debug("OpenSecureChannel timeout scheduled for +5s");

    sendOpenSecureChannelRequest(ctx, requestType);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:23,代码来源:UaTcpClientMessageHandler.java

示例2: OpenSecureChannelRequest

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
public OpenSecureChannelRequest(RequestHeader _requestHeader, UInteger _clientProtocolVersion, SecurityTokenRequestType _requestType, MessageSecurityMode _securityMode, ByteString _clientNonce, UInteger _requestedLifetime) {
    this._requestHeader = _requestHeader;
    this._clientProtocolVersion = _clientProtocolVersion;
    this._requestType = _requestType;
    this._securityMode = _securityMode;
    this._clientNonce = _clientNonce;
    this._requestedLifetime = _requestedLifetime;
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:9,代码来源:OpenSecureChannelRequest.java

示例3: decode

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
public static OpenSecureChannelRequest decode(UaDecoder decoder) {
    RequestHeader _requestHeader = decoder.decodeSerializable("RequestHeader", RequestHeader.class);
    UInteger _clientProtocolVersion = decoder.decodeUInt32("ClientProtocolVersion");
    SecurityTokenRequestType _requestType = decoder.decodeEnumeration("RequestType", SecurityTokenRequestType.class);
    MessageSecurityMode _securityMode = decoder.decodeEnumeration("SecurityMode", MessageSecurityMode.class);
    ByteString _clientNonce = decoder.decodeByteString("ClientNonce");
    UInteger _requestedLifetime = decoder.decodeUInt32("RequestedLifetime");

    return new OpenSecureChannelRequest(_requestHeader, _clientProtocolVersion, _requestType, _securityMode, _clientNonce, _requestedLifetime);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:11,代码来源:OpenSecureChannelRequest.java

示例4: getRequestType

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
@Override
public SecurityTokenRequestType getRequestType() {
    Optional<SecurityTokenRequestType> property = getProperty(AuditOpenSecureChannelEventType.REQUEST_TYPE);

    return property.orElse(null);
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:7,代码来源:AuditOpenSecureChannelEventNode.java

示例5: setRequestType

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
@Override
public void setRequestType(SecurityTokenRequestType value) {
    setProperty(AuditOpenSecureChannelEventType.REQUEST_TYPE, value);
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:5,代码来源:AuditOpenSecureChannelEventNode.java

示例6: sendOpenSecureChannelRequest

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
private void sendOpenSecureChannelRequest(ChannelHandlerContext ctx, SecurityTokenRequestType requestType) {
    SecurityAlgorithm algorithm = secureChannel.getSecurityPolicy().getSymmetricEncryptionAlgorithm();
    int nonceLength = NonceUtil.getNonceLength(algorithm);

    ByteString clientNonce = secureChannel.isSymmetricSigningEnabled() ?
            NonceUtil.generateNonce(nonceLength) :
            ByteString.NULL_VALUE;

    secureChannel.setLocalNonce(clientNonce);

    OpenSecureChannelRequest request = new OpenSecureChannelRequest(
            new RequestHeader(null, DateTime.now(), uint(0), uint(0), null, uint(0), null),
            uint(PROTOCOL_VERSION),
            requestType,
            secureChannel.getMessageSecurityMode(),
            secureChannel.getLocalNonce(),
            client.getChannelLifetime());

    encodeMessage(request, MessageType.OpenSecureChannel).whenComplete((t2, ex) -> {
        if (ex != null) {
            ctx.close();
            return;
        }

        List<ByteBuf> chunks = t2.v2();

        ctx.executor().execute(() -> {
            chunks.forEach(c -> ctx.write(c, ctx.voidPromise()));
            ctx.flush();
        });

        ChannelSecurity channelSecurity = secureChannel.getChannelSecurity();

        long currentTokenId = channelSecurity != null ?
                channelSecurity.getCurrentToken().getTokenId().longValue() : -1L;

        long previousTokenId = channelSecurity != null ?
                channelSecurity.getPreviousToken().map(token -> token.getTokenId().longValue()).orElse(-1L) : -1L;

        logger.debug(
                "Sent OpenSecureChannelRequest ({}, id={}, currentToken={}, previousToken={}).",
                request.getRequestType(), secureChannel.getChannelId(), currentTokenId, previousTokenId);
    });
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:45,代码来源:UaTcpClientMessageHandler.java

示例7: installSecurityToken

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
private void installSecurityToken(ChannelHandlerContext ctx, OpenSecureChannelResponse response) {
    ChannelSecurity.SecuritySecrets newKeys = null;
    if (response.getServerProtocolVersion().longValue() < PROTOCOL_VERSION) {
        throw new UaRuntimeException(StatusCodes.Bad_ProtocolVersionUnsupported,
                "server protocol version unsupported: " + response.getServerProtocolVersion());
    }

    ChannelSecurityToken newToken = response.getSecurityToken();

    if (secureChannel.isSymmetricSigningEnabled()) {
        secureChannel.setRemoteNonce(response.getServerNonce());

        newKeys = ChannelSecurity.generateKeyPair(
                secureChannel,
                secureChannel.getLocalNonce(),
                secureChannel.getRemoteNonce()
        );
    }

    ChannelSecurity oldSecrets = secureChannel.getChannelSecurity();
    ChannelSecurity.SecuritySecrets oldKeys = oldSecrets != null ? oldSecrets.getCurrentKeys() : null;
    ChannelSecurityToken oldToken = oldSecrets != null ? oldSecrets.getCurrentToken() : null;

    secureChannel.setChannelSecurity(new ChannelSecurity(newKeys, newToken, oldKeys, oldToken));

    DateTime createdAt = response.getSecurityToken().getCreatedAt();
    long revisedLifetime = response.getSecurityToken().getRevisedLifetime().longValue();

    if (revisedLifetime > 0) {
        long renewAt = (long) (revisedLifetime * 0.75);
        renewFuture = ctx.executor().schedule(
                () -> sendOpenSecureChannelRequest(ctx, SecurityTokenRequestType.Renew),
                renewAt, TimeUnit.MILLISECONDS);
    } else {
        logger.warn("Server revised secure channel lifetime to 0; renewal will not occur.");
    }

    ctx.executor().execute(() -> {
        // SecureChannel is ready; remove the acknowledge handler.
        if (ctx.pipeline().get(UaTcpClientAcknowledgeHandler.class) != null) {
            ctx.pipeline().remove(UaTcpClientAcknowledgeHandler.class);
        }
    });

    ChannelSecurity channelSecurity = secureChannel.getChannelSecurity();

    long currentTokenId = channelSecurity.getCurrentToken().getTokenId().longValue();

    long previousTokenId = channelSecurity.getPreviousToken()
            .map(t -> t.getTokenId().longValue()).orElse(-1L);

    logger.debug(
            "SecureChannel id={}, currentTokenId={}, previousTokenId={}, lifetime={}ms, createdAt={}",
            secureChannel.getChannelId(), currentTokenId, previousTokenId, revisedLifetime, createdAt);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:56,代码来源:UaTcpClientMessageHandler.java

示例8: getRequestType

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
SecurityTokenRequestType getRequestType(); 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:2,代码来源:AuditOpenSecureChannelEventType.java

示例9: setRequestType

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
void setRequestType(SecurityTokenRequestType value); 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:2,代码来源:AuditOpenSecureChannelEventType.java

示例10: getRequestType

import com.digitalpetri.opcua.stack.core.types.enumerated.SecurityTokenRequestType; //导入依赖的package包/类
public SecurityTokenRequestType getRequestType() { return _requestType; } 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:2,代码来源:OpenSecureChannelRequest.java


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