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