org.jboss.remoting3.Endpoint Java Examples

The following examples show how to use org.jboss.remoting3.Endpoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemotingHttpUpgradeService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public RemotingHttpUpgradeService(final Consumer<RemotingHttpUpgradeService> serviceConsumer,
                                  final Supplier<ChannelUpgradeHandler> upgradeRegistrySupplier,
                                  final Supplier<ListenerRegistry> listenerRegistrySupplier,
                                  final Supplier<Endpoint> endpointSupplier,
                                  final Supplier<org.jboss.as.domain.management.SecurityRealm> securityRealmSupplier,
                                  final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier,
                                  final String httpConnectorName, final String endpointName, final OptionMap connectorPropertiesOptionMap) {
    this.serviceConsumer = serviceConsumer;
    this.upgradeRegistrySupplier = upgradeRegistrySupplier;
    this.listenerRegistrySupplier = listenerRegistrySupplier;
    this.endpointSupplier = endpointSupplier;
    this.securityRealmSupplier = securityRealmSupplier;
    this.saslAuthenticationFactorySupplier = saslAuthenticationFactorySupplier;
    this.httpConnectorName = httpConnectorName;
    this.endpointName = endpointName;
    this.connectorPropertiesOptionMap = connectorPropertiesOptionMap;
}
 
Example #2
Source File: DomainServerCommunicationServices.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void activate(final ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
    final ServiceTarget serviceTarget = serviceActivatorContext.getServiceTarget();
    final ServiceName endpointName = managementSubsystemEndpoint ? RemotingServices.SUBSYSTEM_ENDPOINT : ManagementRemotingServices.MANAGEMENT_ENDPOINT;
    final EndpointService.EndpointType endpointType = managementSubsystemEndpoint ? EndpointService.EndpointType.SUBSYSTEM : EndpointService.EndpointType.MANAGEMENT;
    try {
        ManagementWorkerService.installService(serviceTarget);
        // TODO see if we can figure out a way to work in the vault resolver instead of having to use ExpressionResolver.SIMPLE
        @SuppressWarnings("deprecation")
        final OptionMap options = EndpointConfigFactory.create(ExpressionResolver.SIMPLE, endpointConfig, DEFAULTS);
        ManagementRemotingServices.installRemotingManagementEndpoint(serviceTarget, endpointName, WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null), endpointType, options);

        // Install the communication services
        final ServiceBuilder<?> sb = serviceTarget.addService(HostControllerConnectionService.SERVICE_NAME);
        final Supplier<ExecutorService> esSupplier = Services.requireServerExecutor(sb);
        final Supplier<ScheduledExecutorService> sesSupplier = sb.requires(ServerService.JBOSS_SERVER_SCHEDULED_EXECUTOR);
        final Supplier<Endpoint> eSupplier = sb.requires(endpointName);
        final Supplier<ProcessStateNotifier> cpsnSupplier = sb.requires(ControlledProcessStateService.INTERNAL_SERVICE_NAME);
        sb.setInstance(new HostControllerConnectionService(managementURI, serverName, serverProcessName, authKey, initialOperationID, managementSubsystemEndpoint, sslContextSupplier, esSupplier, sesSupplier, eSupplier, cpsnSupplier));
        sb.install();
    } catch (OperationFailedException e) {
        throw new ServiceRegistryException(e);
    }
}
 
Example #3
Source File: RemotingHttpUpgradeService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void installServices(final OperationContext context, final String remotingConnectorName,
                                   final String httpConnectorName, final ServiceName endpointName,
                                   final OptionMap connectorPropertiesOptionMap, final String securityRealm,
                                   final String saslAuthenticationFactory) {
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final ServiceName serviceName = UPGRADE_SERVICE_NAME.append(remotingConnectorName);
    final ServiceBuilder<?> sb = serviceTarget.addService(serviceName);
    final Consumer<RemotingHttpUpgradeService> serviceConsumer = sb.provides(serviceName);
    final Supplier<ChannelUpgradeHandler> urSupplier = sb.requires(HTTP_UPGRADE_REGISTRY.append(httpConnectorName));
    final Supplier<ListenerRegistry> lrSupplier = sb.requires(RemotingServices.HTTP_LISTENER_REGISTRY);
    final Supplier<Endpoint> eSupplier = sb.requires(endpointName);
    final Supplier<org.jboss.as.domain.management.SecurityRealm> srSupplier = securityRealm != null ? sb.requires(org.jboss.as.domain.management.SecurityRealm.ServiceUtil.createServiceName(securityRealm)) : null;
    final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? sb.requires(context.getCapabilityServiceName(SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactory, SaslAuthenticationFactory.class)) : null;
    sb.setInstance(new RemotingHttpUpgradeService(serviceConsumer, urSupplier, lrSupplier, eSupplier, srSupplier, safSupplier, httpConnectorName, endpointName.getSimpleName(), connectorPropertiesOptionMap));
    sb.setInitialMode(ServiceController.Mode.PASSIVE);
    sb.install();
}
 
