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


Java Stack类代码示例

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


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

示例1: getEndpoints

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的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.connect().thenCompose(c ->
        c.<GetEndpointsResponse>sendRequest(request)
            .whenComplete((r, ex) -> client.disconnect())
            .thenApply(GetEndpointsResponse::getEndpoints)
    );
}
 
开发者ID:eclipse,项目名称:milo,代码行数:24,代码来源:UaTcpStackClient.java

示例2: build

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
public UaTcpStackServerConfig build() {
    Preconditions.checkNotNull(certificateManager, "certificateManager must be non-null");
    Preconditions.checkNotNull(certificateValidator, "certificateValidator must be non-null");

    if (executor == null) {
        executor = Stack.sharedExecutor();
    }

    return new UaTcpStackServerConfigImpl(
        serverName,
        applicationName,
        applicationUri,
        productUri,
        channelConfig,
        strictEndpointUrlsEnabled,
        certificateManager,
        certificateValidator,
        executor,
        userTokenPolicies,
        softwareCertificates
    );
}
 
开发者ID:eclipse,项目名称:milo,代码行数:23,代码来源:UaTcpStackServerConfigBuilder.java

示例3: shutdown

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
@PreDestroy
public void shutdown() {
  if (client.get() != null) {
    try {
      client.get().disconnect().get(500, TimeUnit.MILLISECONDS);
    } catch (TimeoutException | InterruptedException | ExecutionException e) {
      logger.error(e.getMessage(), e);
    }
  }
  Stack.releaseSharedResources(500, TimeUnit.MILLISECONDS);
}
 
开发者ID:comtel2000,项目名称:opc-ua-client,代码行数:12,代码来源:OpcUaClientConnector.java

示例4: build

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
public UaTcpStackClientConfig build() {
    if (executor == null) {
        executor = Stack.sharedExecutor();
    }
    if (eventLoop == null) {
        eventLoop = Stack.sharedEventLoop();
    }
    if (wheelTimer == null) {
        wheelTimer = Stack.sharedWheelTimer();
    }

    return new UaTcpStackClientConfigImpl(
        endpointUrl,
        endpoint,
        keyPair,
        certificate,
        certificateChain,
        certificateValidator,
        applicationName,
        applicationUri,
        productUri,
        channelConfig,
        channelLifetime,
        executor,
        eventLoop,
        wheelTimer
    );
}
 
开发者ID:eclipse,项目名称:milo,代码行数:29,代码来源:UaTcpStackClientConfigBuilder.java

示例5: testCopy

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
@Test
public void testCopy() {


    UaTcpStackClientConfig original = UaTcpStackClientConfig.builder()
        .setEndpointUrl("test")
        .setKeyPair(clientKeyPair)
        .setCertificate(clientCertificate)
        .setCertificateChain(new X509Certificate[]{clientCertificate})
        .setCertificateValidator(validator)
        .setApplicationName(LocalizedText.english("testName"))
        .setApplicationUri("testApplicationUri")
        .setProductUri("testProductUri")
        .setChannelConfig(ChannelConfig.DEFAULT)
        .setChannelLifetime(uint(1234))
        .setExecutor(Stack.sharedExecutor())
        .setEventLoop(Stack.sharedEventLoop())
        .setWheelTimer(Stack.sharedWheelTimer())
        .build();

    UaTcpStackClientConfig copy = UaTcpStackClientConfig.copy(original).build();

    assertEquals(copy.getEndpointUrl(), original.getEndpointUrl());
    assertEquals(copy.getKeyPair(), original.getKeyPair());
    assertEquals(copy.getCertificate(), original.getCertificate());
    assertEquals(copy.getCertificateChain(), original.getCertificateChain());
    assertEquals(copy.getCertificateValidator(), original.getCertificateValidator());
    assertEquals(copy.getApplicationName(), original.getApplicationName());
    assertEquals(copy.getApplicationUri(), original.getApplicationUri());
    assertEquals(copy.getProductUri(), original.getProductUri());
    assertEquals(copy.getChannelConfig(), original.getChannelConfig());
    assertEquals(copy.getChannelLifetime(), original.getChannelLifetime());
    assertEquals(copy.getExecutor(), original.getExecutor());
    assertEquals(copy.getEventLoop(), original.getEventLoop());
    assertEquals(copy.getWheelTimer(), original.getWheelTimer());
}
 
开发者ID:eclipse,项目名称:milo,代码行数:37,代码来源:UaTcpStackClientConfigTest.java

