Search in sources :

Example 1 with TransportProfile

use of org.eclipse.milo.opcua.stack.core.transport.TransportProfile in project milo by eclipse.

the class UascServerAsymmetricHandler method openSecureChannel.

private OpenSecureChannelResponse openSecureChannel(ChannelHandlerContext ctx, OpenSecureChannelRequest request) throws UaException {
    SecurityTokenRequestType requestType = request.getRequestType();
    if (requestType == SecurityTokenRequestType.Issue) {
        secureChannel.setMessageSecurityMode(request.getSecurityMode());
        String endpointUrl = ctx.channel().attr(UascServerHelloHandler.ENDPOINT_URL_KEY).get();
        EndpointDescription endpoint = stackServer.getEndpointDescriptions().stream().filter(e -> {
            boolean transportMatch = Objects.equals(e.getTransportProfileUri(), transportProfile.getUri());
            boolean pathMatch = Objects.equals(EndpointUtil.getPath(e.getEndpointUrl()), EndpointUtil.getPath(endpointUrl));
            boolean securityPolicyMatch = Objects.equals(e.getSecurityPolicyUri(), secureChannel.getSecurityPolicy().getUri());
            boolean securityModeMatch = Objects.equals(e.getSecurityMode(), request.getSecurityMode());
            return transportMatch && pathMatch && securityPolicyMatch && securityModeMatch;
        }).findFirst().orElseThrow(() -> {
            String message = String.format("no matching endpoint found: transportProfile=%s, " + "endpointUrl=%s, securityPolicy=%s, securityMode=%s", transportProfile, endpointUrl, secureChannel.getSecurityPolicy(), request.getSecurityMode());
            return new UaException(StatusCodes.Bad_SecurityChecksFailed, message);
        });
        ctx.channel().attr(ENDPOINT_KEY).set(endpoint);
    }
    if (requestType == SecurityTokenRequestType.Renew && secureChannel.getMessageSecurityMode() != request.getSecurityMode()) {
        throw new UaException(StatusCodes.Bad_SecurityChecksFailed, "secure channel renewal requested a different MessageSecurityMode.");
    }
    long channelLifetime = request.getRequestedLifetime().longValue();
    channelLifetime = Math.min(channelLifetime, stackServer.getConfig().getMaximumSecureChannelLifetime().longValue());
    channelLifetime = Math.max(channelLifetime, stackServer.getConfig().getMinimumSecureChannelLifetime().longValue());
    ChannelSecurityToken newToken = new ChannelSecurityToken(uint(secureChannel.getChannelId()), uint(stackServer.getNextTokenId()), DateTime.now(), uint(channelLifetime));
    SecurityKeys newKeys = null;
    if (secureChannel.isSymmetricSigningEnabled()) {
        // Validate the remote nonce; it must be non-null and the correct length for the security algorithm.
        ByteString remoteNonce = request.getClientNonce();
        NonceUtil.validateNonce(remoteNonce, secureChannel.getSecurityPolicy());
        ByteString localNonce = generateNonce(secureChannel.getSecurityPolicy());
        secureChannel.setLocalNonce(localNonce);
        secureChannel.setRemoteNonce(remoteNonce);
        newKeys = ChannelSecurity.generateKeyPair(secureChannel, secureChannel.getRemoteNonce(), secureChannel.getLocalNonce());
    }
    ChannelSecurity oldSecrets = secureChannel.getChannelSecurity();
    SecurityKeys oldKeys = oldSecrets != null ? oldSecrets.getCurrentKeys() : null;
    ChannelSecurityToken oldToken = oldSecrets != null ? oldSecrets.getCurrentToken() : null;
    ChannelSecurity newSecrets = new ChannelSecurity(newKeys, newToken, oldKeys, oldToken);
    secureChannel.setChannelSecurity(newSecrets);
    /*
         * Cancel the previous timeout, if it exists, and start a new one.
         */
    if (secureChannelTimeout == null || secureChannelTimeout.cancel()) {
        final long lifetime = channelLifetime;
        secureChannelTimeout = Stack.sharedWheelTimer().newTimeout(timeout -> {
            logger.debug("SecureChannel renewal timed out after {}ms. id={}, channel={}", lifetime, secureChannel.getChannelId(), ctx.channel());
            ctx.close();
        }, channelLifetime, TimeUnit.MILLISECONDS);
    }
    ResponseHeader responseHeader = new ResponseHeader(DateTime.now(), request.getRequestHeader().getRequestHandle(), StatusCode.GOOD, null, null, null);
    return new OpenSecureChannelResponse(responseHeader, uint(PROTOCOL_VERSION), newToken, secureChannel.getLocalNonce());
}
Also used : X509Certificate(java.security.cert.X509Certificate) AttributeKey(io.netty.util.AttributeKey) ErrorMessage(org.eclipse.milo.opcua.stack.core.channel.messages.ErrorMessage) KeyPair(java.security.KeyPair) ChannelSecurityToken(org.eclipse.milo.opcua.stack.core.types.structured.ChannelSecurityToken) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) LoggerFactory(org.slf4j.LoggerFactory) SecurityKeys(org.eclipse.milo.opcua.stack.core.channel.ChannelSecurity.SecurityKeys) DateTime(org.eclipse.milo.opcua.stack.core.types.builtin.DateTime) MessageEncodeException(org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) CertificateManager(org.eclipse.milo.opcua.stack.core.security.CertificateManager) TransportProfile(org.eclipse.milo.opcua.stack.core.transport.TransportProfile) SerializationQueue(org.eclipse.milo.opcua.stack.core.channel.SerializationQueue) Objects(java.util.Objects) CompositeByteBuf(io.netty.buffer.CompositeByteBuf) List(java.util.List) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) CertificateValidator(org.eclipse.milo.opcua.stack.core.security.CertificateValidator) EncodedMessage(org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.EncodedMessage) Optional(java.util.Optional) MessageType(org.eclipse.milo.opcua.stack.core.channel.messages.MessageType) BufferUtil(org.eclipse.milo.opcua.stack.core.util.BufferUtil) EndpointUtil(org.eclipse.milo.opcua.stack.core.util.EndpointUtil) ChunkDecoder(org.eclipse.milo.opcua.stack.core.channel.ChunkDecoder) ExceptionHandler(org.eclipse.milo.opcua.stack.core.channel.ExceptionHandler) HeaderDecoder(org.eclipse.milo.opcua.stack.core.channel.headers.HeaderDecoder) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) MessageDecodeException(org.eclipse.milo.opcua.stack.core.channel.MessageDecodeException) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) Stack(org.eclipse.milo.opcua.stack.core.Stack) EndpointDescription(org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription) ByteToMessageDecoder(io.netty.handler.codec.ByteToMessageDecoder) SecurityPolicy(org.eclipse.milo.opcua.stack.core.security.SecurityPolicy) UaStackServer(org.eclipse.milo.opcua.stack.server.UaStackServer) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) Timeout(io.netty.util.Timeout) AsymmetricSecurityHeader(org.eclipse.milo.opcua.stack.core.channel.headers.AsymmetricSecurityHeader) Logger(org.slf4j.Logger) NonceUtil.generateNonce(org.eclipse.milo.opcua.stack.core.util.NonceUtil.generateNonce) IOException(java.io.IOException) UaSerializationException(org.eclipse.milo.opcua.stack.core.UaSerializationException) OpenSecureChannelRequest(org.eclipse.milo.opcua.stack.core.types.structured.OpenSecureChannelRequest) MessageAbortException(org.eclipse.milo.opcua.stack.core.channel.MessageAbortException) ServerSecureChannel(org.eclipse.milo.opcua.stack.core.channel.ServerSecureChannel) OpenSecureChannelResponse(org.eclipse.milo.opcua.stack.core.types.structured.OpenSecureChannelResponse) TimeUnit(java.util.concurrent.TimeUnit) NonceUtil(org.eclipse.milo.opcua.stack.core.util.NonceUtil) ChannelSecurity(org.eclipse.milo.opcua.stack.core.channel.ChannelSecurity) UaException(org.eclipse.milo.opcua.stack.core.UaException) SecurityTokenRequestType(org.eclipse.milo.opcua.stack.core.types.enumerated.SecurityTokenRequestType) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) OpenSecureChannelResponse(org.eclipse.milo.opcua.stack.core.types.structured.OpenSecureChannelResponse) UaException(org.eclipse.milo.opcua.stack.core.UaException) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) SecurityKeys(org.eclipse.milo.opcua.stack.core.channel.ChannelSecurity.SecurityKeys) ChannelSecurity(org.eclipse.milo.opcua.stack.core.channel.ChannelSecurity) SecurityTokenRequestType(org.eclipse.milo.opcua.stack.core.types.enumerated.SecurityTokenRequestType) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) EndpointDescription(org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription) ChannelSecurityToken(org.eclipse.milo.opcua.stack.core.types.structured.ChannelSecurityToken)

