當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。