org.jboss.as.network.SocketBinding Java Examples

The following examples show how to use org.jboss.as.network.SocketBinding. 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: CamelUndertowHostService.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
private void validateEndpointPort(URI httpURI) {
    // Camel HTTP endpoint port defaults are 0 or -1
    boolean portMatched = httpURI.getPort() == 0 || httpURI.getPort() == -1;

    // If a port was specified, verify that undertow has a listener configured for it
    if (!portMatched) {
        for (UndertowListener listener : defaultHost.getServer().getListeners()) {
            SocketBinding binding = listener.getSocketBinding();
            if (binding != null) {
                if (binding.getPort() == httpURI.getPort()) {
                    portMatched = true;
                    break;
                }
            }
        }
    }

    if (!"localhost".equals(httpURI.getHost())) {
        LOGGER.debug("Cannot bind to host other than 'localhost': {}", httpURI);
    }
    if (!portMatched) {
        LOGGER.debug("Cannot bind to specific port: {}", httpURI);
    }
}
 
Example #2
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 #3
Source File: ConnectorAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
void launchServices(OperationContext context, String connectorName, ModelNode fullModel) throws OperationFailedException {
    OptionMap optionMap = ConnectorUtils.getFullOptions(context, fullModel);

    final ServiceTarget target = context.getServiceTarget();

    final String socketName = ConnectorResource.SOCKET_BINDING.resolveModelAttribute(context, fullModel).asString();
    final ServiceName socketBindingName = context.getCapabilityServiceName(ConnectorResource.SOCKET_CAPABILITY_NAME, socketName, SocketBinding.class);

    ModelNode securityRealmModel = ConnectorResource.SECURITY_REALM.resolveModelAttribute(context, fullModel);
    final ServiceName securityRealmName = securityRealmModel.isDefined() ? SecurityRealm.ServiceUtil.createServiceName(securityRealmModel.asString()) : null;

    ModelNode saslAuthenticationFactoryModel = ConnectorResource.SASL_AUTHENTICATION_FACTORY.resolveModelAttribute(context, fullModel);
    final ServiceName saslAuthenticationFactoryName = saslAuthenticationFactoryModel.isDefined()
            ? context.getCapabilityServiceName(SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactoryModel.asString(), SaslAuthenticationFactory.class)
            : null;

    ModelNode sslContextModel = ConnectorResource.SSL_CONTEXT.resolveModelAttribute(context, fullModel);
    final ServiceName sslContextName = sslContextModel.isDefined()
            ? context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, sslContextModel.asString(), SSLContext.class) : null;

    final ServiceName sbmName = context.getCapabilityServiceName(SOCKET_BINDING_MANAGER_CAPABILTIY, SocketBindingManager.class);

    RemotingServices.installConnectorServicesForSocketBinding(target, RemotingServices.SUBSYSTEM_ENDPOINT, connectorName,
            socketBindingName, optionMap, securityRealmName, saslAuthenticationFactoryName, sslContextName, sbmName);
}
 
Example #4
Source File: SocketBindingService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public SocketBindingService(final Consumer<SocketBinding> socketBindingConsumer,
                            final Supplier<NetworkInterfaceBinding> interfaceBindingSupplier,
                            final Supplier<SocketBindingManager> socketBindingsSupplier,
                            final String name, int port, boolean isFixedPort,
                            InetAddress multicastAddress, int multicastPort,
                            List<ClientMapping> clientMappings) {
    assert name != null : "name is null";
    this.socketBindingConsumer = socketBindingConsumer;
    this.interfaceBindingSupplier = interfaceBindingSupplier;
    this.socketBindingsSupplier = socketBindingsSupplier;
    this.name = name;
    this.port = port;
    this.isFixedPort = isFixedPort;
    this.multicastAddress = multicastAddress;
    this.multicastPort = multicastPort;
    this.clientMappings = clientMappings;
}
 
Example #5
Source File: AbstractBindingWriteHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue,
                                       final ModelNode currentValue, final HandbackHolder<RollbackInfo> handbackHolder) throws OperationFailedException {

    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final PathElement element = address.getLastElement();
    final String bindingName = element.getValue();
    final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
    final ServiceName serviceName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, SocketBinding.class);
    final ServiceController<?> controller = context.getServiceRegistry(true).getRequiredService(serviceName);
    final SocketBinding binding = controller.getState() == ServiceController.State.UP ? SocketBinding.class.cast(controller.getValue()) : null;
    final boolean bound = binding != null && binding.isBound();
    if (binding == null) {
        // existing is not started, so can't update it. Instead reinstall the service
        handleBindingReinstall(context, bindingName, bindingModel, serviceName);
    } else if (bound) {
        // Cannot edit bound sockets
        return true;
    } else {
        handleRuntimeChange(context, operation, attributeName, resolvedValue, binding);
    }
    handbackHolder.setHandback(new RollbackInfo(bindingName, bindingModel, binding));
    return requiresRestart();
}
 