Example 2 with TransportProfile

use of org.eclipse.milo.opcua.stack.core.transport.TransportProfile in project milo by eclipse.

the class UascServerHelloHandler method onHello.

private void onHello(ChannelHandlerContext ctx, ByteBuf buffer) throws UaException {
    logger.debug("[remote={}] Received Hello message.", ctx.channel().remoteAddress());
    receivedHello = true;
    final HelloMessage hello = TcpMessageDecoder.decodeHello(buffer);
    String endpointUrl = hello.getEndpointUrl();
    boolean endpointMatch = endpointUrl != null && stackServer.getEndpointDescriptions().stream().anyMatch(endpoint -> Objects.equals(EndpointUtil.getPath(endpointUrl), EndpointUtil.getPath(endpoint.getEndpointUrl())));
    if (!endpointMatch) {
        throw new UaException(StatusCodes.Bad_TcpEndpointUrlInvalid, "unrecognized endpoint url: " + endpointUrl);
    }
    ctx.channel().attr(ENDPOINT_URL_KEY).set(endpointUrl);
    long remoteProtocolVersion = hello.getProtocolVersion();
    long remoteReceiveBufferSize = hello.getReceiveBufferSize();
    long remoteSendBufferSize = hello.getSendBufferSize();
    long remoteMaxMessageSize = hello.getMaxMessageSize();
    long remoteMaxChunkCount = hello.getMaxChunkCount();
    if (remoteProtocolVersion < PROTOCOL_VERSION) {
        throw new UaException(StatusCodes.Bad_ProtocolVersionUnsupported, "unsupported protocol version: " + remoteProtocolVersion);
    }
    EncodingLimits config = stackServer.getConfig().getEncodingLimits();
    /* Our receive buffer size is determined by the remote send buffer size. */
    long localReceiveBufferSize = Math.min(remoteSendBufferSize, config.getMaxChunkSize());
    /* Our send buffer size is determined by the remote receive buffer size. */
    long localSendBufferSize = Math.min(remoteReceiveBufferSize, config.getMaxChunkSize());
    /* Max chunk count the remote can send us; not influenced by remote configuration. */
    long localMaxChunkCount = config.getMaxChunkCount();
    /* Max message size the remote can send us. Determined by our max chunk count and receive buffer size. */
    long localMaxMessageSize = Math.min(localReceiveBufferSize * localMaxChunkCount, config.getMaxMessageSize());
    ChannelParameters parameters = new ChannelParameters(Ints.saturatedCast(localMaxMessageSize), Ints.saturatedCast(localReceiveBufferSize), Ints.saturatedCast(localSendBufferSize), Ints.saturatedCast(localMaxChunkCount), Ints.saturatedCast(remoteMaxMessageSize), Ints.saturatedCast(remoteReceiveBufferSize), Ints.saturatedCast(remoteSendBufferSize), Ints.saturatedCast(remoteMaxChunkCount));
    SerializationQueue serializationQueue = new SerializationQueue(stackServer.getConfig().getExecutor(), parameters, stackServer.getSerializationContext());
    ctx.pipeline().addLast(new UascServerAsymmetricHandler(stackServer, transportProfile, serializationQueue));
    ctx.pipeline().remove(this);
    logger.debug("[remote={}] Removed HelloHandler, added AsymmetricHandler.", ctx.channel().remoteAddress());
    AcknowledgeMessage acknowledge = new AcknowledgeMessage(PROTOCOL_VERSION, localReceiveBufferSize, localSendBufferSize, localMaxMessageSize, localMaxChunkCount);
    ByteBuf messageBuffer = TcpMessageEncoder.encode(acknowledge);
    // Using ctx.executor() is necessary to ensure this handler is removed
    // before the message can be written and another response arrives.
    ctx.executor().execute(() -> ctx.writeAndFlush(messageBuffer));
    logger.debug("[remote={}] Sent Acknowledge message.", ctx.channel().remoteAddress());
}
Also used : AttributeKey(io.netty.util.AttributeKey) ErrorMessage(org.eclipse.milo.opcua.stack.core.channel.messages.ErrorMessage) ExceptionHandler(org.eclipse.milo.opcua.stack.core.channel.ExceptionHandler) LoggerFactory(org.slf4j.LoggerFactory) HeaderDecoder(org.eclipse.milo.opcua.stack.core.channel.headers.HeaderDecoder) ChannelParameters(org.eclipse.milo.opcua.stack.core.channel.ChannelParameters) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) TcpMessageEncoder(org.eclipse.milo.opcua.stack.core.channel.messages.TcpMessageEncoder) ByteBuf(io.netty.buffer.ByteBuf) Stack(org.eclipse.milo.opcua.stack.core.Stack) HelloMessage(org.eclipse.milo.opcua.stack.core.channel.messages.HelloMessage) ByteToMessageDecoder(io.netty.handler.codec.ByteToMessageDecoder) UaStackServer(org.eclipse.milo.opcua.stack.server.UaStackServer) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) TransportProfile(org.eclipse.milo.opcua.stack.core.transport.TransportProfile) Logger(org.slf4j.Logger) TcpMessageDecoder(org.eclipse.milo.opcua.stack.core.channel.messages.TcpMessageDecoder) EncodingLimits(org.eclipse.milo.opcua.stack.core.channel.EncodingLimits) AcknowledgeMessage(org.eclipse.milo.opcua.stack.core.channel.messages.AcknowledgeMessage) IOException(java.io.IOException) Ints(com.google.common.primitives.Ints) SerializationQueue(org.eclipse.milo.opcua.stack.core.channel.SerializationQueue) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) UaException(org.eclipse.milo.opcua.stack.core.UaException) MessageType(org.eclipse.milo.opcua.stack.core.channel.messages.MessageType) EndpointUtil(org.eclipse.milo.opcua.stack.core.util.EndpointUtil) ChannelParameters(org.eclipse.milo.opcua.stack.core.channel.ChannelParameters) HelloMessage(org.eclipse.milo.opcua.stack.core.channel.messages.HelloMessage) SerializationQueue(org.eclipse.milo.opcua.stack.core.channel.SerializationQueue) UaException(org.eclipse.milo.opcua.stack.core.UaException) AcknowledgeMessage(org.eclipse.milo.opcua.stack.core.channel.messages.AcknowledgeMessage) EncodingLimits(org.eclipse.milo.opcua.stack.core.channel.EncodingLimits) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with TransportProfile

