use of com.sun.identity.common.configuration.ServerConfigXML.DirUserObject in project OpenAM by OpenRock.
the class ServerConfigXMLViewBean method handleButton1Request.
/**
* Handles save request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) {
submitCycle = true;
String svrMinPool = (String) getDisplayFieldValue(TF_SERVER_MIN_POOL);
String svrMaxPool = (String) getDisplayFieldValue(TF_SERVER_MAX_POOL);
String bindDN = (String) getDisplayFieldValue(TF_SERVER_BIND_DN);
String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
ServerSiteModel model = (ServerSiteModel) getModel();
try {
ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
ServerConfigXML.ServerGroup smsServerGroup = xmlObj.getSMSServerGroup();
if (bAMSDKEnabled) {
String userMinPool = (String) getDisplayFieldValue(TF_USER_MIN_POOL);
String userMaxPool = (String) getDisplayFieldValue(TF_USER_MAX_POOL);
ServerConfigXML.ServerGroup defaultServerGroup = xmlObj.getDefaultServerGroup();
defaultServerGroup.minPool = Integer.parseInt(userMinPool);
defaultServerGroup.maxPool = Integer.parseInt(userMaxPool);
defaultServerGroup.dsBaseDN = ((String) getDisplayFieldValue(TF_USER_ROOTSUFFIX)).trim();
for (Iterator i = defaultServerGroup.dsUsers.iterator(); i.hasNext(); ) {
DirUserObject o = (DirUserObject) i.next();
if (o.type.equals("proxy")) {
o.dn = "cn=puser,ou=DSAME Users," + defaultServerGroup.dsBaseDN;
String pwd = (String) getDisplayFieldValue(TF_USER_PROXY_PWD);
if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
o.password = Crypt.encode(pwd);
}
} else if (o.type.equals("admin")) {
o.dn = "cn=dsameuser,ou=DSAME Users," + defaultServerGroup.dsBaseDN;
String pwd = (String) getDisplayFieldValue(TF_USER_ADMIN_PWD);
if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
o.password = Crypt.encode(pwd);
}
}
}
}
smsServerGroup.minPool = Integer.parseInt(svrMinPool);
smsServerGroup.maxPool = Integer.parseInt(svrMaxPool);
List userGroup = smsServerGroup.dsUsers;
ServerConfigXML.DirUserObject bind = (ServerConfigXML.DirUserObject) userGroup.iterator().next();
bind.dn = bindDN;
String bindPwd = (String) getDisplayFieldValue(TF_SERVER_BIND_PWD);
if (!bindPwd.equals(AMPropertySheetModel.passwordRandom)) {
bind.password = Crypt.encode(bindPwd);
}
model.setServerConfigXML(serverName, xmlObj.toXML());
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("serverconfig.updated"));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
} catch (NumberFormatException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("exception.thread.pool.no.integer"));
}
forwardTo();
}
use of com.sun.identity.common.configuration.ServerConfigXML.DirUserObject 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.DirUserObject in project OpenAM by OpenRock.
the class AMSetupServlet method getSMSPassword.
/**
* Gets clear password of SMS datastore
* @param ssg <code>ServerGroup</code> instance representing SMS
* or Configuration datastore.
* @return clear password
*/
private static String getSMSPassword(ServerGroup ssg) throws Exception {
DirUserObject sduo = (DirUserObject) ssg.dsUsers.get(0);
String epass = sduo.password;
return AccessController.doPrivileged(new DecodeAction(epass));
}
use of com.sun.identity.common.configuration.ServerConfigXML.DirUserObject in project OpenAM by OpenRock.
the class ServerConfigXMLViewBean method setConfigProperties.
private void setConfigProperties(String serverName, ServerSiteModel model) throws AMConsoleException {
if (!submitCycle) {
ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
ServerConfigXML.ServerGroup defaultServerGroup = xmlObj.getDefaultServerGroup();
ServerConfigXML.ServerGroup smsServerGroup = xmlObj.getSMSServerGroup();
propertySheetModel.setValue(TF_USER_MIN_POOL, Integer.toString(defaultServerGroup.minPool));
propertySheetModel.setValue(TF_USER_MAX_POOL, Integer.toString(defaultServerGroup.maxPool));
propertySheetModel.setValue(TF_SERVER_MIN_POOL, Integer.toString(smsServerGroup.minPool));
propertySheetModel.setValue(TF_SERVER_MAX_POOL, Integer.toString(smsServerGroup.maxPool));
List bindInfo = smsServerGroup.dsUsers;
if (!bindInfo.isEmpty()) {
ServerConfigXML.DirUserObject bind = (ServerConfigXML.DirUserObject) bindInfo.iterator().next();
propertySheetModel.setValue(TF_SERVER_BIND_DN, bind.dn);
propertySheetModel.setValue(TF_SERVER_BIND_PWD, AMPropertySheetModel.passwordRandom);
}
if (bAMSDKEnabled) {
propertySheetModel.setValue(TF_USER_ROOTSUFFIX, defaultServerGroup.dsBaseDN);
for (Iterator i = defaultServerGroup.dsUsers.iterator(); i.hasNext(); ) {
DirUserObject o = (DirUserObject) i.next();
if (o.type.equals("proxy")) {
propertySheetModel.setValue(TF_USER_PROXY_PWD, AMPropertySheetModel.passwordRandom);
} else if (o.type.equals("admin")) {
propertySheetModel.setValue(TF_USER_ADMIN_PWD, AMPropertySheetModel.passwordRandom);
}
}
}
populateUserTableModel(defaultServerGroup.hosts);
populateServerTableModel(smsServerGroup.hosts);
}
}
Aggregations