Search in sources :

Example 1 with StringUtil

use of org.apache.qpid.server.util.StringUtil in project qpid-broker-j by apache.

the class Main method execute.

protected void execute() throws Exception {
    Map<String, Object> attributes = new HashMap<>();
    String initialProperties = _commandLine.getOptionValue(OPTION_INITIAL_SYSTEM_PROPERTIES.getOpt());
    SystemLauncher.populateSystemPropertiesFromDefaults(initialProperties);
    String initialConfigLocation = _commandLine.getOptionValue(OPTION_INITIAL_CONFIGURATION_PATH.getOpt());
    if (initialConfigLocation != null) {
        attributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, initialConfigLocation);
    }
    // process the remaining options
    if (_commandLine.hasOption(OPTION_HELP.getOpt())) {
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("Qpid", OPTIONS, true);
    } else if (_commandLine.hasOption(OPTION_CREATE_INITIAL_CONFIG.getOpt())) {
        createInitialConfigCopy(initialConfigLocation);
    } else if (_commandLine.hasOption(OPTION_VERSION.getOpt())) {
        printVersion();
    } else {
        String[] configPropPairs = _commandLine.getOptionValues(OPTION_CONFIGURATION_PROPERTY.getOpt());
        Map<String, String> context = calculateConfigContext(configPropPairs);
        if (!context.isEmpty()) {
            attributes.put(SystemConfig.CONTEXT, context);
        }
        String configurationStore = _commandLine.getOptionValue(OPTION_CONFIGURATION_STORE_PATH.getOpt());
        if (configurationStore != null) {
            attributes.put("storePath", configurationStore);
        }
        String configurationStoreType = _commandLine.getOptionValue(OPTION_CONFIGURATION_STORE_TYPE.getOpt());
        attributes.put(SystemConfig.TYPE, configurationStoreType == null ? JsonSystemConfigImpl.SYSTEM_CONFIG_TYPE : configurationStoreType);
        boolean managementMode = _commandLine.hasOption(OPTION_MANAGEMENT_MODE.getOpt());
        if (managementMode) {
            attributes.put(SystemConfig.MANAGEMENT_MODE, true);
            String httpPort = _commandLine.getOptionValue(OPTION_MM_HTTP_PORT.getOpt());
            if (httpPort != null) {
                attributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, httpPort);
            }
            boolean quiesceVhosts = _commandLine.hasOption(OPTION_MM_QUIESCE_VHOST.getOpt());
            attributes.put(SystemConfig.MANAGEMENT_MODE_QUIESCE_VIRTUAL_HOSTS, quiesceVhosts);
            String password = _commandLine.getOptionValue(OPTION_MM_PASSWORD.getOpt());
            if (password == null) {
                password = new StringUtil().randomAlphaNumericString(MANAGEMENT_MODE_PASSWORD_LENGTH);
            }
            attributes.put(SystemConfig.MANAGEMENT_MODE_PASSWORD, password);
        }
        setExceptionHandler();
        startBroker(attributes);
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) HashMap(java.util.HashMap) StringUtil(org.apache.qpid.server.util.StringUtil)

Example 2 with StringUtil

use of org.apache.qpid.server.util.StringUtil in project qpid-broker-j by apache.

the class StringUtilTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _util = new StringUtil();
}
Also used : StringUtil(org.apache.qpid.server.util.StringUtil)

Example 3 with StringUtil

use of org.apache.qpid.server.util.StringUtil in project qpid-broker-j by apache.

the class SimpleLDAPAuthenticationManagerImpl method createSslSocketFactoryOverrideClass.

private Class<? extends SocketFactory> createSslSocketFactoryOverrideClass(final TrustStore trustStore) {
    String managerName = String.format("%s_%s_%s", getName(), getId(), trustStore == null ? "none" : trustStore.getName());
    String clazzName = new StringUtil().createUniqueJavaName(managerName);
    SSLContext sslContext = null;
    try {
        sslContext = SSLUtil.tryGetSSLContext();
        sslContext.init(null, trustStore == null ? null : trustStore.getTrustManagers(), null);
    } catch (GeneralSecurityException e) {
        LOGGER.error("Exception creating SSLContext", e);
        if (trustStore != null) {
            throw new IllegalConfigurationException("Error creating SSLContext with trust store : " + trustStore.getName(), e);
        } else {
            throw new IllegalConfigurationException("Error creating SSLContext (no trust store)", e);
        }
    }
    SSLSocketFactory sslSocketFactory = new CipherSuiteAndProtocolRestrictingSSLSocketFactory(sslContext.getSocketFactory(), _tlsCipherSuiteWhiteList, _tlsCipherSuiteBlackList, _tlsProtocolWhiteList, _tlsProtocolBlackList);
    Class<? extends AbstractLDAPSSLSocketFactory> clazz = LDAPSSLSocketFactoryGenerator.createSubClass(clazzName, sslSocketFactory);
    LOGGER.debug("Connection to Directory will use custom SSL socket factory : {}", clazz);
    return clazz;
}
Also used : GeneralSecurityException(java.security.GeneralSecurityException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) CipherSuiteAndProtocolRestrictingSSLSocketFactory(org.apache.qpid.server.util.CipherSuiteAndProtocolRestrictingSSLSocketFactory) SSLContext(javax.net.ssl.SSLContext) StringUtil(org.apache.qpid.server.util.StringUtil) CipherSuiteAndProtocolRestrictingSSLSocketFactory(org.apache.qpid.server.util.CipherSuiteAndProtocolRestrictingSSLSocketFactory) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) AbstractLDAPSSLSocketFactory(org.apache.qpid.server.security.auth.manager.ldap.AbstractLDAPSSLSocketFactory)

Aggregations

StringUtil (org.apache.qpid.server.util.StringUtil)3 GeneralSecurityException (java.security.GeneralSecurityException)1 HashMap (java.util.HashMap)1 SSLContext (javax.net.ssl.SSLContext)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 AbstractLDAPSSLSocketFactory (org.apache.qpid.server.security.auth.manager.ldap.AbstractLDAPSSLSocketFactory)1 CipherSuiteAndProtocolRestrictingSSLSocketFactory (org.apache.qpid.server.util.CipherSuiteAndProtocolRestrictingSSLSocketFactory)1