Example #6
Source File: RegistrationAdvertiser.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public static ServiceController<Void> install(ServiceTarget target,
                                              String serviceName,
                                              String socketBindingName,
                                              Collection<String> userDefinedTags) {
    List<String> tags = new ArrayList<>(userDefinedTags);
    tags.add(socketBindingName);

    ServiceName socketBinding = ServiceName.parse("org.wildfly.network.socket-binding." + socketBindingName);
    RegistrationAdvertiser advertiser = new RegistrationAdvertiser(serviceName, tags.toArray(new String[tags.size()]));

    return target.addService(ServiceName.of("swarm", "topology", "register", serviceName, socketBindingName), advertiser)
            .addDependency(CONNECTOR_SERVICE_NAME, TopologyConnector.class, advertiser.getTopologyConnectorInjector())
            .addDependency(socketBinding, SocketBinding.class, advertiser.getSocketBindingInjector())
            .setInitialMode(ServiceController.Mode.PASSIVE)
            .install();
}
 
Example #7
Source File: LocalDestinationOutboundSocketBindingAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void installOutboundSocketBindingService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();

    // socket name
    final String outboundSocketName = context.getCurrentAddressValue();
    final String socketBindingRef = LocalDestinationOutboundSocketBindingResourceDefinition.SOCKET_BINDING_REF.resolveModelAttribute(context, model).asString();
    // (optional) source interface
    final String sourceInterfaceName = OutboundSocketBindingResourceDefinition.SOURCE_INTERFACE.resolveModelAttribute(context, model).asStringOrNull();
    // (optional) source port
    final Integer sourcePort = OutboundSocketBindingResourceDefinition.SOURCE_PORT.resolveModelAttribute(context, model).asIntOrNull();
    // (optional but defaulted) fixedSourcePort
    final boolean fixedSourcePort = OutboundSocketBindingResourceDefinition.FIXED_SOURCE_PORT.resolveModelAttribute(context, model).asBoolean();

    // create the service
    final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY);
    final Consumer<OutboundSocketBinding> osbConsumer = builder.provides(OUTBOUND_SOCKET_BINDING_CAPABILITY);
    final Supplier<SocketBindingManager> sbmSupplier = builder.requiresCapability("org.wildfly.management.socket-binding-manager", SocketBindingManager.class);
    final Supplier<NetworkInterfaceBinding> nibSupplier = sourceInterfaceName != null ? builder.requiresCapability("org.wildfly.network.interface", NetworkInterfaceBinding.class, sourceInterfaceName) : null;
    final Supplier<SocketBinding> sbSupplier = builder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, socketBindingRef);
    builder.setInstance(new LocalDestinationOutboundSocketBindingService(osbConsumer, sbmSupplier, nibSupplier, sbSupplier, outboundSocketName, sourcePort, fixedSourcePort));
    builder.setInitialMode(ServiceController.Mode.ON_DEMAND);
    builder.addAliases(OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(outboundSocketName));
    builder.install();
}
 
