use of com.iplanet.services.util.XMLException in project OpenAM by OpenRock.
the class ServerGroup method process.
/**
* Not to be called. This is a method to be called by the parser to read the
* xml information.
*/
public void process(XMLParser parser, String name, Vector elems, Hashtable atts, String Pcdata) throws XMLException {
if (DSConfigMgr.debugger.messageEnabled()) {
DSConfigMgr.debugger.message("in ServerGroup.process()");
}
if (name.equals(DSConfigMgr.SERVERGROUP)) {
// get the group ID.
groupName = (String) atts.get(DSConfigMgr.NAME);
// Get the Servers
for (int i = 0; i < elems.size(); i++) {
Object obj = elems.elementAt(i);
if (DSConfigMgr.debugger.messageEnabled()) {
DSConfigMgr.debugger.message("Object of type:" + obj.getClass().getName());
}
if (obj instanceof Server) {
if (servers == null) {
if (DSConfigMgr.debugger.messageEnabled()) {
DSConfigMgr.debugger.message("Initializing servers list.");
}
servers = new ArrayList<Server>();
}
servers.add((Server) obj);
} else if (obj instanceof LDAPUser) {
if (users == null) {
users = new ArrayList();
}
users.add(obj);
} else if (obj instanceof GenericNode) {
// if it is generic node, its probably the base dn.
GenericNode x = (GenericNode) obj;
if (x._name.equals(DSConfigMgr.BASE_DN)) {
if (x._pcdata != null) {
if (DN.valueOf(x._pcdata).size() <= 0) {
throw new XMLException(DSConfigMgr.getString(IUMSConstants.DSCFG_INVALID_BASE_DN) + x._pcdata);
}
}
baseDN = DN.valueOf(x._pcdata).toString();
} else if (x._name.equals(DSConfigMgr.MISC_CONFIG)) {
String attrName = (String) x._atts.get(DSConfigMgr.NAME);
String attrValue = (String) x._atts.get(DSConfigMgr.VALUE);
if (name != null && name.length() > 0) {
if (miscConfig == null) {
miscConfig = new HashMap();
}
miscConfig.put(attrName, attrValue);
}
}
}
}
if (servers == null || baseDN == null) {
String errorMsg = null;
if (servers == null) {
errorMsg = "No server object found in the server group:" + groupName;
}
if (baseDN == null) {
errorMsg = "No base DN string defined in the server group:" + groupName;
}
throw new XMLException(errorMsg);
}
// Get the rest of the attributes
String maxConnPoolStr = System.getProperty("max_conn_pool");
if (maxConnPoolStr == null)
maxConnPoolStr = (String) atts.get(DSConfigMgr.MAX_CONN_POOL);
String minConnPoolStr = System.getProperty("min_conn_pool");
if (minConnPoolStr == null)
minConnPoolStr = (String) atts.get(DSConfigMgr.MIN_CONN_POOL);
try {
maxConnPool = Integer.parseInt(maxConnPoolStr);
} catch (NumberFormatException ex) {
maxConnPool = 10;
}
try {
minConnPool = Integer.parseInt(minConnPoolStr);
} catch (NumberFormatException ex) {
minConnPool = 1;
}
String ldapHeartbeatStr = System.getProperty(Constants.LDAP_HEARTBEAT);
if (ldapHeartbeatStr == null)
ldapHeartbeatStr = (String) atts.get(Constants.LDAP_HEARTBEAT);
try {
ldapHeartbeat = Integer.parseInt(ldapHeartbeatStr);
} catch (NumberFormatException ex) {
ldapHeartbeat = 10;
}
} else {
throw new XMLException(DSConfigMgr.getString(IUMSConstants.DSCFG_SERVERGROUP_NODE_EXPECTED));
}
// Put it in the list of groups.
parser.getGroupContainer().put(groupName, this);
}
use of com.iplanet.services.util.XMLException in project OpenAM by OpenRock.
the class BootstrapCreator method updateBootstrap.
public static void updateBootstrap() throws ConfigurationException {
try {
DSConfigMgrBase dsCfg = new DSConfigMgrBase();
dsCfg.parseServiceConfigXML();
instance.update(dsCfg);
} catch (XMLException e) {
throw new ConfigurationException(e.getMessage());
} catch (SMSException e) {
throw new ConfigurationException(e.getMessage());
} catch (SSOException e) {
throw new ConfigurationException(e.getMessage());
}
}
use of com.iplanet.services.util.XMLException in project OpenAM by OpenRock.
the class ServerConfigMgr method getServerConfigXMLDoc.
private void getServerConfigXMLDoc() throws Exception {
InputStream is = null;
try {
String strXML = ServerConfiguration.getServerConfigXML(ssoToken, SystemProperties.getServerInstanceName());
is = new ByteArrayInputStream(strXML.getBytes());
Document document = XMLUtils.getXMLDocument(is);
if (document == null) {
throw (new XMLException(i18n.getString("dscfg-error-reading-config-file") + "\n" + i18n.getString("dscfg-corrupted-serverconfig")));
}
root = XMLUtils.getRootNode(document, DSConfigMgr.ROOT);
if (root == null) {
throw new XMLException(i18n.getString("dscfg-unable-to-find-root-node") + "\n" + i18n.getString("dscfg-corrupted-serverconfig"));
}
defaultServerGroup = XMLUtils.getNamedChildNode(root, DSConfigMgr.SERVERGROUP, DSConfigMgr.NAME, DSConfigMgr.DEFAULT);
if (defaultServerGroup == null) {
throw new XMLException(i18n.getString("dscfg-unable-to-find-default-servergroup") + "\n" + i18n.getString("dscfg-corrupted-serverconfig"));
}
strXMLDeclarationHdr = getXMLDeclarationHeader(ssoToken, configFile);
} finally {
if (is != null) {
is.close();
}
}
}
use of com.iplanet.services.util.XMLException in project OpenAM by OpenRock.
the class ServerConfigMgr method setUserPassword.
private void setUserPassword(String userType, String password) throws Exception {
Node pwdNode = XMLUtils.getChildNode(getUserNode(userType), DSConfigMgr.AUTH_PASSWD);
if (pwdNode == null) {
throw (new XMLException(i18n.getString("dscfg-corrupted-serverconfig")));
}
// Encrypt the new password and store
String encPassword = (String) AccessController.doPrivileged(new EncodeAction(password));
NodeList textNodes = pwdNode.getChildNodes();
Node textNode = textNodes.item(0);
textNode.setNodeValue(encPassword);
// Delete the remaining text nodes
for (int i = 1; i < textNodes.getLength(); i++) {
pwdNode.removeChild(textNodes.item(i));
}
}
use of com.iplanet.services.util.XMLException in project OpenAM by OpenRock.
the class ServerConfigMgr method changePassword.
/**
* Checks and sets the password
*/
private void changePassword(String userType, String oldPassword, String newPassword) throws Exception {
String fileEncPassword = getUserPassword(userType);
String userDN = getUserDN(userType);
if ((fileEncPassword == null) || (fileEncPassword.length() == 0) || (userDN == null) || (userDN.length() == 0)) {
debug.error("Null password or user DN for user type: " + userType + " from file: " + configFile);
throw new XMLException(i18n.getString("dscfg-corrupted-serverconfig"));
}
// Verify old password
if (!oldPassword.equals(AccessController.doPrivileged(new DecodeAction(fileEncPassword)))) {
throw new Exception(i18n.getString("dscfg-old-passwd-donot-match"));
}
if (isAMSDKConfigured) {
// this is to check if updating of DS is required.
try {
new AuthContext(new AuthPrincipal(userDN), newPassword.toCharArray());
if (debug.messageEnabled()) {
debug.message("DN: " + userDN + " new password is already updated in the directory");
}
} catch (LoginException lee) {
try {
AuthContext ac = new AuthContext(new AuthPrincipal(userDN), oldPassword.toCharArray());
PersistentObject user = UMSObject.getObject(ac.getSSOToken(), new Guid(userDN));
if (debug.messageEnabled()) {
debug.message("For DN: " + userDN + " changing password in directory");
}
user.setAttribute(new Attr("userPassword", newPassword));
user.save();
} catch (LoginException le) {
if (debug.warningEnabled()) {
debug.warning("For DN: " + userDN + " new and old passwords donot match with directory");
}
throw new Exception(i18n.getString("dscfg-invalid-password") + "\n" + le.getMessage());
}
}
}
setUserPassword(userType, newPassword);
}
Aggregations