Example #4
Source File: HostControllerConnectionService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public HostControllerConnectionService(final URI connectionURI, final String serverName, final String serverProcessName,
                                       final String authKey, final int connectOperationID,
                                       final boolean managementSubsystemEndpoint, final Supplier<SSLContext> sslContextSupplier,
                                       final Supplier<ExecutorService> executorSupplier,
                                       final Supplier<ScheduledExecutorService> scheduledExecutorSupplier,
                                       final Supplier<Endpoint> endpointSupplier,
                                       final Supplier<ProcessStateNotifier> processStateNotifierSupplier) {
    this.connectionURI= connectionURI;
    this.serverName = serverName;
    this.userName = DomainManagedServerCallbackHandler.DOMAIN_SERVER_AUTH_PREFIX + serverName;
    this.serverProcessName = serverProcessName;
    this.initialAuthKey = authKey;
    this.connectOperationID = connectOperationID;
    this.managementSubsystemEndpoint = managementSubsystemEndpoint;
    if (sslContextSupplier != null) {
        this.sslContextSupplier = sslContextSupplier;
    } else {
        this.sslContextSupplier = HostControllerConnectionService::getAcceptingSSLContext;
    }
    this.executorSupplier = executorSupplier;
    this.scheduledExecutorSupplier = scheduledExecutorSupplier;
    this.endpointSupplier = endpointSupplier;
    this.processStateNotifierSupplier = processStateNotifierSupplier;
}
 
Example #5
Source File: RemotingServices.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Deprecated
public static void installConnectorServicesForNetworkInterfaceBinding(final ServiceTarget serviceTarget,
                                                                      final ServiceName endpointName,
                                                                      final String connectorName,
                                                                      final ServiceName networkInterfaceBindingName,
                                                                      final int port,
                                                                      final OptionMap connectorPropertiesOptionMap,
                                                                      final ServiceName securityRealm,
                                                                      final ServiceName saslAuthenticationFactory,
                                                                      final ServiceName sslContext,
                                                                      final ServiceName socketBindingManager) {
    final ServiceName serviceName= serverServiceName(connectorName);
    final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
    final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer = builder.provides(serviceName);
    final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
    final Supplier<SecurityRealm> srSupplier = securityRealm != null ? builder.requires(securityRealm) : null;
    final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? builder.requires(saslAuthenticationFactory) : null;
    final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requires(sslContext): null;
    final Supplier<SocketBindingManager> sbmSupplier = socketBindingManager != null ? builder.requires(socketBindingManager) : null;
    final Supplier<NetworkInterfaceBinding> ibSupplier = builder.requires(networkInterfaceBindingName);
    builder.setInstance(new InjectedNetworkBindingStreamServerService(streamServerConsumer,
            eSupplier, srSupplier, safSupplier, scSupplier, sbmSupplier, ibSupplier, connectorPropertiesOptionMap, port));
    builder.install();
}
 
Example #6
Source File: ManagementRemotingServices.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Set up the services to create a channel listener. This assumes that an endpoint service called {@code endpointName} exists.
 *  @param serviceTarget the service target to install the services into
 * @param endpointName the name of the endpoint to install a channel listener into
 * @param channelName the name of the channel
 * @param operationHandlerName the name of the operation handler to handle request for this channel
 * @param options the remoting options
 * @param onDemand whether to install the services on demand
 */