Example #8
Source File: BindingAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void installBindingService(OperationContext context, ModelNode config, String name)
        throws UnknownHostException, OperationFailedException {
    final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();

    final ModelNode intfNode = AbstractSocketBindingResourceDefinition.INTERFACE.resolveModelAttribute(context, config);
    final String intf = intfNode.isDefined() ? intfNode.asString() : null;
    final int port = AbstractSocketBindingResourceDefinition.PORT.resolveModelAttribute(context, config).asInt();
    final boolean fixedPort = AbstractSocketBindingResourceDefinition.FIXED_PORT.resolveModelAttribute(context, config).asBoolean();
    final ModelNode mcastNode = AbstractSocketBindingResourceDefinition.MULTICAST_ADDRESS.resolveModelAttribute(context, config);
    final String mcastAddr = mcastNode.isDefined() ? mcastNode.asString() : null;
    final int mcastPort = AbstractSocketBindingResourceDefinition.MULTICAST_PORT.resolveModelAttribute(context, config).asInt(0);
    final InetAddress mcastInet = mcastAddr == null ? null : InetAddress.getByName(mcastAddr);
    final ModelNode mappingsNode = config.get(CLIENT_MAPPINGS);
    final List<ClientMapping> clientMappings = mappingsNode.isDefined() ? parseClientMappings(context, mappingsNode) : null;

    final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(SOCKET_BINDING_CAPABILITY);
    final Consumer<SocketBinding> sbConsumer = builder.provides(SOCKET_BINDING_CAPABILITY);
    final Supplier<NetworkInterfaceBinding> ibSupplier = intf != null ? builder.requiresCapability("org.wildfly.network.interface", NetworkInterfaceBinding.class, intf) : null;
    final Supplier<SocketBindingManager> sbSupplier = builder.requiresCapability("org.wildfly.management.socket-binding-manager", SocketBindingManager.class);
    final SocketBindingService service = new SocketBindingService(sbConsumer, ibSupplier, sbSupplier, name, port, fixedPort, mcastInet, mcastPort, clientMappings);
    builder.setInstance(service);
    builder.addAliases(SocketBinding.JBOSS_BINDING_NAME.append(name));
    builder.setInitialMode(Mode.ON_DEMAND);
    builder.install();
}
 
Example #9
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void addExtraServices(final ServiceTarget target) {
    ManagementRemotingServices.installRemotingManagementEndpoint(target, ManagementRemotingServices.MANAGEMENT_ENDPOINT, "localhost", EndpointService.EndpointType.MANAGEMENT);
    ServiceName tmpDirPath = ServiceName.JBOSS.append("server", "path", "jboss.controller.temp.dir");

    RemotingServices.installConnectorServicesForSocketBinding(target, ManagementRemotingServices.MANAGEMENT_ENDPOINT,
            "server", SocketBinding.JBOSS_BINDING_NAME.append("server"), OptionMap.EMPTY,
            null, null, null, ServiceName.parse("org.wildfly.management.socket-binding-manager"));
}
 
Example #10
Source File: TestHostCapableExtension.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 {
    boolean hasSocketBinding = resource.getModel().hasDefined(SOCKET_BINDING.getName());
    TestService service = new TestService(hasSocketBinding);
    ServiceBuilder<TestService> serviceBuilder = context.getServiceTarget().addService(createServiceName(context.getCurrentAddress()), service);
    if (hasSocketBinding) {
        final String socketName = SOCKET_BINDING.resolveModelAttribute(context, resource.getModel()).asString();
        final ServiceName socketBindingName = context.getCapabilityServiceName(RootResourceDefinition.SOCKET_CAPABILITY_NAME, socketName, SocketBinding.class);
        serviceBuilder.addDependency(socketBindingName, SocketBinding.class, service.socketBindingInjector);
    }
    serviceBuilder.install();
}
 
Example #11
Source File: ClientMappingsHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
void handleRuntimeRollback(OperationContext context, ModelNode operation, String attributeName, ModelNode attributeValue, SocketBinding binding) {
    try {
        binding.setClientMappings(BindingAddHandler.parseClientMappings(context, attributeValue));
    } catch (OperationFailedException e) {
        throw ControllerLogger.ROOT_LOGGER.failedToRecoverServices(e);
    }
}
 
Example #12
Source File: LocalDestinationOutboundSocketBindingService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LocalDestinationOutboundSocketBindingService(final Consumer<OutboundSocketBinding> outboundSocketBindingConsumer,
                                                    final Supplier<SocketBindingManager> socketBindingManagerSupplier,
                                                    final Supplier<NetworkInterfaceBinding> sourceInterfaceSupplier,
                                                    final Supplier<SocketBinding> localDestinationSocketBindingSupplier,
                                                    final String name, final Integer sourcePort, final boolean fixedSourcePort) {
    super(outboundSocketBindingConsumer, socketBindingManagerSupplier, sourceInterfaceSupplier, name, sourcePort, fixedSourcePort);
    this.localDestinationSocketBindingSupplier = localDestinationSocketBindingSupplier;
}
 
Example #13
Source File: OtherServicesSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Test that a port offset of 0 works correctly.
 */
