Search in sources :

Example 6 with ConfigurationException

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

the class AddSiteFailoverURLs method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String siteName = getStringOptionValue(IArgument.SITE_NAME);
    List secondaryURLs = (List) rc.getOption(IArgument.SECONDARY_URLS);
    String[] params = { siteName };
    try {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SITE_FAILOVER_URLS", params);
        if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
            SiteConfiguration.addSiteSecondaryURLs(adminSSOToken, siteName, secondaryURLs);
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-site-secondary-urls-succeeded"), (Object[]) params));
        } else {
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-site-secondary-urls-no-exists"), (Object[]) params));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SITE_FAILOVER_URLS", params);
    } catch (SSOException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ConfigurationException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException)

Example 7 with ConfigurationException

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

the class AddSiteMembers method handleRequest.

/**
     * Adds members to a site.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String siteName = getStringOptionValue(IArgument.SITE_NAME);
    List serverNames = (List) rc.getOption(IArgument.SERVER_NAMES);
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { siteName };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SITE_MEMBERS", params);
        if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
            SiteConfiguration.addServersToSite(adminSSOToken, siteName, serverNames);
            outputWriter.printlnMessage(getResourceString("add-site-members-succeeded"));
        } else {
            outputWriter.printlnMessage(getResourceString("add-site-members-site-not-exist"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SITE_MEMBERS", params);
    } catch (ConfigurationException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException)

Example 8 with ConfigurationException

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

the class AddAgentsToGroup method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    String agentGroupName = getStringOptionValue(IArgument.AGENT_GROUP_NAME);
    List agentNames = rc.getOption(IArgument.AGENT_NAMES);
    String[] params = { realm, agentGroupName, "" };
    String agentName = "";
    try {
        AMIdentity amidGroup = new AMIdentity(adminSSOToken, agentGroupName, IdType.AGENTGROUP, realm, null);
        for (Iterator i = agentNames.iterator(); i.hasNext(); ) {
            agentName = (String) i.next();
            params[2] = agentName;
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_AGENT_TO_GROUP", params);
            AMIdentity amid = new AMIdentity(adminSSOToken, agentName, IdType.AGENTONLY, realm, null);
            AgentConfiguration.AddAgentToGroup(amidGroup, amid);
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_AGENT_TO_GROUP", params);
        }
        if (agentNames.size() > 1) {
            outputWriter.printlnMessage(getResourceString("add-agent-to-group-succeeded-pural"));
        } else {
            outputWriter.printlnMessage(getResourceString("add-agent-to-group-succeeded"));
        }
    } catch (IdRepoException e) {
        String[] args = { realm, agentGroupName, agentName, e.getMessage() };
        debugError("AddAgentsToGroup.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AGENT_TO_GROUP", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ConfigurationException e) {
        String[] args = { realm, agentGroupName, agentName, e.getMessage() };
        debugError("AddAgentsToGroup.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AGENT_TO_GROUP", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { realm, agentGroupName, agentName, e.getMessage() };
        debugError("AddAgentsToGroup.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AGENT_TO_GROUP", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) IOutput(com.sun.identity.cli.IOutput) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException)

Example 9 with ConfigurationException

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

the class ShowSiteMembers method handleRequest.

/**
     * Display members of a site.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String siteName = getStringOptionValue(IArgument.SITE_NAME);
    String[] params = { siteName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_SITE_MEMBERS", params);
    IOutput outputWriter = getOutputWriter();
    try {
        Set members = SiteConfiguration.listServers(adminSSOToken, siteName);
        if ((members != null) && !members.isEmpty()) {
            for (Iterator i = members.iterator(); i.hasNext(); ) {
                outputWriter.printlnMessage((String) i.next());
            }
        } else {
            outputWriter.printlnMessage(getResourceString("show-site-members-no-members"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SHOW_SITE_MEMBERS", params);
    } catch (ConfigurationException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("ShowSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SHOW_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("ShowSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SHOW_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("ShowSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SHOW_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 10 with ConfigurationException

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

the class SetServerConfigXML method handleRequest.

/**
     * Set Server Configuration XML.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String serverName = getStringOptionValue(IArgument.SERVER_NAME);
    String xmlFile = getStringOptionValue(IArgument.XML_FILE);
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serverName };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_SERVER_CONFIG_XML", params);
        String xml = xmlFile;
        boolean isWebEnabled = getCommandManager().webEnabled();
        if (!isWebEnabled) {
            xml = CLIUtil.getFileContent(getCommandManager(), xmlFile);
        }
        ServerConfiguration.setServerConfigXML(adminSSOToken, serverName, xml);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-serverconfig-xml-succeeded"), (Object[]) params));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_SERVER_CONFIG_XML", params);
    } catch (SSOException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("SetServerConfigXML.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVER_CONFIG_XML", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ConfigurationException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("SetServerConfigXML.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVER_CONFIG_XML", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("SetServerConfigXML.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVER_CONFIG_XML", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Aggregations

ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)48 SSOException (com.iplanet.sso.SSOException)40 SMSException (com.sun.identity.sm.SMSException)39 SSOToken (com.iplanet.sso.SSOToken)30 CLIException (com.sun.identity.cli.CLIException)19 IOutput (com.sun.identity.cli.IOutput)17 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)14 List (java.util.List)12 IdRepoException (com.sun.identity.idm.IdRepoException)11 IOException (java.io.IOException)11 Map (java.util.Map)10 Set (java.util.Set)9 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)6 HashSet (java.util.HashSet)6 Iterator (java.util.Iterator)6 NotFoundException (org.forgerock.json.resource.NotFoundException)6 AMIdentity (com.sun.identity.idm.AMIdentity)5 MalformedURLException (java.net.MalformedURLException)5 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)5 HashMap (java.util.HashMap)4