public static void installManagementChannelOpenListenerService(
        final ServiceTarget serviceTarget,
        final ServiceName endpointName,
        final String channelName,
        final ServiceName operationHandlerName,
        final OptionMap options,
        final boolean onDemand) {

    final ServiceName serviceName = RemotingServices.channelServiceName(endpointName, channelName);
    final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
    final Supplier<ManagementChannelInitialization> ohfSupplier = builder.requires(operationHandlerName);
    final Supplier<ExecutorService> esSupplier = builder.requires(SHUTDOWN_EXECUTOR_NAME);
    final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
    final Supplier<ManagementChannelRegistryService> rSupplier = builder.requires(ManagementChannelRegistryService.SERVICE_NAME);
    builder.setInstance(new ManagementChannelOpenListenerService(ohfSupplier, esSupplier, eSupplier, rSupplier, channelName, options));
    builder.setInitialMode(onDemand ? ON_DEMAND : ACTIVE);
    builder.install();
}
 
Example #7
Source File: RemotingServices.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void installConnectorServicesForSocketBinding(final ServiceTarget serviceTarget,
                                                            final ServiceName endpointName,
                                                            final String connectorName,
                                                            final ServiceName socketBindingName,
                                                            final OptionMap connectorPropertiesOptionMap,
                                                            final ServiceName securityRealm,
                                                            final ServiceName saslAuthenticationFactory,
                                                            final ServiceName sslContext,
                                                            final ServiceName socketBindingManager) {
    final ServiceName serviceName = serverServiceName(connectorName);
    final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
    final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer = builder.provides(serviceName);
    final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
    final Supplier<SecurityRealm> srSupplier = securityRealm != null ? builder.requires(securityRealm) : null;
    final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? builder.requires(saslAuthenticationFactory) : null;
    final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requires(sslContext) : null;
    final Supplier<SocketBindingManager> sbmSupplier = builder.requires(socketBindingManager);
    final Supplier<SocketBinding> sbSupplier = builder.requires(socketBindingName);
    builder.setInstance(new InjectedSocketBindingStreamServerService(streamServerConsumer,
            eSupplier, srSupplier, safSupplier, scSupplier, sbmSupplier, sbSupplier, connectorPropertiesOptionMap));
    builder.install();
}
 
Example #8
Source File: AbstractStreamServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
AbstractStreamServerService(
        final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer,
        final Supplier<Endpoint> endpointSupplier,
        final Supplier<SecurityRealm> securityRealmSupplier,
        final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier,
        final Supplier<SSLContext> sslContextSupplier,
        final Supplier<SocketBindingManager> socketBindingManagerSupplier,
        final OptionMap connectorPropertiesOptionMap) {
    this.streamServerConsumer = streamServerConsumer;
    this.endpointSupplier = endpointSupplier;
    this.securityRealmSupplier = securityRealmSupplier;
    this.saslAuthenticationFactorySupplier = saslAuthenticationFactorySupplier;
    this.sslContextSupplier = sslContextSupplier;
    this.socketBindingManagerSupplier = socketBindingManagerSupplier;
    this.connectorPropertiesOptionMap = connectorPropertiesOptionMap;
}
 
Example #9
Source File: RemotingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Tests that the outbound connections configured in the remoting subsytem are processed and services
 * are created for them
 *
 * @throws Exception
 */
@Test
public void testRuntime() throws Exception {
    KernelServices services = createKernelServicesBuilder(createRuntimeAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml())
            .build();

    ServiceName remotingEndpointSN = RemotingServices.SUBSYSTEM_ENDPOINT;
    ServiceName remotingConnectorSN = RemotingServices.serverServiceName("remoting-connector");
    DependenciesRetrievalService dependencies = DependenciesRetrievalService.create(services, remotingEndpointSN, remotingConnectorSN);
    Endpoint endpointService = dependencies.getService(remotingEndpointSN);
    assertNotNull("Endpoint service was null", endpointService);
    assertNotNull(endpointService.getName());

    Object remotingConnector = dependencies.getService(remotingConnectorSN);
    assertNotNull("Remoting connector was null", remotingConnector);
}
 
Example #10
Source File: ManagementChannelOpenListenerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
ManagementChannelOpenListenerService(final Supplier<ManagementChannelInitialization> operationHandlerFactorySupplier,
                                     final Supplier<ExecutorService> executorServiceSupplier,
                                     final Supplier<Endpoint> endpointSupplier,
                                     final Supplier<ManagementChannelRegistryService> registrySupplier,
                                     final String channelName, final OptionMap optionMap) {
    super(endpointSupplier, registrySupplier, channelName, optionMap);
    this.operationHandlerFactorySupplier = operationHandlerFactorySupplier;
    this.executorServiceSupplier = executorServiceSupplier;
}
 