@Test
public void testPortOffsetZero() throws Exception {
    ((OtherServicesSubsystemExtension)getMainExtension()).setAddHandler(SubsystemAddWithSocketBindingUserService.INSTANCE);

    //Parse the subsystem xml and install into the controller
    String subsystemXml =
            "<subsystem xmlns=\"" + SimpleSubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>";
    KernelServices services = createKernelServicesBuilder(new PortOffsetZeroInit())
            .setSubsystemXml(subsystemXml)
            .build();


    //Read the whole model and make sure it looks as expected
    ModelNode model = services.readWholeModel();
    Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(OtherServicesSubsystemExtension.SUBSYSTEM_NAME));

    ModelNode group = model.require(SOCKET_BINDING_GROUP).require(ControllerInitializer.SOCKET_BINDING_GROUP_NAME);
    Assert.assertEquals(8000, group.require(PORT_OFFSET).asInt());

    ModelNode bindings = group.require(SOCKET_BINDING);
    Assert.assertEquals(1, bindings.asList().size());
    Assert.assertEquals(0, group.require(SOCKET_BINDING).require("test2").require(PORT).asInt());

    ServiceController<?> controller = services.getContainer().getService(SocketBindingUserService.NAME);
    Assert.assertNotNull(controller);
    SocketBindingUserService service = (SocketBindingUserService)controller.getValue();
    SocketBinding socketBinding = service.socketBindingValue.getValue();
    Assert.assertEquals(8000, socketBinding.getSocketBindings().getPortOffset());
    Assert.assertFalse("fixed port", socketBinding.isFixedPort());
    Assert.assertEquals(0, socketBinding.getPort());
    // Port 0 must not be affected by port-offset
    Assert.assertEquals(0, socketBinding.getSocketAddress().getPort());
}
 
Example #14
Source File: SubsystemAddWithSocketBindingUserService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void performBoottime(OperationContext context, ModelNode operation, Resource resource)
        throws OperationFailedException {

    SocketBindingUserService mine = new SocketBindingUserService();
    context.getServiceTarget().addService(SocketBindingUserService.NAME, mine)
        .addDependency(SocketBinding.JBOSS_BINDING_NAME.append("test2"), SocketBinding.class, mine.socketBindingValue)
        .install();

}
 
Example #15
Source File: TestHostCapableExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    if (hasSocketBinding) {
        SocketBinding binding = socketBindingInjector.getValue();
        try {
            serverSocket = binding.createServerSocket();
        } catch (IOException e) {
            throw new StartException(e);
        }
    }
}
 
Example #16
Source File: JGroupsTopologyConnector.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
public synchronized void unadvertise(String appName, SocketBinding binding) {
    Registration registration = this.registrations.remove(appName + ":" + binding.getName());
    if (registration != null) {
        try {
            this.dispatcher.submitOnCluster(new UnadvertiseCommand(registration));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example #17
Source File: LocalDestinationOutboundSocketBindingService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private int getDestinationPort() {
    final SocketBinding localDestinationSocketBinding = localDestinationSocketBindingSupplier.get();
    // instead of directly using SocketBinding.getPort(), we go via the SocketBinding.getSocketAddress()
    // since the getPort() method doesn't take into account whether the port is a fixed port or whether an offset
    // needs to be added. Alternatively, we could introduce a getAbsolutePort() in the SocketBinding class.
    final InetSocketAddress socketAddress = localDestinationSocketBinding.getSocketAddress();
    return socketAddress.getPort();
}
 
Example #18
Source File: AbstractBindingWriteHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void revertBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel,
                                    String attributeName, ModelNode previousValue) {
    final ServiceName serviceName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, SocketBinding.class);
    context.removeService(serviceName);
    ModelNode unresolvedConfig = bindingModel.clone();
    unresolvedConfig.get(attributeName).set(previousValue);
    try {
        BindingAddHandler.installBindingService(context, unresolvedConfig, bindingName);
    } catch (Exception e) {
        // Bizarro, as we installed the service before
        throw new RuntimeException(e);
    }
}
 
Example #19
Source File: OtherServicesSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Test that socket binding got added properly
 */
@Test
public void testSocketBinding() throws Exception {
    ((OtherServicesSubsystemExtension)getMainExtension()).setAddHandler(SubsystemAddWithSocketBindingUserService.INSTANCE);

    //Parse the subsystem xml and install into the controller
    String subsystemXml =
            "<subsystem xmlns=\"" + SimpleSubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>";
    KernelServices services = createKernelServicesBuilder(new SocketBindingInit())
            .setSubsystemXml(subsystemXml)
            .build();


    //Read the whole model and make sure it looks as expected
    ModelNode model = services.readWholeModel();
    Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(OtherServicesSubsystemExtension.SUBSYSTEM_NAME));

    ModelNode iface = model.require(INTERFACE).require(ControllerInitializer.INTERFACE_NAME);
    Assert.assertEquals("127.0.0.1", iface.require(INET_ADDRESS).asString());

    ModelNode group = model.require(SOCKET_BINDING_GROUP).require(ControllerInitializer.SOCKET_BINDING_GROUP_NAME);
    Assert.assertEquals(ControllerInitializer.INTERFACE_NAME, group.require(DEFAULT_INTERFACE).asString());
    Assert.assertEquals(ControllerInitializer.SOCKET_BINDING_GROUP_NAME, group.require(NAME).asString());
    Assert.assertEquals(0, group.require(PORT_OFFSET).asInt());

    ModelNode bindings = group.require(SOCKET_BINDING);
    Assert.assertEquals(3, bindings.asList().size());
    Assert.assertEquals(123, group.require(SOCKET_BINDING).require("test1").require(PORT).asInt());
    Assert.assertEquals(234, group.require(SOCKET_BINDING).require("test2").require(PORT).asInt());
    Assert.assertEquals(345, group.require(SOCKET_BINDING).require("test3").require(PORT).asInt());

    ServiceController<?> controller = services.getContainer().getService(SocketBindingUserService.NAME);
    Assert.assertNotNull(controller);
    SocketBindingUserService service = (SocketBindingUserService)controller.getValue();
    SocketBinding socketBinding = service.socketBindingValue.getValue();
    Assert.assertEquals(234, socketBinding.getPort());
    Assert.assertEquals("127.0.0.1", socketBinding.getAddress().getHostAddress());
}
 
