Search in sources :

Example 1 with DirUserObject

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();
}
Also used : DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) Iterator(java.util.Iterator) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Example 2 with DirUserObject

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);
    }
}
Also used : DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) ServerGroup(com.sun.identity.common.configuration.ServerConfigXML.ServerGroup) HashMap(java.util.HashMap) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Example 3 with DirUserObject

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));
}
Also used : DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) DecodeAction(com.sun.identity.security.DecodeAction)

Example 4 with DirUserObject

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);
    }
}
Also used : DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) Iterator(java.util.Iterator) List(java.util.List) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Aggregations

DirUserObject (com.sun.identity.common.configuration.ServerConfigXML.DirUserObject)4 ServerConfigXML (com.sun.identity.common.configuration.ServerConfigXML)3 Iterator (java.util.Iterator)3 List (java.util.List)2 SSOToken (com.iplanet.sso.SSOToken)1 ServerGroup (com.sun.identity.common.configuration.ServerConfigXML.ServerGroup)1 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 ServerSiteModel (com.sun.identity.console.service.model.ServerSiteModel)1 DecodeAction (com.sun.identity.security.DecodeAction)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1