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;
}
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;
}
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();
}
Aggregations