Example #20
Source File: JMXSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void addExtraServices(final ServiceTarget target) {
    ManagementRemotingServices.installRemotingManagementEndpoint(target, ManagementRemotingServices.MANAGEMENT_ENDPOINT, "localhost", EndpointService.EndpointType.MANAGEMENT);

    RemotingServices.installConnectorServicesForSocketBinding(target, ManagementRemotingServices.MANAGEMENT_ENDPOINT,
            "remote", SocketBinding.JBOSS_BINDING_NAME.append("remote"), OptionMap.EMPTY,
            null, null, null, ServiceName.parse("org.wildfly.management.socket-binding-manager"));
}
 
Example #21
Source File: BindingRuntimeHandlers.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
void execute(final ModelNode operation, final SocketBinding binding, final ModelNode result) {
    ManagedBinding managedBinding = binding.getManagedBinding();
    if (managedBinding != null) {
        InetAddress addr = managedBinding.getBindAddress().getAddress();
        result.set(NetworkUtils.canonize(addr.getHostAddress()));
    }
}
 
Example #22
Source File: SocketBindingService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(final StartContext context) {
    binding = new SocketBinding(name, port, isFixedPort,
       multicastAddress, multicastPort,
       interfaceBindingSupplier != null ? interfaceBindingSupplier.get() : null,
       socketBindingsSupplier.get(), clientMappings);
    socketBindingConsumer.accept(binding);
}
 
Example #23
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 #24
Source File: NativeManagementAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected List<ServiceName> installServices(OperationContext context, NativeInterfaceCommonPolicy commonPolicy, ModelNode model)
        throws OperationFailedException {
    final ServiceTarget serviceTarget = context.getServiceTarget();

    final ServiceName endpointName = ManagementRemotingServices.MANAGEMENT_ENDPOINT;
    final String hostName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null);

    NativeManagementServices.installManagementWorkerService(serviceTarget, context.getServiceRegistry(false));
    NativeManagementServices.installRemotingServicesIfNotInstalled(serviceTarget, hostName, context.getServiceRegistry(false));

    final String bindingName = SOCKET_BINDING.resolveModelAttribute(context, model).asString();
    ServiceName socketBindingServiceName = context.getCapabilityServiceName(SOCKET_BINDING_CAPABILITY_NAME, bindingName, SocketBinding.class);

    String securityRealm = commonPolicy.getSecurityRealm();
    String saslAuthenticationFactory = commonPolicy.getSaslAuthenticationFactory();
    if (saslAuthenticationFactory == null && securityRealm == null) {
        ServerLogger.ROOT_LOGGER.nativeManagementInterfaceIsUnsecured();
    }

    ServiceName securityRealmName = securityRealm != null ? SecurityRealm.ServiceUtil.createServiceName(securityRealm) : null;
    ServiceName saslAuthenticationFactoryName = saslAuthenticationFactory != null ? context.getCapabilityServiceName(
            SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactory, SaslAuthenticationFactory.class) : null;
    String sslContext = commonPolicy.getSSLContext();
    ServiceName sslContextName = sslContext != null ? context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, sslContext, SSLContext.class) : null;

    final ServiceName sbmName = context.getCapabilityServiceName("org.wildfly.management.socket-binding-manager", SocketBindingManager.class);

    ManagementRemotingServices.installConnectorServicesForSocketBinding(serviceTarget, endpointName,
                ManagementRemotingServices.MANAGEMENT_CONNECTOR,
                socketBindingServiceName, commonPolicy.getConnectorOptions(),
                securityRealmName, saslAuthenticationFactoryName, sslContextName, sbmName);
    return Arrays.asList(REMOTING_BASE.append("server", MANAGEMENT_CONNECTOR), socketBindingServiceName);
}
 