Example #11
Source File: RemotingServices.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void installRemotingManagementEndpoint(final ServiceTarget serviceTarget, final ServiceName endpointName,
                                                     final String hostName, final EndpointService.EndpointType type, final OptionMap options) {
    final ServiceBuilder<?> builder = serviceTarget.addService(endpointName);
    final Consumer<Endpoint> endpointConsumer = builder.provides(endpointName);
    final Supplier<XnioWorker> workerSupplier = builder.requires(ServiceName.JBOSS.append("serverManagement", "controller", "management", "worker"));
    builder.setInstance(new EndpointService(endpointConsumer, workerSupplier, hostName, type, options));
    builder.install();
}
 
Example #12
Source File: AbstractChannelOpenListenerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public AbstractChannelOpenListenerService(final Supplier<Endpoint> endpointSupplier,
                                          final Supplier<ManagementChannelRegistryService> registrySupplier,
                                          final String channelName, final OptionMap optionMap) {
    this.endpointSupplier = endpointSupplier;
    this.registrySupplier = registrySupplier;
    this.channelName = channelName;
    this.optionMap = optionMap;
}
 
Example #13
Source File: RemotingConnectorService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void addService(final ServiceTarget target,
                       final ServiceName remotingCapability,
                       final String resolvedDomain,
                       final String expressionsDomain) {
    final RemotingConnectorService service = new RemotingConnectorService(resolvedDomain, expressionsDomain);
    target.addService(SERVICE_NAME, service)
            .addDependency(MBeanServerService.SERVICE_NAME, MBeanServer.class, service.mBeanServer)
            .addDependency(remotingCapability, Endpoint.class, service.endpoint)
            .install();
}
 
Example #14
Source File: InjectedSocketBindingStreamServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
InjectedSocketBindingStreamServerService(
        final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer,
        final Supplier<Endpoint> endpointSupplier,
        final Supplier<SecurityRealm> securityRealmSupplier,
        final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier,
        final Supplier<SSLContext> sslContextSupplier,
        final Supplier<SocketBindingManager> socketBindingManagerSupplier,
        final Supplier<SocketBinding> socketBindingSupplier,
        final OptionMap connectorPropertiesOptionMap) {
    super(streamServerConsumer, endpointSupplier, securityRealmSupplier, saslAuthenticationFactorySupplier,
            sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap);
    this.socketBindingSupplier = socketBindingSupplier;
}
 
Example #15
Source File: InjectedNetworkBindingStreamServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
InjectedNetworkBindingStreamServerService(
        final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer,
        final Supplier<Endpoint> endpointSupplier,
        final Supplier<SecurityRealm> securityRealmSupplier,
        final Supplier<SaslAuthenticationFactory> saslAuthenticationFactorySupplier,
        final Supplier<SSLContext> sslContextSupplier,
        final Supplier<SocketBindingManager> socketBindingManagerSupplier,
        final Supplier<NetworkInterfaceBinding> interfaceBindingSupplier,
        final OptionMap connectorPropertiesOptionMap, int port) {
    super(streamServerConsumer, endpointSupplier, securityRealmSupplier, saslAuthenticationFactorySupplier,
            sslContextSupplier, socketBindingManagerSupplier, connectorPropertiesOptionMap);
    this.interfaceBindingSupplier = interfaceBindingSupplier;
    this.port = port;
}
 
Example #16
Source File: RemotingSubsystemAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {

    // WFCORE-4510 -- the effective endpoint configuration is from the root subsystem resource,
    // not from the placeholder configuration=endpoint child resource.
    ModelNode endpointModel = resource.getModel();
    String workerName = WORKER.resolveModelAttribute(context, endpointModel).asString();

    final OptionMap map = EndpointConfigFactory.populate(context, endpointModel);

    // create endpoint
    final String nodeName = WildFlySecurityManager.getPropertyPrivileged(RemotingExtension.NODE_NAME_PROPERTY, null);

    // In case of a managed server the subsystem endpoint might already be installed {@see DomainServerCommunicationServices}
    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        final ServiceController<?> controller = context.getServiceRegistry(false).getService(RemotingServices.SUBSYSTEM_ENDPOINT);
        if (controller != null) {
            // if installed, just skip the rest
            return;
        }
    }

    final CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(REMOTING_ENDPOINT_CAPABILITY);
    final Consumer<Endpoint> endpointConsumer = builder.provides(REMOTING_ENDPOINT_CAPABILITY);
    final Supplier<XnioWorker> workerSupplier = builder.requiresCapability(IO_WORKER_CAPABILITY_NAME, XnioWorker.class, workerName);
    builder.setInstance(new EndpointService(endpointConsumer, workerSupplier, nodeName, EndpointService.EndpointType.SUBSYSTEM, map));
    builder.install();
}
 
