use of com.sun.identity.common.DebugPropertiesObserver in project OpenAM by OpenRock.
the class Bootstrap method getConfiguration.
/**
* Returns System Property with an URL.
*
* @param bootstrapData an URL that contains information on how to
* fetch the server configuration properties.
* @param reinit <code>true</code> to re initialize the system.
* @throws Exception if properties cannot be loaded.
*/
private static Properties getConfiguration(BootstrapData bootstrapData, boolean reinit, boolean bStartDS) throws Exception {
Properties properties = null;
bootstrapData.initSMS(bStartDS);
if (reinit) {
AdminUtils.initialize();
SMSAuthModule.initialize();
}
DSConfigMgr dsCfg = DSConfigMgr.getDSConfigMgr();
ServerGroup sg = dsCfg.getServerGroup("sms");
if (sg == null) {
return null;
}
try (ConnectionFactory factory = dsCfg.getNewConnectionFactory("sms", LDAPUser.Type.AUTH_ADMIN);
Connection conn = factory.getConnection()) {
// Success case. Managed to get connection
} catch (LDAPServiceException e) {
// ignore, DS is down
return null;
}
String dsbasedn = bootstrapData.getUserBaseDN();
String pwd = bootstrapData.getDsameUserPassword();
String dsameUser = "cn=dsameuser,ou=DSAME Users," + dsbasedn;
String instanceName = bootstrapData.getInstanceName();
SSOToken ssoToken = getSSOToken(dsbasedn, dsameUser, JCECrypt.decode(pwd));
try {
properties = ServerConfiguration.getServerInstance(ssoToken, instanceName);
if (properties != null) {
// set debug level to error because debug.message in
// SMSEntry.initializedClass won't work and will print out
// error message. Save the debug level and will be restored
// after SMSEntry.initializedClass.
String debugLevel = (String) properties.get(Constants.SERVICES_DEBUG_LEVEL);
boolean debugSetAtDefault = false;
if (debugLevel == null) {
debugSetAtDefault = true;
}
properties.setProperty(Constants.SERVICES_DEBUG_LEVEL, Debug.STR_ERROR);
SystemProperties.initializeProperties(properties, true, false);
DebugPropertiesObserver debugPO = DebugPropertiesObserver.getInstance();
String serverConfigXML = ServerConfiguration.getServerConfigXML(ssoToken, instanceName);
Crypt.reinitialize();
BootstrapData.loadServerConfigXML(serverConfigXML);
SMSEntry.initializeClass();
if (debugSetAtDefault) {
properties.remove(Constants.SERVICES_DEBUG_LEVEL);
} else {
properties.setProperty(Constants.SERVICES_DEBUG_LEVEL, debugLevel);
}
SystemProperties.initializeProperties(properties, true, true);
String defaultDebugLevel = SystemProperties.getProperties().getProperty(Constants.SERVICES_DEBUG_LEVEL);
if (debugSetAtDefault) {
properties.setProperty(Constants.SERVICES_DEBUG_LEVEL, defaultDebugLevel);
SystemProperties.initializeProperties(properties, true, true);
}
AdminUtils.initialize();
SMSAuthModule.initialize();
debugPO.notifyChanges();
SMSPropertiesObserver.getInstance().notifyChanges();
SystemProperties.setServerInstanceName(instanceName);
// ConfigurationObserver is already added when
// DebugPropertiesObserver.getInstance().notifyChanges();
// is called. Adding again causes 2 notification events
// to be sent.
// ServiceConfigManager scm = new ServiceConfigManager(
// Constants.SVC_NAME_PLATFORM, (SSOToken)
// AccessController.doPrivileged(
// AdminTokenAction.getInstance()));
// scm.addListener(ConfigurationObserver.getInstance());
}
} catch (SMSException e) {
//ignore. product is not configured yet.
System.out.println("Bootstrap.getConfiguration :" + e);
properties = null;
}
return properties;
}
Aggregations