Example #25
Source File: UndertowHttpManagementService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public NetworkInterfaceBinding getHttpNetworkInterfaceBinding() {
    NetworkInterfaceBinding binding = interfaceBindingSupplier != null ? interfaceBindingSupplier.get() : null;
    if (binding == null) {
        SocketBinding socketBinding = socketBindingSupplier != null ? socketBindingSupplier.get() : null;
        if (socketBinding != null) {
            binding = socketBinding.getNetworkInterfaceBinding();
        }
    }
    return binding;
}
 
Example #26
Source File: UndertowHttpManagementService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public NetworkInterfaceBinding getHttpsNetworkInterfaceBinding() {
    NetworkInterfaceBinding binding = interfaceBindingSupplier != null ? interfaceBindingSupplier.get() : null;
    if (binding == null) {
        SocketBinding socketBinding = secureSocketBindingSupplier != null ? secureSocketBindingSupplier.get() : null;
        if (socketBinding != null) {
            binding = socketBinding.getNetworkInterfaceBinding();
        }
    }
    return binding;
}
 
Example #27
Source File: BindingMulticastAddressHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
void handleRuntimeRollback(OperationContext context, ModelNode operation, String attributeName, ModelNode attributeValue, SocketBinding binding) {
    final InetAddress address;
    if(attributeValue.isDefined()) {
        String addrString = attributeValue.asString();
        try {
            address = InetAddress.getByName(addrString);
        } catch (UnknownHostException e) {
            throw ServerLogger.ROOT_LOGGER.failedToResolveMulticastAddressForRollback(e, addrString);
        }
    } else {
        address = null;
    }
    binding.setMulticastAddress(address);
}
 
Example #28
Source File: TransactionsArquillianTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testPorts() throws Exception {
    ServiceController<SocketBinding> statusManagerService = (ServiceController<SocketBinding>) registry.getService(ServiceName.parse("org.wildfly.network.socket-binding.txn-status-manager"));
    SocketBinding statusManager = statusManagerService.getValue();
    assertEquals(9876, statusManager.getAbsolutePort());

    ServiceController<SocketBinding> recoveryService = (ServiceController<SocketBinding>) registry.getService(ServiceName.parse("org.wildfly.network.socket-binding.txn-recovery-environment"));
    SocketBinding recovery = recoveryService.getValue();
    assertEquals(4567, recovery.getAbsolutePort());

}
 
Example #29
Source File: BindingRuntimeHandlers.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
void execute(final ModelNode operation, final SocketBinding binding, final ModelNode result) {
    ManagedBinding managedBinding = binding.getManagedBinding();
    if (managedBinding != null) {
        int port = managedBinding.getBindAddress().getPort();
        result.set(port);
    }
}
 
Example #30
Source File: BindingMulticastAddressHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
void handleRuntimeChange(OperationContext context, ModelNode operation, String attributeName, ModelNode attributeValue, SocketBinding binding) throws OperationFailedException {
    final InetAddress address;
    if(attributeValue.isDefined()) {
        String addrString = attributeValue.asString();
        try {
            address = InetAddress.getByName(addrString);
        } catch (UnknownHostException e) {
            throw ServerLogger.ROOT_LOGGER.failedToResolveMulticastAddress(e, addrString);
        }
    } else {
        address = null;
    }
    binding.setMulticastAddress(address);
}