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


Java EndpointDescription类代码示例

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


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

示例1: getEndpoints

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
/**
 * Query the GetEndpoints service at the given endpoint URL.
 *
 * @param endpointUrl the endpoint URL to get endpoints from.
 * @return the {@link EndpointDescription}s returned by the GetEndpoints service.
 */
public static CompletableFuture<EndpointDescription[]> getEndpoints(String endpointUrl) {
    UaTcpStackClientConfig config = UaTcpStackClientConfig.builder()
            .setEndpointUrl(endpointUrl)
            .build();

    UaTcpStackClient client = new UaTcpStackClient(config);

    GetEndpointsRequest request = new GetEndpointsRequest(
            new RequestHeader(null, DateTime.now(), uint(1), uint(0), null, uint(5000), null),
            endpointUrl, null, new String[]{Stack.UA_TCP_BINARY_TRANSPORT_URI});

    return client.<GetEndpointsResponse>sendRequest(request)
            .whenComplete((r, ex) -> client.disconnect())
            .thenApply(GetEndpointsResponse::getEndpoints);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:22,代码来源:UaTcpStackClient.java

示例2: ClientExample

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
public ClientExample(X509Certificate certificate, KeyPair keyPair) throws Exception {
    // Query endpoints and select highest security level.
    EndpointDescription[] endpoints = UaTcpStackClient.getEndpoints("opc.tcp://localhost:12685/example").get();

    EndpointDescription endpoint = Arrays.stream(endpoints)
            .sorted((e1, e2) -> e2.getSecurityLevel().intValue() - e1.getSecurityLevel().intValue())
            .findFirst()
            .orElseThrow(() -> new Exception("no endpoints returned"));

    UaTcpStackClientConfig config = UaTcpStackClientConfig.builder()
            .setApplicationName(LocalizedText.english("Stack Example Client"))
            .setApplicationUri(String.format("urn:example-client:%s", UUID.randomUUID()))
            .setCertificate(certificate)
            .setKeyPair(keyPair)
            .setEndpoint(endpoint)
            .build();

    client = new UaTcpStackClient(config);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:20,代码来源:ClientExample.java

示例3: onGetEndpoints

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Override
public void onGetEndpoints(ServiceRequest<GetEndpointsRequest, GetEndpointsResponse> serviceRequest) {
    GetEndpointsRequest request = serviceRequest.getRequest();

    List<String> profileUris = request.getProfileUris() != null ?
            newArrayList(request.getProfileUris()) :
            new ArrayList<>();

    List<EndpointDescription> allEndpoints = endpoints.stream()
            .map(UaTcpStackServer.this::mapEndpoint)
            .filter(ed -> filterProfileUris(ed, profileUris))
            .collect(toList());

    List<EndpointDescription> matchingEndpoints = allEndpoints.stream()
            .filter(ed -> filterEndpointUrls(ed, request.getEndpointUrl()))
            .collect(toList());

    GetEndpointsResponse response = new GetEndpointsResponse(
            serviceRequest.createResponseHeader(),
            matchingEndpoints.isEmpty() ?
                    a(allEndpoints, EndpointDescription.class) :
                    a(matchingEndpoints, EndpointDescription.class)
    );

    serviceRequest.setResponse(response);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:27,代码来源:UaTcpStackServer.java

示例4: endpointMatchesUrl

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
private boolean endpointMatchesUrl(EndpointDescription endpoint, String endpointUrl) {
    try {
        String requestedHost = new URI(endpointUrl).parseServerAuthority().getHost();
        String endpointHost = new URI(endpoint.getEndpointUrl()).parseServerAuthority().getHost();

        return requestedHost.equalsIgnoreCase(endpointHost);
    } catch (Throwable e) {
        logger.warn("Unable to create URI.", e);
        return false;
    }
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:12,代码来源:SessionManager.java

示例5: UaTcpStackClientConfigImpl

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
public UaTcpStackClientConfigImpl(@Nullable String endpointUrl,
                                  @Nullable EndpointDescription endpoint,
                                  @Nullable KeyPair keyPair,
                                  @Nullable X509Certificate certificate,
                                  LocalizedText applicationName,
                                  String applicationUri,
                                  String productUri,
                                  ChannelConfig channelConfig,
                                  UInteger channelLifetime,
                                  ExecutorService executor,
                                  NioEventLoopGroup eventLoop,
                                  HashedWheelTimer wheelTimer,
                                  boolean secureChannelReauthenticationEnabled) {

    this.endpointUrl = endpointUrl;
    this.endpoint = endpoint;
    this.keyPair = keyPair;
    this.certificate = certificate;
    this.applicationName = applicationName;
    this.applicationUri = applicationUri;
    this.productUri = productUri;
    this.channelConfig = channelConfig;
    this.channelLifetime = channelLifetime;
    this.executor = executor;
    this.eventLoop = eventLoop;
    this.wheelTimer = wheelTimer;
    this.secureChannelReauthenticationEnabled = secureChannelReauthenticationEnabled;
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:29,代码来源:UaTcpStackClientConfigBuilder.java

示例6: testClientServerRoundTrip_TestStack_NoSecurity

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test(dataProvider = "getVariants")
public void testClientServerRoundTrip_TestStack_NoSecurity(Variant input) throws Exception {
    EndpointDescription endpoint = endpoints[0];

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    connectAndTest(input, client);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:12,代码来源:ClientServerTest.java

示例7: testClientServerRoundTrip_TestStack_Basic128Rsa15_Sign

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test(dataProvider = "getVariants")
public void testClientServerRoundTrip_TestStack_Basic128Rsa15_Sign(Variant input) throws Exception {
    EndpointDescription endpoint = endpoints[1];

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    connectAndTest(input, client);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:12,代码来源:ClientServerTest.java

示例8: testClientServerRoundTrip_TestStack_Basic256_Sign

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test(dataProvider = "getVariants")
public void testClientServerRoundTrip_TestStack_Basic256_Sign(Variant input) throws Exception {
    EndpointDescription endpoint = endpoints[2];

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    connectAndTest(input, client);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:12,代码来源:ClientServerTest.java

示例9: testClientServerRoundTrip_TestStack_Basic256Sha256_Sign

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test(dataProvider = "getVariants")
public void testClientServerRoundTrip_TestStack_Basic256Sha256_Sign(Variant input) throws Exception {
    EndpointDescription endpoint = endpoints[3];

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    connectAndTest(input, client);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:12,代码来源:ClientServerTest.java

示例10: testClientServerRoundTrip_TestStack_Basic128Rsa15_SignAndEncrypt

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test(dataProvider = "getVariants")
public void testClientServerRoundTrip_TestStack_Basic128Rsa15_SignAndEncrypt(Variant input) throws Exception {
    EndpointDescription endpoint = endpoints[4];

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    connectAndTest(input, client);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:12,代码来源:ClientServerTest.java

示例11: testClientServerRoundTrip_TestStack_Basic256_SignAndEncrypt

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test(dataProvider = "getVariants")
public void testClientServerRoundTrip_TestStack_Basic256_SignAndEncrypt(Variant input) throws Exception {
    EndpointDescription endpoint = endpoints[5];

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    connectAndTest(input, client);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:12,代码来源:ClientServerTest.java

示例12: testClientServerRoundTrip_TestStack_Basic256Sha256_SignAndEncrypt

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test(dataProvider = "getVariants")
public void testClientServerRoundTrip_TestStack_Basic256Sha256_SignAndEncrypt(Variant input) throws Exception {
    EndpointDescription endpoint = endpoints[6];

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    connectAndTest(input, client);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:12,代码来源:ClientServerTest.java

示例13: testClientDisconnect

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test
public void testClientDisconnect() throws Exception {
    EndpointDescription endpoint = endpoints[0];
    Variant input = new Variant(42);

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
        SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    RequestHeader header = new RequestHeader(
        NodeId.NULL_VALUE,
        DateTime.now(),
        uint(0), uint(0), null, uint(60000), null);

    TestStackRequest request = new TestStackRequest(header, uint(0), 0, input);

    logger.info("sending request: {}", request);
    UaResponseMessage response0 = client.sendRequest(request).get();
    logger.info("got response: {}", response0);

    // client doesn't wait for server to close the channel, it
    // closes after flushing the message, so we need to delay
    // here for the purpose of testing. we close the secure
    // channel and sleep to give the server time to act, then
    // assert that the server no longer knows about it.
    long secureChannelId = client.getChannelFuture().get().getChannelId();
    client.disconnect().get();
    Thread.sleep(100);
    logger.info("asserting channel closed...");
    assertNull(server.getSecureChannel(secureChannelId));
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:33,代码来源:ClientServerTest.java

示例14: testClientReconnect

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test
public void testClientReconnect() throws Exception {
    EndpointDescription endpoint = endpoints[0];
    Variant input = new Variant(42);

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    RequestHeader header = new RequestHeader(
            NodeId.NULL_VALUE,
            DateTime.now(),
            uint(0), uint(0), null, uint(60000), null);

    TestStackRequest request = new TestStackRequest(header, uint(0), 0, input);

    logger.info("sending request: {}", request);
    UaResponseMessage response0 = client.sendRequest(request).get();
    logger.info("got response: {}", response0);

    logger.info("initiating a reconnect by closing channel in server...");
    long secureChannelId = client.getChannelFuture().get().getChannelId();
    server.getSecureChannel(secureChannelId).attr(UaTcpStackServer.BoundChannelKey).get().close().await();

    logger.info("sending request: {}", request);
    UaResponseMessage response1 = client.sendRequest(request).get();
    logger.info("got response: {}", response1);

    client.disconnect().get();
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:32,代码来源:ClientServerTest.java

示例15: testClientReconnect_InvalidSecureChannel

import com.digitalpetri.opcua.stack.core.types.structured.EndpointDescription; //导入依赖的package包/类
@Test
public void testClientReconnect_InvalidSecureChannel() throws Exception {
    EndpointDescription endpoint = endpoints[0];
    Variant input = new Variant(42);

    logger.info("SecurityPolicy={}, MessageSecurityMode={}, input={}",
            SecurityPolicy.fromUri(endpoint.getSecurityPolicyUri()), endpoint.getSecurityMode(), input);

    UaTcpStackClient client = createClient(endpoint);

    RequestHeader header = new RequestHeader(
            NodeId.NULL_VALUE,
            DateTime.now(),
            uint(0), uint(0), null, uint(60000), null);

    TestStackRequest request = new TestStackRequest(header, uint(0), 0, input);

    logger.info("sending request: {}", request);
    UaResponseMessage response0 = client.sendRequest(request).get();
    logger.info("got response: {}", response0);

    // Get our original valid secure channel, then sabotage it, then cause a disconnect.
    // The end effect is that we reconnect with an invalid secure channel id.
    ClientSecureChannel secureChannel = client.getChannelFuture().get();
    long secureChannelId = secureChannel.getChannelId();
    secureChannel.setChannelId(Long.MAX_VALUE);
    server.getSecureChannel(secureChannelId).attr(UaTcpStackServer.BoundChannelKey).get().close().await();
    Thread.sleep(500);

    logger.info("sending request: {}", request);
    UaResponseMessage response1 = client.sendRequest(request).get();
    logger.info("got response: {}", response1);
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:34,代码来源:ClientServerTest.java


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