示例6: mapEndpoint

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
private EndpointDescription mapEndpoint(Endpoint endpoint) {
    List<UserTokenPolicy> userTokenPolicies = config.getUserTokenPolicies();

    return new EndpointDescription(
        endpoint.getEndpointUri().toString(),
        getApplicationDescription(),
        certificateByteString(endpoint.getCertificate()),
        endpoint.getMessageSecurity(),
        endpoint.getSecurityPolicy().getSecurityPolicyUri(),
        userTokenPolicies.toArray(new UserTokenPolicy[userTokenPolicies.size()]),
        Stack.UA_TCP_BINARY_TRANSPORT_URI,
        ubyte(endpoint.getSecurityLevel())
    );
}
 
开发者ID:eclipse,项目名称:milo,代码行数:15,代码来源:UaTcpStackServer.java

示例7: onGetEndpoints

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的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(endpoint -> {
            List<UserTokenPolicy> userTokenPolicies = config.getUserTokenPolicies();

            return new EndpointDescription(
                endpoint.getEndpointUri().toString(),
                getFilteredApplicationDescription(request.getEndpointUrl()),
                certificateByteString(endpoint.getCertificate()),
                endpoint.getMessageSecurity(),
                endpoint.getSecurityPolicy().getSecurityPolicyUri(),
                userTokenPolicies.toArray(new UserTokenPolicy[userTokenPolicies.size()]),
                Stack.UA_TCP_BINARY_TRANSPORT_URI,
                ubyte(endpoint.getSecurityLevel())
            );
        })
        .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:eclipse,项目名称:milo,代码行数:40,代码来源:UaTcpStackServer.java

示例8: removeCryptographyRestrictions

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
/**
 * Do the following, but with reflection to bypass access checks:
 * <p>
 * JceSecurity.isRestricted = false;
 * JceSecurity.defaultPolicy.perms.clear();
 * JceSecurity.defaultPolicy.add(CryptoAllPermission.INSTANCE);
 */
private static boolean removeCryptographyRestrictions() {
    Logger logger = LoggerFactory.getLogger(Stack.class);

    if (isRestrictedCryptography()) {
        try {
            final Class<?> jceSecurity = Class.forName("javax.crypto.JceSecurity");
            final Class<?> cryptoPermissions = Class.forName("javax.crypto.CryptoPermissions");
            final Class<?> cryptoAllPermission = Class.forName("javax.crypto.CryptoAllPermission");

            // Private? No big deal...
            final Field isRestrictedField = jceSecurity.getDeclaredField("isRestricted");
            isRestrictedField.setAccessible(true);

            // Final? Let's remove that...
            final Field modifiersField = Field.class.getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(isRestrictedField, isRestrictedField.getModifiers() & ~Modifier.FINAL);

            // isRestricted = false
            isRestrictedField.set(null, false);

            final Field defaultPolicyField = jceSecurity.getDeclaredField("defaultPolicy");
            defaultPolicyField.setAccessible(true);
            final PermissionCollection defaultPolicy = (PermissionCollection) defaultPolicyField.get(null);

            final Field perms = cryptoPermissions.getDeclaredField("perms");
            perms.setAccessible(true);
            ((Map<?, ?>) perms.get(defaultPolicy)).clear();

            final Field instance = cryptoAllPermission.getDeclaredField("INSTANCE");
            instance.setAccessible(true);
            defaultPolicy.add((Permission) instance.get(null));

            logger.info("Successfully removed cryptography restrictions.");
            return true;
        } catch (final Exception e) {
            logger.warn("Failed to remove cryptography restrictions.", e);
            return false;
        }
    }

    return true;
}
 
开发者ID:eclipse,项目名称:milo,代码行数:51,代码来源:CryptoRestrictions.java

