use of org.eclipse.milo.opcua.stack.server.UaStackServerConfig in project milo by eclipse.
the class OpcUaServerConfigBuilder method build.
@Override
public OpcUaServerConfig build() {
UaStackServerConfig stackServerConfig = super.build();
ScheduledExecutorService scheduledExecutorService = this.scheduledExecutorService;
if (scheduledExecutorService == null) {
scheduledExecutorService = Stack.sharedScheduledExecutor();
}
return new OpcUaServerConfigImpl(stackServerConfig, identityValidator, buildInfo, limits, scheduledExecutorService);
}
use of org.eclipse.milo.opcua.stack.server.UaStackServerConfig in project milo by eclipse.
the class ClientServerTest method setUpClientServer.
@BeforeSuite
public void setUpClientServer() throws Exception {
super.setUp();
UaStackServerConfig config = UaStackServerConfig.builder().setCertificateManager(serverCertificateManager).setCertificateValidator(serverCertificateValidator).setEndpoints(createEndpointConfigurations(serverCertificate)).build();
server = new UaStackServer(config);
setReadRequestHandler(new Variant(42));
server.startup().get();
endpoints = DiscoveryClient.getEndpoints("opc.tcp://localhost:12685/test").get().toArray(new EndpointDescription[0]);
}
use of org.eclipse.milo.opcua.stack.server.UaStackServerConfig in project milo by eclipse.
the class StackIntegrationTest method setUpClientServer.
@BeforeSuite
public void setUpClientServer() throws Exception {
super.setUp();
int tcpBindPort = getTcpBindPort();
int httpsBindPort = getHttpsBindPort();
KeyPair httpsKeyPair = SelfSignedCertificateGenerator.generateRsaKeyPair(2048);
X509Certificate httpsCertificate = new SelfSignedHttpsCertificateBuilder(httpsKeyPair).setCommonName("localhost").build();
List<String> bindAddresses = newArrayList();
bindAddresses.add("localhost");
List<String> hostnames = newArrayList();
hostnames.add("localhost");
Set<EndpointConfiguration> endpointConfigurations = new LinkedHashSet<>();
for (String bindAddress : bindAddresses) {
for (String hostname : hostnames) {
EndpointConfiguration.Builder base = EndpointConfiguration.newBuilder().setBindAddress(bindAddress).setHostname(hostname).setPath("/test").setCertificate(serverCertificate).addTokenPolicies(USER_TOKEN_POLICY_ANONYMOUS);
// TCP Transport Endpoints
endpointConfigurations.add(base.copy().setBindPort(tcpBindPort).setSecurityPolicy(SecurityPolicy.None).setSecurityMode(MessageSecurityMode.None).setTransportProfile(TransportProfile.TCP_UASC_UABINARY).build());
endpointConfigurations.add(base.copy().setBindPort(tcpBindPort).setSecurityPolicy(SecurityPolicy.Basic256Sha256).setSecurityMode(MessageSecurityMode.SignAndEncrypt).setTransportProfile(TransportProfile.TCP_UASC_UABINARY).build());
// HTTPS Transport Endpoints
endpointConfigurations.add(base.copy().setBindPort(httpsBindPort).setSecurityPolicy(SecurityPolicy.None).setSecurityMode(MessageSecurityMode.None).setTransportProfile(TransportProfile.HTTPS_UABINARY).build());
endpointConfigurations.add(base.copy().setBindPort(httpsBindPort).setSecurityPolicy(SecurityPolicy.Basic256Sha256).setSecurityMode(MessageSecurityMode.SignAndEncrypt).setTransportProfile(TransportProfile.HTTPS_UABINARY).build());
}
}
UaStackServerConfig serverConfig = configureServer(UaStackServerConfig.builder().setEndpoints(endpointConfigurations).setCertificateManager(serverCertificateManager).setCertificateValidator(serverCertificateValidator).setHttpsKeyPair(httpsKeyPair).setHttpsCertificate(httpsCertificate)).build();
stackServer = new UaStackServer(serverConfig);
stackServer.startup().get();
String discoveryUrl = getDiscoveryUrl();
EndpointDescription endpoint = selectEndpoint(DiscoveryClient.getEndpoints(discoveryUrl).thenApply(endpoints -> {
endpoints.forEach(e -> logger.info("discovered endpoint: {}", e.getEndpointUrl()));
return endpoints;
}).get());
UaStackClientConfig clientConfig = configureClient(UaStackClientConfig.builder().setEndpoint(endpoint).setKeyPair(clientKeyPair).setCertificate(clientCertificate).setRequestTimeout(uint(5000))).build();
stackClient = UaStackClient.create(clientConfig);
stackClient.connect().get();
}
Aggregations