Search in sources :

Example 1 with GenericNode

use of com.iplanet.services.util.GenericNode in project OpenAM by OpenRock.

the class LDAPUser method process.

public void process(XMLParser parser, String name, Vector elems, Hashtable atts, String Pcdata) {
    if (DSConfigMgr.debugger.messageEnabled()) {
        DSConfigMgr.debugger.message("in LDAPUser.process()");
    }
    userID = (String) atts.get(DSConfigMgr.NAME);
    for (int i = 0; i < elems.size(); i++) {
        GenericNode genNode = (GenericNode) elems.elementAt(i);
        if (genNode._name.equals(DSConfigMgr.AUTH_ID)) {
            // Get the bind dn
            userName = genNode._pcdata;
        }
        // The auth type.
        String str = (String) atts.get(DSConfigMgr.AUTH_TYPE);
        if (str == null || str.equalsIgnoreCase(DSConfigMgr.VAL_AUTH_BASIC)) {
            userType = Type.AUTH_BASIC;
        } else if (str.equalsIgnoreCase(DSConfigMgr.VAL_AUTH_PROXY)) {
            userType = Type.AUTH_PROXY;
        } else if (str.equalsIgnoreCase(DSConfigMgr.VAL_AUTH_REBIND)) {
            userType = Type.AUTH_REBIND;
        } else if (str.equalsIgnoreCase(DSConfigMgr.VAL_AUTH_ADMIN)) {
            userType = Type.AUTH_ADMIN;
        } else {
            userType = Type.AUTH_ANONYMOUS;
        }
        // If this element is the password.
        if (genNode._name.equals(DSConfigMgr.AUTH_PASSWD)) {
            userPasswd = genNode._pcdata;
        }
    }
}
Also used : GenericNode(com.iplanet.services.util.GenericNode)

Example 2 with GenericNode

use of com.iplanet.services.util.GenericNode 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);
}
Also used : XMLException(com.iplanet.services.util.XMLException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GenericNode(com.iplanet.services.util.GenericNode)

Aggregations

GenericNode (com.iplanet.services.util.GenericNode)2 XMLException (com.iplanet.services.util.XMLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1