Exemplo n.º 1
0
  public static ChannelServer create(final Configuration configuration) throws IOException {
    if (configuration == null) {
      throw new IllegalArgumentException("Null configuration");
    }
    configuration.validate();

    final Endpoint endpoint =
        Remoting.createEndpoint(configuration.getEndpointName(), configuration.getOptionMap());

    Registration registration =
        endpoint.addConnectionProvider(
            configuration.getUriScheme(),
            new RemoteConnectionProviderFactory(),
            OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE));

    final NetworkServerProvider networkServerProvider =
        endpoint.getConnectionProviderInterface(
            configuration.getUriScheme(), NetworkServerProvider.class);
    SimpleServerAuthenticationProvider provider = new SimpleServerAuthenticationProvider();
    // There is currently a probable bug in jboss remoting, so the user realm name MUST be the same
    // as
    // the endpoint name.
    provider.addUser("bob", configuration.getEndpointName(), "pass".toCharArray());
    AcceptingChannel<? extends ConnectedStreamChannel> streamServer =
        networkServerProvider.createServer(
            configuration.getBindAddress(),
            OptionMap.create(Options.SASL_MECHANISMS, Sequence.of("CRAM-MD5")),
            provider,
            null);

    return new ChannelServer(endpoint, registration, streamServer);
  }
Exemplo n.º 2
0
  public void start() throws IOException {
    log.infof("Starting JMX Remoting Server %s", Version.getVersionString());

    // Initialise general Remoting - this step would be implemented elsewhere when
    // running within an application server.
    final Xnio xnio = Xnio.getInstance();
    endpoint = Remoting.createEndpoint("JMXRemoting", xnio, OptionMap.EMPTY);
    endpoint.addConnectionProvider(
        "remote", new RemoteConnectionProviderFactory(), OptionMap.EMPTY);

    final NetworkServerProvider nsp =
        endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SocketAddress bindAddress = new InetSocketAddress(host, listenerPort);
    final OptionMap serverOptions = createOptionMap();

    server = nsp.createServer(bindAddress, serverOptions, authenticationProvider, null);

    Map<String, Object> configMap = new HashMap<String, Object>();
    if (excludedVersions != null) {
      configMap.put(EXCLUDED_VERSIONS, excludedVersions);
    }
    // Initialise the components that will provide JMX connectivity.
    if (mbeanServerLocator == null) {
      connectorServer =
          new RemotingConnectorServer(
              mbeanServer, endpoint, configMap, serverMessageEventHandlerFactory);
      connectorServer.start();
    } else {
      delegatingServer =
          new DelegatingRemotingConnectorServer(
              mbeanServerLocator, endpoint, configMap, serverMessageEventHandlerFactory);
      delegatingServer.start();
    }
  }
 @BeforeClass
 public static void create() throws Exception {
   final WildFlyElytronProvider provider = new WildFlyElytronProvider();
   Security.addProvider(provider);
   providerName = provider.getName();
   endpoint = Endpoint.builder().setEndpointName("test").build();
   NetworkServerProvider networkServerProvider =
       endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
   final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
   final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
   domainBuilder.addRealm("mainRealm", mainRealm).build();
   domainBuilder.setDefaultRealmName("mainRealm");
   domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
   final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
   mainRealm.setPasswordMap(
       "bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
   final SaslServerFactory saslServerFactory =
       new ServiceLoaderSaslServerFactory(RemoteChannelCloseTest.class.getClassLoader());
   final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
   builder.setSecurityDomain(domainBuilder.build());
   builder.setFactory(saslServerFactory);
   builder.addMechanism(
       SaslMechanismInformation.Names.SCRAM_SHA_256, MechanismConfiguration.EMPTY);
   final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
   streamServer =
       networkServerProvider.createServer(
           new InetSocketAddress("localhost", 30123), OptionMap.EMPTY, saslAuthenticationFactory);
 }
  private void startServer() throws Exception {
    final Xnio xnio = Xnio.getInstance();
    endpoint = Remoting.createEndpoint("RemoteNaming", xnio, OptionMap.EMPTY);
    endpoint.addConnectionProvider(
        "remote", new RemoteConnectionProviderFactory(), OptionMap.EMPTY);
    final NetworkServerProvider nsp =
        endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SocketAddress bindAddress = new InetSocketAddress("localhost", 7999);
    final OptionMap serverOptions = TestUtils.createOptionMap();

    server =
        nsp.createServer(
            bindAddress, serverOptions, new TestUtils.DefaultAuthenticationHandler(), null);
    remoteNamingService = new RemoteNamingService(localContext, Executors.newFixedThreadPool(10));
    remoteNamingService.start(endpoint);

    serverStopped = false;
  }
Exemplo n.º 5
0
  public void start() throws IOException {
    log.infof("Starting JMX Remoting Server %s", Version.getVersionString());

    // Initialise general Remoting - this step would be implemented elsewhere when
    // running within an application server.
    final Xnio xnio = Xnio.getInstance();
    endpoint = Remoting.createEndpoint("JMXRemoting", xnio, OptionMap.EMPTY);
    endpoint.addConnectionProvider(
        "remote", new RemoteConnectionProviderFactory(), OptionMap.EMPTY);

    final NetworkServerProvider nsp =
        endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SocketAddress bindAddress = new InetSocketAddress("localhost", listenerPort);
    final OptionMap serverOptions = createOptionMap();

    server = nsp.createServer(bindAddress, serverOptions, authenticationProvider, null);

    // Initialise the components that will provide JMX connectivity.
    connectorServer = new RemotingConnectorServer(mbeanServer, endpoint);
    connectorServer.start();
  }