Search in sources :

Example 1 with ServerConfigXML

use of com.sun.identity.common.configuration.ServerConfigXML in project OpenAM by OpenRock.

the class ServerConfigXMLAddServerViewBean method handleButton1Request.

/**
     * Handles create server to server configuration XML request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    ServerSiteModel model = (ServerSiteModel) getModel();
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    String serverGroupType = (String) getPageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
    String name = (String) getDisplayFieldValue(TF_NAME);
    name = name.trim();
    String host = (String) getDisplayFieldValue(TF_HOST);
    host = host.trim();
    String port = (String) getDisplayFieldValue(TF_PORT);
    port = port.trim();
    String type = (String) getDisplayFieldValue(CHOICE_TYPE);
    if ((name.length() > 0) && (port.length() > 0) && (host.length() > 0)) {
        try {
            ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
            ServerConfigXML.ServerGroup serverGroup = (serverGroupType.equals(DSConfigMgr.DEFAULT)) ? xmlObj.getDefaultServerGroup() : xmlObj.getSMSServerGroup();
            serverGroup.addHost(name, host, port, type);
            model.setServerConfigXML(serverName, xmlObj.toXML());
            backTrail();
            ServerConfigXMLViewBean vb = (ServerConfigXMLViewBean) getViewBean(ServerConfigXMLViewBean.class);
            removePageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
            passPgSessionMap(vb);
            vb.forwardTo(getRequestContext());
        } catch (ConfigurationException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "serverconfig.create.server.missing.atributes");
        forwardTo();
    }
}
Also used : ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Example 2 with ServerConfigXML

use of com.sun.identity.common.configuration.ServerConfigXML 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 3 with ServerConfigXML

use of com.sun.identity.common.configuration.ServerConfigXML 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 4 with ServerConfigXML

use of com.sun.identity.common.configuration.ServerConfigXML in project OpenAM by OpenRock.

the class ServerSiteModelImpl method getServerConfigObject.

/**
     * Returns the server configuration XML object.
     *
     * @param serverName Name of server.
     * @return the server configuration XML object.
     * @throws AMConsoleException if server configuration XML object cannot be
     *         return.
     */
public ServerConfigXML getServerConfigObject(String serverName) throws AMConsoleException {
    String[] param = { serverName };
    logEvent("ATTEMPT_GET_SERVER_CONFIG_XML", param);
    ServerConfigXML xmlObject = null;
    try {
        String xml = ServerConfiguration.getServerConfigXML(getUserSSOToken(), serverName);
        xmlObject = new ServerConfigXML(xml);
        logEvent("SUCCEED_GET_SERVER_CONFIG_XML", param);
    } catch (SMSException e) {
        String[] params = { serverName, e.getMessage() };
        logEvent("SMS_EXCEPTION_GET_SERVER_CONFIG_XML", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] params = { serverName, e.getMessage() };
        logEvent("SSO_EXCEPTION_GET_SERVER_CONFIG_XML", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (Exception e) {
        String[] params = { serverName, e.getMessage() };
        logEvent("GENERIC_EXCEPTION_GET_SERVER_CONFIG_XML", params);
        throw new AMConsoleException(getErrorString(e));
    }
    return xmlObject;
}
Also used : SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SMSException(com.sun.identity.sm.SMSException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) IOException(java.io.IOException) UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SSOException(com.iplanet.sso.SSOException) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Example 5 with ServerConfigXML

use of com.sun.identity.common.configuration.ServerConfigXML in project OpenAM by OpenRock.

the class AMSetupServlet method getSMSServerGroup.

/**
     * Gets <code>ServerGroup</code> for SMS for specified server
     * @param sname servername of groupo to find.
     * @return <code>ServerGroup</code> instance
     */
private static ServerGroup getSMSServerGroup(String sname) throws Exception {
    String xml = ServerConfiguration.getServerConfigXML(adminToken, sname);
    ServerConfigXML scc = new ServerConfigXML(xml);
    return scc.getSMSServerGroup();
}
Also used : ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Aggregations

ServerConfigXML (com.sun.identity.common.configuration.ServerConfigXML)8 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)5 ServerSiteModel (com.sun.identity.console.service.model.ServerSiteModel)4 DirUserObject (com.sun.identity.common.configuration.ServerConfigXML.DirUserObject)3 Iterator (java.util.Iterator)3 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)2 CCActionTable (com.sun.web.ui.view.table.CCActionTable)2 List (java.util.List)2 SSOException (com.iplanet.sso.SSOException)1 SSOToken (com.iplanet.sso.SSOToken)1 ServerGroup (com.sun.identity.common.configuration.ServerConfigXML.ServerGroup)1 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)1 SMSException (com.sun.identity.sm.SMSException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1