示例9: testCopyAndModify

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
@Test
public void testCopyAndModify() {
    UaTcpStackClientConfig original = UaTcpStackClientConfig.builder()
        .setEndpointUrl("test")
        .setKeyPair(clientKeyPair)
        .setCertificate(clientCertificate)
        .setCertificateValidator(validator)
        .setApplicationName(LocalizedText.english("testName"))
        .setApplicationUri("testApplicationUri")
        .setProductUri("testProductUri")
        .setChannelConfig(ChannelConfig.DEFAULT)
        .setChannelLifetime(uint(1234))
        .setExecutor(Stack.sharedExecutor())
        .setEventLoop(Stack.sharedEventLoop())
        .setWheelTimer(Stack.sharedWheelTimer())
        .build();

    UaTcpStackClientConfig copy = UaTcpStackClientConfig.copy(original,
        builder -> builder.setEndpointUrl("foo")
            .setKeyPair(null)
            .setCertificate(null)
            .setCertificateChain(null)
            .setCertificateValidator(null)
            .setApplicationName(LocalizedText.english("fooName"))
            .setApplicationUri("fooApplicationUri")
            .setProductUri("fooProductUri")
            .setChannelConfig(null)
            .setChannelLifetime(uint(0))
    );

    assertEquals(copy.getEndpointUrl(), Optional.of("foo"));
    assertEquals(copy.getKeyPair(), Optional.empty());
    assertEquals(copy.getCertificate(), Optional.empty());
    assertEquals(copy.getCertificateChain(), Optional.empty());
    assertEquals(copy.getCertificateValidator(), null);
    assertEquals(copy.getApplicationName(), LocalizedText.english("fooName"));
    assertEquals(copy.getApplicationUri(), "fooApplicationUri");
    assertEquals(copy.getProductUri(), "fooProductUri");
    assertEquals(copy.getChannelConfig(), null);
    assertEquals(copy.getChannelLifetime(), uint(0));
}
 
开发者ID:eclipse,项目名称:milo,代码行数:42,代码来源:UaTcpStackClientConfigTest.java

示例10: OpcUaServer

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
public OpcUaServer(OpcUaServerConfig config) {
    this.config = config;

    stackServer = new UaTcpStackServer(config);

    stackServer.addServiceSet((AttributeServiceSet) sessionManager);
    stackServer.addServiceSet((AttributeHistoryServiceSet) sessionManager);
    stackServer.addServiceSet((MethodServiceSet) sessionManager);
    stackServer.addServiceSet((MonitoredItemServiceSet) sessionManager);
    stackServer.addServiceSet((NodeManagementServiceSet) sessionManager);
    stackServer.addServiceSet((SessionServiceSet) sessionManager);
    stackServer.addServiceSet((SubscriptionServiceSet) sessionManager);
    stackServer.addServiceSet((ViewServiceSet) sessionManager);

    ObjectTypeManagerInitializer.initialize(objectTypeManager);
    VariableTypeManagerInitializer.initialize(variableTypeManager);

    namespaceManager.addNamespace(uaNamespace = new OpcUaNamespace(this));

    vendorNamespace = namespaceManager.registerAndAdd(
        config.getApplicationUri(),
        index -> new VendorNamespace(OpcUaServer.this, config.getApplicationUri()));

    serverTable.addUri(stackServer.getApplicationDescription().getApplicationUri());

    for (ReferenceType referenceType : BuiltinReferenceType.values()) {
        referenceTypes.put(referenceType.getNodeId(), referenceType);
    }

    for (String bindAddress : config.getBindAddresses()) {
        Set<String> hostnames = Sets.newHashSet(config.getEndpointAddresses());

        for (String hostname : hostnames) {
            for (SecurityPolicy securityPolicy : config.getSecurityPolicies()) {
                MessageSecurityMode messageSecurity = securityPolicy == SecurityPolicy.None ?
                    MessageSecurityMode.None : MessageSecurityMode.SignAndEncrypt;

                String endpointUrl = endpointUrl(hostname, config.getBindPort(), config.getServerName());

                Set<X509Certificate> certificates = config.getCertificateManager().getCertificates();

                if (certificates.isEmpty()) {
                    logger.info("Binding endpoint {} to {} [{}/{}]",
                        endpointUrl, bindAddress, securityPolicy, messageSecurity);

                    stackServer.addEndpoint(endpointUrl, bindAddress, null, securityPolicy, messageSecurity);
                } else {
                    for (X509Certificate certificate : certificates) {
                        logger.info("Binding endpoint {} to {} [{}/{}]",
                            endpointUrl, bindAddress, securityPolicy, messageSecurity);

                        stackServer.addEndpoint(
                            endpointUrl, bindAddress, certificate, securityPolicy, messageSecurity);
                    }
                }
            }
        }
    }

    eventBus = new AsyncEventBus("server", stackServer.getExecutorService());

    logger.info("eclipse milo opc-ua stack version: {}", Stack.VERSION);
    logger.info("eclipse milo opc-ua sdk version: {}", SDK_VERSION);
}
 
开发者ID:eclipse,项目名称:milo,代码行数:65,代码来源:OpcUaServer.java

示例11: getScheduledExecutorService

import org.eclipse.milo.opcua.stack.core.Stack; //导入依赖的package包/类
public ScheduledExecutorService getScheduledExecutorService() {
    return Stack.sharedScheduledExecutor();
}
 
开发者ID:eclipse,项目名称:milo,代码行数:4,代码来源:OpcUaServer.java


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