use of org.eclipse.milo.opcua.stack.core.transport.TransportProfile in project milo by eclipse.

the class ServerChannelManager method bootstrap.

private static CompletableFuture<Channel> bootstrap(UaStackServer stackServer, InetSocketAddress bindAddress, TransportProfile transportProfile) {
    ChannelInitializer<SocketChannel> initializer;
    if (transportProfile == TransportProfile.TCP_UASC_UABINARY) {
        initializer = new OpcServerTcpChannelInitializer(stackServer);
    } else {
        initializer = new OpcServerHttpChannelInitializer(stackServer);
    }
    ServerBootstrap bootstrap = new ServerBootstrap();
    bootstrap.group(Stack.sharedEventLoop()).handler(new LoggingHandler(ServerChannelManager.class)).channel(NioServerSocketChannel.class).childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).childOption(ChannelOption.TCP_NODELAY, true).childHandler(initializer);
    CompletableFuture<Channel> channelFuture = new CompletableFuture<>();
    bootstrap.bind(bindAddress).addListener((ChannelFutureListener) future -> {
        if (future.isSuccess()) {
            Channel channel = future.channel();
            channelFuture.complete(channel);
        } else {
            channelFuture.completeExceptionally(future.cause());
        }
    });
    return channelFuture;
}
Also used : ChannelOption(io.netty.channel.ChannelOption) LoggingHandler(io.netty.handler.logging.LoggingHandler) Multiset(com.google.common.collect.Multiset) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) EndpointConfiguration(org.eclipse.milo.opcua.stack.server.EndpointConfiguration) Stack(org.eclipse.milo.opcua.stack.core.Stack) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) Map(java.util.Map) ChannelFutureListener(io.netty.channel.ChannelFutureListener) UaStackServer(org.eclipse.milo.opcua.stack.server.UaStackServer) SocketChannel(io.netty.channel.socket.SocketChannel) TransportProfile(org.eclipse.milo.opcua.stack.core.transport.TransportProfile) Logger(org.slf4j.Logger) ChannelInitializer(io.netty.channel.ChannelInitializer) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) InetSocketAddress(java.net.InetSocketAddress) Maps(com.google.common.collect.Maps) OpcServerHttpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.http.OpcServerHttpChannelInitializer) Channel(io.netty.channel.Channel) AsyncSemaphore(org.eclipse.milo.opcua.stack.core.util.AsyncSemaphore) ConcurrentHashMultiset(com.google.common.collect.ConcurrentHashMultiset) OpcServerTcpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.tcp.OpcServerTcpChannelInitializer) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) LoggingHandler(io.netty.handler.logging.LoggingHandler) CompletableFuture(java.util.concurrent.CompletableFuture) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) Channel(io.netty.channel.Channel) OpcServerHttpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.http.OpcServerHttpChannelInitializer) OpcServerTcpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.tcp.OpcServerTcpChannelInitializer) ServerBootstrap(io.netty.bootstrap.ServerBootstrap)