Example #17
Source File: EndpointService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public EndpointService(final Consumer<Endpoint> endpointConsumer, final Supplier<XnioWorker> workerSupplier, String nodeName, EndpointType type, final OptionMap optionMap) {
    this.endpointConsumer = endpointConsumer;
    this.workerSupplier = workerSupplier;
    if (nodeName == null) {
        nodeName = "remote";
    }
    endpointName = type == EndpointType.SUBSYSTEM ? nodeName : nodeName + ":" + type;
    this.optionMap = optionMap;
}
 
Example #18
Source File: RemoteDomainConnectionService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static Future<MasterDomainControllerClient> install(final ServiceTarget serviceTarget,
                                                    final ModelController controller,
                                                    final ExtensionRegistry extensionRegistry,
                                                    final LocalHostControllerInfo localHostControllerInfo,
                                                    final ServiceName authenticationContext,
                                                    final String securityRealm,
                                                    final RemoteFileRepository remoteFileRepository,
                                                    final ContentRepository contentRepository,
                                                    final IgnoredDomainResourceRegistry ignoredDomainResourceRegistry,
                                                    final HostControllerRegistrationHandler.OperationExecutor operationExecutor,
                                                    final DomainController domainController,
                                                    final HostControllerEnvironment hostControllerEnvironment,
                                                    final ExecutorService executor,
                                                    final RunningMode currentRunningMode,
                                                    final Map<String, ProxyController> serverProxies,
                                                    final AtomicBoolean domainConfigAvailable) {
    RemoteDomainConnectionService service = new RemoteDomainConnectionService(controller, extensionRegistry, localHostControllerInfo,
            remoteFileRepository, contentRepository,
            ignoredDomainResourceRegistry, operationExecutor, domainController,
            hostControllerEnvironment, executor, currentRunningMode, serverProxies, domainConfigAvailable);
    ServiceBuilder<MasterDomainControllerClient> builder = serviceTarget.addService(MasterDomainControllerClient.SERVICE_NAME, service)
            .addDependency(ManagementRemotingServices.MANAGEMENT_ENDPOINT, Endpoint.class, service.endpointInjector)
            .addDependency(ServerInventoryService.SERVICE_NAME, ServerInventory.class, service.serverInventoryInjector)
            .addDependency(HostControllerService.HC_SCHEDULED_EXECUTOR_SERVICE_NAME, ScheduledExecutorService.class, service.scheduledExecutorInjector)
            .setInitialMode(ServiceController.Mode.ACTIVE);

    if (authenticationContext != null) {
        builder.addDependency(authenticationContext, AuthenticationContext.class, service.authenticationContextInjector);
    }
    if (securityRealm != null) {
        SecurityRealm.ServiceUtil.addDependency(builder, service.securityRealmInjector, securityRealm);
    }

    builder.install();
    return service.futureClient;
}
 
Example #19
Source File: RemotingConnectorAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {

    boolean useManagementEndpoint = RemotingConnectorResource.USE_MANAGEMENT_ENDPOINT.resolveModelAttribute(context, model).asBoolean();

    ServiceName remotingCapability;
    if (!useManagementEndpoint) {
        // Use the remoting capability
        // if (context.getProcessType() == ProcessType.DOMAIN_SERVER) then DomainServerCommunicationServices
        // installed the "remoting subsystem" endpoint and we don't even necessarily *have to* have a remoting
        // subsystem and possibly we could skip adding the requirement for its capability. But really, specifying
        // not to use the management endpoint and then not configuring a remoting subsystem is a misconfiguration,
        // and we should treat it as such. So, we add the requirement no matter what.
        context.requireOptionalCapability(RemotingConnectorResource.REMOTING_CAPABILITY, RemotingConnectorResource.REMOTE_JMX_CAPABILITY.getName(),
                    RemotingConnectorResource.USE_MANAGEMENT_ENDPOINT.getName());
        remotingCapability = context.getCapabilityServiceName(RemotingConnectorResource.REMOTING_CAPABILITY, Endpoint.class);
    } else {
        remotingCapability = ManagementRemotingServices.MANAGEMENT_ENDPOINT;
    }
    // Read the model for the JMX subsystem to find the domain name for the resolved/expressions models (if they are exposed).
    PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
    PathAddress parentAddress = address.subAddress(0, address.size() - 1);
    ModelNode jmxSubsystemModel = Resource.Tools.readModel(context.readResourceFromRoot(parentAddress, true));
    String resolvedDomain = getDomainName(context, jmxSubsystemModel, CommonAttributes.RESOLVED);
    String expressionsDomain = getDomainName(context, jmxSubsystemModel, CommonAttributes.EXPRESSION);

    RemotingConnectorService.addService(context.getServiceTarget(), remotingCapability, resolvedDomain, expressionsDomain);
}
 
