use of com.sun.identity.common.configuration.ServerConfigXML.ServerGroup in project OpenAM by OpenRock.
the class AddAMSDKIdRepoPlugin method updateServerConfigXML.
private void updateServerConfigXML() throws Exception {
SSOToken adminSSOToken = getAdminSSOToken();
Set servers = ServerConfiguration.getServers(adminSSOToken);
Map newValues = new HashMap();
newValues.put("com.sun.am.event.connection.disable.list", "");
for (Iterator items = servers.iterator(); items.hasNext(); ) {
String instance = (String) items.next();
String serverconfig = ServerConfiguration.getServerConfigXML(adminSSOToken, instance);
ServerConfigXML cxml = new ServerConfigXML(serverconfig);
ServerGroup defaultGroup = cxml.getDefaultServerGroup();
// Add directory servers
if ((directoryServers != null) && !directoryServers.isEmpty()) {
defaultGroup.hosts.clear();
int i = 1;
for (Iterator dshosts = directoryServers.iterator(); dshosts.hasNext(); i++) {
String dshost = (String) dshosts.next();
// Parse the dshost
String name = "SERVER" + i;
DSEntry dsEntry = new DSEntry(dshost);
String type = (dsEntry.ssl) ? "SSL" : "SIMPLE";
String host = dsEntry.host;
String port = Integer.toString(dsEntry.port);
defaultGroup.addHost(name, host, port, type);
}
}
// Set the base dn
defaultGroup.dsBaseDN = basedn;
// Set admin & proxy user's password
for (Iterator users = defaultGroup.dsUsers.iterator(); users.hasNext(); ) {
DirUserObject user = (DirUserObject) users.next();
if (user.type.equals("proxy")) {
user.dn = "cn=puser,ou=DSAME Users," + basedn;
user.password = Crypt.encode(pUserPwd);
} else if (user.type.equals("admin")) {
user.dn = "cn=dsameuser,ou=DSAME Users," + basedn;
user.password = Crypt.encode(dUserPwd);
}
}
// Saver serverconfig.xml
ServerConfiguration.setServerConfigXML(adminSSOToken, instance, cxml.toXML());
// Enable psearch for um, aci and sm
ServerConfiguration.setServerInstance(adminSSOToken, instance, newValues);
}
}
use of com.sun.identity.common.configuration.ServerConfigXML.ServerGroup in project OpenAM by OpenRock.
the class AMSetupServlet method syncServerInfoWithRelication.
/**
* Synchronizes embedded replication state with current server list.
* @return boolean true is sync succeeds else false.
*/
private static boolean syncServerInfoWithRelication() {
// We need to execute syn only if we are in Embedded mode
if (!isEmbeddedDS()) {
return true;
}
try {
if (getAdminSSOToken() == null) {
Debug.getInstance(SetupConstants.DEBUG_NAME).error("AMSetupServlet.syncServerInfoWithRelication: " + "Could not sync servers with embedded replication:no admin token");
return false;
}
// Determine which server this is
String myName = WebtopNaming.getLocalServer();
// See if we need to execute sync
// Check if we are already replication with other servers
Properties props = ServerConfiguration.getServerInstance(adminToken, myName);
String syncFlag = props.getProperty(Constants.EMBED_SYNC_SERVERS);
if ("off".equals(syncFlag)) {
return true;
}
// Get server list
Set<String> serverSet = ServerConfiguration.getServers(adminToken);
if (serverSet == null) {
return true;
}
String dsAdminPort = props.getProperty(Constants.DS_ADMIN_PORT);
Set<String> currServerSet = new HashSet<String>();
Set<String> currServerDSSet = new HashSet<String>();
Set<String> currServerDSAdminPortsSet = new HashSet<String>();
for (String sname : serverSet) {
Properties p = ServerConfiguration.getServerInstance(adminToken, sname);
String hname = p.getProperty(Constants.AM_SERVER_HOST);
String rPort = p.getProperty(Constants.EMBED_REPL_PORT);
currServerSet.add(hname + ":" + rPort);
ServerGroup sg = getSMSServerGroup(sname);
currServerDSSet.add(hname + ":" + getSMSPort(sg));
currServerDSAdminPortsSet.add(hname + ":" + p.getProperty(Constants.DS_ADMIN_PORT));
}
// Ensure OpenDJ system properties are setup so that it can discover its installation root
final String embeddedDjInstallRoot = getBaseDir() + "/" + SetupConstants.SMS_OPENDS_DATASTORE;
for (String property : OpenDJUpgrader.INSTALL_ROOT_PROPERTIES) {
System.setProperty(property, embeddedDjInstallRoot);
}
// Force initialization of embedded DJ configuration with the correct installation root
if (!ConfigurationFramework.getInstance().isInitialized()) {
ConfigurationFramework.getInstance().initialize(embeddedDjInstallRoot);
}
ServerGroup sGroup = getSMSServerGroup(myName);
boolean stats = EmbeddedOpenDS.syncReplicatedServers(currServerSet, dsAdminPort, getSMSPassword(sGroup));
boolean statd = EmbeddedOpenDS.syncReplicatedDomains(currServerSet, dsAdminPort, getSMSPassword(sGroup));
boolean statl = EmbeddedOpenDS.syncReplicatedServerList(currServerDSAdminPortsSet, getSMSPort(sGroup), getSMSPassword(sGroup));
return stats || statd || statl;
} catch (Exception ex) {
Debug.getInstance(SetupConstants.DEBUG_NAME).error("AMSetupServlet.syncServerInfoWithRelication: " + "Could not sync servers with embedded replication:", ex);
return false;
}
}
Aggregations