Example 4 with TransportProfile

use of org.eclipse.milo.opcua.stack.core.transport.TransportProfile in project milo by eclipse.

the class OpcClientWebSocketChannelInitializer method initChannel.

@Override
protected void initChannel(SocketChannel channel) throws Exception {
    String endpointUrl = client.getConfig().getEndpoint().getEndpointUrl();
    String scheme = EndpointUtil.getScheme(endpointUrl);
    TransportProfile transportProfile = TransportProfile.fromUri(client.getConfig().getEndpoint().getTransportProfileUri());
    String subprotocol;
    if (transportProfile == TransportProfile.WSS_UASC_UABINARY) {
        subprotocol = "opcua+cp";
    } else if (transportProfile == TransportProfile.WSS_UAJSON) {
        subprotocol = "opcua+uajson";
    } else {
        throw new UaException(StatusCodes.Bad_InternalError, "unexpected TransportProfile: " + transportProfile);
    }
    if ("opc.wss".equalsIgnoreCase(scheme)) {
        SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
        channel.pipeline().addLast(sslContext.newHandler(channel.alloc()));
    }
    int maxMessageSize = client.getConfig().getEncodingLimits().getMaxMessageSize();
    channel.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
    channel.pipeline().addLast(new HttpClientCodec());
    channel.pipeline().addLast(new HttpObjectAggregator(maxMessageSize));
    channel.pipeline().addLast(new WebSocketClientProtocolHandler(WebSocketClientHandshakerFactory.newHandshaker(new URI(endpointUrl), WebSocketVersion.V13, subprotocol, true, new DefaultHttpHeaders(), client.getConfig().getEncodingLimits().getMaxChunkSize())));
    channel.pipeline().addLast(new WebSocketFrameAggregator(client.getConfig().getEncodingLimits().getMaxMessageSize()));
    // OpcClientWebSocketFrameCodec adds UascClientAcknowledgeHandler when the WS upgrade is done.
    channel.pipeline().addLast(new OpcClientWebSocketBinaryFrameCodec(client, handshake));
}
Also used : WebSocketFrameAggregator(io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator) LoggingHandler(io.netty.handler.logging.LoggingHandler) TransportProfile(org.eclipse.milo.opcua.stack.core.transport.TransportProfile) UaException(org.eclipse.milo.opcua.stack.core.UaException) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) URI(java.net.URI) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) WebSocketClientProtocolHandler(io.netty.handler.codec.http.websocketx.WebSocketClientProtocolHandler) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) SslContext(io.netty.handler.ssl.SslContext)

