Search in sources :

Example 1 with DefaultSystemLauncherListener

use of org.apache.qpid.server.SystemLauncherListener.DefaultSystemLauncherListener in project qpid-broker-j by apache.

the class SNITest method doBrokerStartup.

private void doBrokerStartup(boolean useMatching, String defaultAlias) throws Exception {
    final File initialConfiguration = createInitialContext();
    _brokerWork = TestFileUtils.createTestDirectory("qpid-work", true);
    Map<String, String> context = new HashMap<>();
    context.put("qpid.work_dir", _brokerWork.toString());
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, initialConfiguration.getAbsolutePath());
    attributes.put(SystemConfig.TYPE, JsonSystemConfigImpl.SYSTEM_CONFIG_TYPE);
    attributes.put(SystemConfig.CONTEXT, context);
    _systemLauncher = new SystemLauncher(new DefaultSystemLauncherListener() {

        @Override
        public void onContainerResolve(final SystemConfig<?> systemConfig) {
            _broker = systemConfig.getContainer(Broker.class);
        }
    });
    _systemLauncher.startup(attributes);
    final Map<String, Object> authProviderAttr = new HashMap<>();
    authProviderAttr.put(AuthenticationProvider.NAME, "myAuthProvider");
    authProviderAttr.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE);
    final AuthenticationProvider authProvider = _broker.createChild(AuthenticationProvider.class, authProviderAttr);
    Map<String, Object> keyStoreAttr = new HashMap<>();
    keyStoreAttr.put(FileKeyStore.NAME, "myKeyStore");
    keyStoreAttr.put(FileKeyStore.STORE_URL, _keyStoreFile.toURI().toURL().toString());
    keyStoreAttr.put(FileKeyStore.PASSWORD, KEYSTORE_PASSWORD);
    keyStoreAttr.put(FileKeyStore.USE_HOST_NAME_MATCHING, useMatching);
    keyStoreAttr.put(FileKeyStore.CERTIFICATE_ALIAS, defaultAlias);
    final KeyStore keyStore = _broker.createChild(KeyStore.class, keyStoreAttr);
    Map<String, Object> portAttr = new HashMap<>();
    portAttr.put(Port.NAME, "myPort");
    portAttr.put(Port.TYPE, "AMQP");
    portAttr.put(Port.TRANSPORTS, Collections.singleton(Transport.SSL));
    portAttr.put(Port.PORT, 0);
    portAttr.put(Port.AUTHENTICATION_PROVIDER, authProvider);
    portAttr.put(Port.KEY_STORE, keyStore);
    final Port<?> port = _broker.createChild(Port.class, portAttr);
    _boundPort = port.getBoundPort();
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) FileKeyStore(org.apache.qpid.server.security.FileKeyStore) KeyStore(org.apache.qpid.server.model.KeyStore) SystemLauncher(org.apache.qpid.server.SystemLauncher) DefaultSystemLauncherListener(org.apache.qpid.server.SystemLauncherListener.DefaultSystemLauncherListener) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) File(java.io.File)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 SystemLauncher (org.apache.qpid.server.SystemLauncher)1 DefaultSystemLauncherListener (org.apache.qpid.server.SystemLauncherListener.DefaultSystemLauncherListener)1 AuthenticationProvider (org.apache.qpid.server.model.AuthenticationProvider)1 Broker (org.apache.qpid.server.model.Broker)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 KeyStore (org.apache.qpid.server.model.KeyStore)1 SystemConfig (org.apache.qpid.server.model.SystemConfig)1 FileKeyStore (org.apache.qpid.server.security.FileKeyStore)1