Example #20
Source File: EndpointService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
public void start(final StartContext context) throws StartException {
    final Endpoint endpoint;
    final EndpointBuilder builder = Endpoint.builder();
    builder.setEndpointName(endpointName);
    builder.setXnioWorker(workerSupplier.get());
    try {
        endpoint = builder.build();
    } catch (IOException e) {
        throw RemotingLogger.ROOT_LOGGER.couldNotStart(e);
    }
    // Reuse the options for the remote connection factory for now
    this.endpoint = endpoint;
    endpointConsumer.accept(endpoint);
}
 
Example #21
Source File: TestControllerUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static TestControllerUtils create(URI uri, CallbackHandler callbackHandler) throws IOException {
    final Endpoint endpoint = Endpoint.getCurrent();

    final ProtocolConnectionConfiguration configuration = ProtocolConnectionConfiguration.create(endpoint, uri);
    configuration.setCallbackHandler(callbackHandler);
    return new TestControllerUtils(endpoint, configuration, createDefaultExecutor());
}
 
Example #22
Source File: EndpointService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
public void stop(final StopContext context) {
    context.asynchronous();
    endpointConsumer.accept(null);
    final Endpoint endpoint = this.endpoint;
    this.endpoint = null;
    try {
        endpoint.closeAsync();
    } finally {
        endpoint.addCloseHandler((closed, exception) -> {
            context.complete();
        });
    }
}
 
Example #23
Source File: ChannelServer.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ChannelServer create(final Configuration configuration) throws IOException {
    if (configuration == null) {
        throw new IllegalArgumentException("Null configuration");
    }
    configuration.validate();

    // Hack WFCORE-3302/REM3-303 workaround
    if (firstCreate) {
        firstCreate = false;
    } else {
        try {
            // wait in case the previous socket has not closed
            Thread.sleep(100);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        }
    }

    // TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok
    final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build();

    final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("default", realm).build();
    domainBuilder.setDefaultRealmName("default");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    SecurityDomain testDomain = domainBuilder.build();
    SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder()
        .setSecurityDomain(testDomain)
        .setMechanismConfigurationSelector(mechanismInformation -> "ANONYMOUS".equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null)
        .setFactory(new AnonymousServerFactory())
        .build();
    System.out.println(configuration.getBindAddress());
    AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null);

    return new ChannelServer(endpoint, null, streamServer);
}
 
Example #24
Source File: ChannelServer.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ChannelServer(final Endpoint endpoint,
        final Registration registration,
        final AcceptingChannel<StreamConnection> streamServer) {
    this.endpoint = endpoint;
    this.registration = registration;
    this.streamServer = streamServer;
}
 
Example #25
Source File: ProtocolConnectionConfiguration.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ProtocolConnectionConfiguration create(final Endpoint endpoint, final URI uri, final OptionMap options) {
    final ProtocolConnectionConfiguration configuration = new ProtocolConnectionConfiguration();
    configuration.setEndpoint(endpoint);
    configuration.setUri(uri);
    configuration.setOptionMap(options);
    return configuration;
}
 
