Search in sources :

Example 11 with BrokerConfig

use of com.sun.messaging.jmq.jmsserver.config.BrokerConfig in project openmq by eclipse-ee4j.

the class AccessController method getInstance.

public static AccessController getInstance(String serviceName, int serviceType, boolean forceBasic) throws BrokerException {
    AccessController ac = new AccessController();
    ac.setServiceName(serviceName);
    ac.setServiceType(serviceType);
    String value = null;
    BrokerConfig config = Globals.getConfig();
    value = config.getProperty(PROP_ACCESSCONTROL_ENABLED);
    if (value != null && value.equals("false")) {
        ac.setAccessControlEnabled(false);
    }
    value = config.getProperty(PROP_SERVICE_PREFIX + serviceName + PROP_ACCESSCONTROL_ENABLED_SUFFIX);
    if (value != null && !value.trim().equals("")) {
        if (value.equals("false")) {
            ac.setAccessControlEnabled(false);
        } else {
            ac.setAccessControlEnabled(true);
        }
    }
    ac.getAuthProperties().setProperty(PROP_ACCESSCONTROL_ENABLED, (ac.isAccessControlEnabled() ? "true" : "false"));
    value = config.getProperty(PROP_SERVICE_PREFIX + serviceName + PROP_AUTHENTICATION_TYPE_SUFFIX);
    if (value == null || value.trim().equals("")) {
        value = config.getProperty(PROP_AUTHENTICATION_TYPE);
    }
    if (value != null && !value.trim().equals("")) {
        ac.setAuthType(value);
    }
    if (forceBasic) {
        ac.setAuthType(AUTHTYPE_BASIC);
    }
    if (ac.getAuthType().equals(AUTHTYPE_JMQADMINKEY) || ac.getAuthType().equals(BAD_AUTHTYPE)) {
        throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_UNSUPPORTED_AUTHTYPE, ac.getAuthType()));
    }
    ac.getAuthProperties().setProperty(PROP_AUTHENTICATION_TYPE, ac.getAuthType());
    loadProps(ac);
    return ac;
}
Also used : BrokerConfig(com.sun.messaging.jmq.jmsserver.config.BrokerConfig) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 12 with BrokerConfig

use of com.sun.messaging.jmq.jmsserver.config.BrokerConfig in project openmq by eclipse-ee4j.

the class CommGlobals method getConfig.

// ------------------------------------------------------------------------
// -- static methods for the singleton pattern --
// ------------------------------------------------------------------------
/**
 * method to return the singleton config class
 */
public static BrokerConfig getConfig() {
    if (config == null) {
        synchronized (lock) {
            if (config == null) {
                try {
                    config = new BrokerConfig(configName, parameters, clearProps, saveProps);
                } catch (BrokerException ex) {
                    getLogger().logStack(Logger.ERROR, "Internal Error: Unable to load broker, configuration properties are not available. Exiting", ex.getCause());
                    getCommBroker().exit(-1, "Internal Error: Unable to load broker," + " configuration properties are not available. Exiting", BrokerEvent.Type.FATAL_ERROR);
                }
                // now handle parameters
                if (parameters != null) {
                    // set any non-jmq properties as system properties
                    Enumeration en = parameters.propertyNames();
                    Properties sysprops = System.getProperties();
                    while (en.hasMoreElements()) {
                        String name = (String) en.nextElement();
                        if (!name.startsWith(IMQ + ".")) {
                            sysprops.put(name, parameters.getProperty(name));
                        }
                    }
                }
                // First thing we do after reading in configuration
                // is to initialize the Logger
                Logger l = getLogger();
                l.configure(config, IMQ, (getCommBroker() != null && getCommBroker().isInProcessBroker()), isJMSRAManagedSpecified(), (isNucleusManagedBroker() ? habitat : null));
                // LoggerManager will register as a config listener
                // to handle dynamic updates to logger properties
                new LoggerManager(logger, config);
            // l.open();
            }
        }
    }
    return config;
}
Also used : BrokerConfig(com.sun.messaging.jmq.jmsserver.config.BrokerConfig) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) Enumeration(java.util.Enumeration) LoggerManager(com.sun.messaging.jmq.jmsserver.util.LoggerManager) Properties(java.util.Properties) Logger(com.sun.messaging.jmq.util.log.Logger)

Example 13 with BrokerConfig

use of com.sun.messaging.jmq.jmsserver.config.BrokerConfig in project openmq by eclipse-ee4j.

the class Globals method getHAEnabled.

public static boolean getHAEnabled() {
    if (HAEnabled == null) {
        BrokerConfig conf = getConfig();
        boolean isHA = conf.getBooleanProperty(HA_ENABLED_PROPERTY, HA_ENABLED_DEFAULT);
        String clusterID = conf.getProperty(Globals.CLUSTERID_PROPERTY);
        synchronized (lock) {
            if (HAEnabled == null) {
                if (isHA) {
                    if (clusterID == null || clusterID.length() == 0) {
                        throw new RuntimeException(getBrokerResources().getKString(BrokerResources.X_CID_MUST_BE_SET_HA));
                    }
                    Globals.HAEnabled = Boolean.TRUE;
                    Globals.clusterID = clusterID;
                } else {
                    if (clusterID != null && clusterID.length() != 0) {
                        Globals.clusterID = clusterID;
                    }
                    Globals.HAEnabled = Boolean.FALSE;
                }
            }
        }
    }
    return HAEnabled.booleanValue();
}
Also used : BrokerConfig(com.sun.messaging.jmq.jmsserver.config.BrokerConfig) BrokerShutdownRuntimeException(com.sun.messaging.jmq.jmsserver.util.BrokerShutdownRuntimeException)

Aggregations

BrokerConfig (com.sun.messaging.jmq.jmsserver.config.BrokerConfig)13 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)7 Logger (com.sun.messaging.jmq.util.log.Logger)2 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 List (java.util.List)2 Properties (java.util.Properties)2 FileTransactionLogWriter (com.sun.messaging.jmq.io.txnlog.file.FileTransactionLogWriter)1 BrokerShutdownRuntimeException (com.sun.messaging.jmq.jmsserver.util.BrokerShutdownRuntimeException)1 LoggerManager (com.sun.messaging.jmq.jmsserver.util.LoggerManager)1 MQRMIClientSocketFactory (com.sun.messaging.jmq.management.MQRMIClientSocketFactory)1 Password (com.sun.messaging.jmq.util.Password)1 SizeString (com.sun.messaging.jmq.util.SizeString)1 AccessControlException (java.security.AccessControlException)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LoginException (javax.security.auth.login.LoginException)1