Example 5 with TransportProfile

use of org.eclipse.milo.opcua.stack.core.transport.TransportProfile in project milo by eclipse.

the class UaStackClient method create.

/**
 * Create a {@link UaStackClient} with {@code config}.
 * <p>
 * The {@link UaTransport} instance to create will be inferred from the transport profile URI in the configured
 * endpoint.
 * <p>
 * Supported transports:
 * <ul>
 * <li>TCP + UA Binary</li>
 * <li>HTTP(s) + UA Binary</li>
 * </ul>
 * <p>
 * Experimentally supported:
 * <ul>
 * <li>WebSocket + UA Binary</li>
 * </ul>
 * <p>
 * Not supported:
 * <ul>
 * <li>HTTP(s) + UA JSON</li>
 * <li>HTTP(s) + UA XML</li>
 * <li>WebSocket + UA JSON</li>
 * </ul>
 *
 * @param config the {@link UaStackClientConfig}.
 * @return a {@link UaStackClient} created with {@code config}.
 * @throws UaException if the transport is unsupported.
 */
public static UaStackClient create(UaStackClientConfig config) throws UaException {
    String transportProfileUri = config.getEndpoint().getTransportProfileUri();
    TransportProfile transportProfile = TransportProfile.fromUri(transportProfileUri);
    Function<UaStackClient, UaTransport> transportFactory;
    switch(transportProfile) {
        case TCP_UASC_UABINARY:
            transportFactory = OpcTcpTransport::new;
            break;
        case HTTPS_UABINARY:
            transportFactory = OpcHttpTransport::new;
            break;
        case WSS_UASC_UABINARY:
            transportFactory = OpcWebSocketTransport::new;
            break;
        case HTTPS_UAXML:
        case HTTPS_UAJSON:
        case WSS_UAJSON:
        default:
            throw new UaException(StatusCodes.Bad_InternalError, "unsupported transport: " + transportProfileUri);
    }
    return new UaStackClient(config, transportFactory);
}
Also used : OpcTcpTransport(org.eclipse.milo.opcua.stack.client.transport.tcp.OpcTcpTransport) OpcWebSocketTransport(org.eclipse.milo.opcua.stack.client.transport.websocket.OpcWebSocketTransport) TransportProfile(org.eclipse.milo.opcua.stack.core.transport.TransportProfile) UaTransport(org.eclipse.milo.opcua.stack.client.transport.UaTransport) UaException(org.eclipse.milo.opcua.stack.core.UaException) OpcHttpTransport(org.eclipse.milo.opcua.stack.client.transport.http.OpcHttpTransport)