Example #26
Source File: RemotingModelControllerClient.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void close() throws IOException {
    synchronized (this) {
        if (closed) {
            return;
        }
        closed = true;
        // Don't allow any new request
        channelAssociation.shutdown();
        // First close the channel and connection
        if (strategy != null) {
            StreamUtils.safeClose(strategy);
            strategy = null;
        }
        // Then the endpoint
        final Endpoint endpoint = this.endpoint;
        if (endpoint != null) {
            this.endpoint = null;
            try {
                endpoint.closeAsync();
            } catch (UnsupportedOperationException ignored) {
            }
        }
        // Cancel all still active operations
        channelAssociation.shutdownNow();
        try {
            channelAssociation.awaitCompletion(1, TimeUnit.SECONDS);
        } catch (InterruptedException ignore) {
            Thread.currentThread().interrupt();
        } finally {
            StreamUtils.safeClose(clientConfiguration);
        }
        // Per WFCORE-1573 remoting endpoints should be closed asynchronously, however consumers of this client
        // likely need to wait until the endpoints are fully shutdown.
        if (endpoint != null) try {
            endpoint.awaitClosed();
        } catch (InterruptedException e) {
            final InterruptedIOException cause = new InterruptedIOException(e.getLocalizedMessage());
            cause.initCause(e);
            throw cause;
        }
    }
}
 
Example #27
Source File: ChannelServer.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ChannelServer(final Endpoint endpoint,
    final AcceptingChannel<StreamConnection> streamServer) {
    this.endpoint = endpoint;
    this.streamServer = streamServer;
}
 
Example #28
Source File: ChannelServer.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static ChannelServer create(final Configuration configuration) throws IOException {
    if (configuration == null) {
        throw new IllegalArgumentException("Null configuration");
    }
    configuration.validate();

    // Hack WFCORE-3302/REM3-303 workaround
    if (firstCreate) {
        firstCreate = false;
    } else {
        try {
            // wait in case the previous socket has not closed
            Thread.sleep(100);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        }
    }

    // TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok
    final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build();

    final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm();
    realm.setPasswordMap("bob", ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, "pass".toCharArray()));
    domainBuilder.addRealm("default", realm).build();
    domainBuilder.setDefaultRealmName("default");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    SecurityDomain testDomain = domainBuilder.build();
    SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder()
        .setSecurityDomain(testDomain)
        .setMechanismConfigurationSelector(mechanismInformation -> {
            switch (mechanismInformation.getMechanismName()) {
                case "ANONYMOUS":
                case "PLAIN": {
                    return MechanismConfiguration.EMPTY;
                }
                default: return null;
            }
        })
        .setFactory(SaslFactories.getElytronSaslServerFactory())
        .build();
    AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null);

    return new ChannelServer(endpoint, streamServer);
}
 
Example #29
Source File: ChannelServer.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Endpoint getEndpoint() {
    return endpoint;
}
 
Example #30
Source File: HostControllerConnectionService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public synchronized void start(final StartContext context) throws StartException {
    final Endpoint endpoint = endpointSupplier.get();
    try {
        // we leave local auth enabled as an option for domain servers to use if available. elytron only configuration
        // will require this to be enabled and available on the server side for servers to connect successfully.
        // final OptionMap options = OptionMap.create(Options.SASL_DISALLOWED_MECHANISMS, Sequence.of(JBOSS_LOCAL_USER));
        // Create the connection configuration
        final ProtocolConnectionConfiguration configuration = ProtocolConnectionConfiguration.create(endpoint, connectionURI, OptionMap.EMPTY);
        configuration.setCallbackHandler(HostControllerConnection.createClientCallbackHandler(userName, initialAuthKey));
        configuration.setConnectionTimeout(SERVER_CONNECTION_TIMEOUT);
        configuration.setSslContext(sslContextSupplier.get());
        this.responseAttachmentSupport = new ResponseAttachmentInputStreamSupport(scheduledExecutorSupplier.get());
        // Create the connection
        final HostControllerConnection connection = new HostControllerConnection(serverProcessName, userName, connectOperationID,
                configuration, responseAttachmentSupport, executorSupplier.get());
        // Trigger the started notification based on the process state listener
        final ProcessStateNotifier processService = processStateNotifierSupplier.get();
        processService.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(final PropertyChangeEvent evt) {
                final ControlledProcessState.State old = (ControlledProcessState.State) evt.getOldValue();
                final ControlledProcessState.State current = (ControlledProcessState.State) evt.getNewValue();
                if (old == ControlledProcessState.State.STARTING) {
                    // After starting reload has to be cleared, may still require a restart
                    if(current == ControlledProcessState.State.RUNNING
                            || current == ControlledProcessState.State.RESTART_REQUIRED) {
                        connection.started();
                    } else {
                        IoUtils.safeClose(connection);
                    }
                }
            }
        });
        this.client = new HostControllerClient(serverName, connection.getChannelHandler(), connection,
                managementSubsystemEndpoint, executorSupplier.get());
    } catch (Exception e) {
        throw new StartException(e);
    }
}