Aggregations

TransportProfile (org.eclipse.milo.opcua.stack.core.transport.TransportProfile)5 UaException (org.eclipse.milo.opcua.stack.core.UaException)4 Stack (org.eclipse.milo.opcua.stack.core.Stack)3 UaStackServer (org.eclipse.milo.opcua.stack.server.UaStackServer)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 ByteBuf (io.netty.buffer.ByteBuf)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 ByteToMessageDecoder (io.netty.handler.codec.ByteToMessageDecoder)2 LoggingHandler (io.netty.handler.logging.LoggingHandler)2 AttributeKey (io.netty.util.AttributeKey)2 IOException (java.io.IOException)2 List (java.util.List)2 Objects (java.util.Objects)2 TimeUnit (java.util.concurrent.TimeUnit)2 StatusCodes (org.eclipse.milo.opcua.stack.core.StatusCodes)2 ExceptionHandler (org.eclipse.milo.opcua.stack.core.channel.ExceptionHandler)2 SerializationQueue (org.eclipse.milo.opcua.stack.core.channel.SerializationQueue)2 HeaderDecoder (org.eclipse.milo.opcua.stack.core.channel.headers.HeaderDecoder)2 ErrorMessage (org.eclipse.milo.opcua.stack.core.channel.messages.ErrorMessage)2