Search in sources :

Example 51 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class BulkFederation method handleIDFFRequest.

private void handleIDFFRequest(BufferedWriter out) throws CLIException {
    Map userIdMapping = getUserIdMapping(userIdMappingFileName);
    for (Iterator i = userIdMapping.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry e = (Map.Entry) i.next();
        String localUserId = (String) e.getKey();
        String remoteUserId = (String) e.getValue();
        idffFederateUser(localUserId, remoteUserId, out);
    }
    IOutput outputWriter = getOutputWriter();
    outputWriter.printlnMessage(getResourceString("bulk-federation-succeeded"));
}
Also used : IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 52 with IOutput

use of com.sun.identity.cli.IOutput 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)

Example 53 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class SetSiteFailoverURLs 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_SET_SITE_FAILOVER_URLS", params);
        if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
            SiteConfiguration.setSiteSecondaryURLs(adminSSOToken, siteName, secondaryURLs);
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-site-secondary-urls-succeeded"), (Object[]) params));
        } else {
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-site-secondary-urls-no-exists"), (Object[]) params));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_SITE_FAILOVER_URLS", params);
    } catch (SSOException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("SetSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ConfigurationException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("SetSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("SetSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_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 54 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class ListSites 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();
    try {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_SITES", null);
        Set sites = SiteConfiguration.getSites(adminSSOToken);
        if ((sites != null) && !sites.isEmpty()) {
            for (Iterator i = sites.iterator(); i.hasNext(); ) {
                outputWriter.printlnMessage((String) i.next());
            }
        } else {
            outputWriter.printlnMessage(getResourceString("list-sites-no-instances"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_LIST_SITES", null);
    } catch (SSOException e) {
        String[] args = { e.getMessage() };
        debugError("ListSites.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_SITES", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { e.getMessage() };
        debugError("ListSites.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_SITES", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) 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 55 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class RemoveServerConfig 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 serverName = getStringOptionValue(IArgument.SERVER_NAME);
    List propertyNames = rc.getOption(IArgument.PROPERTY_NAMES);
    try {
        String[] params = { serverName };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_REMOVE_SERVER_CONFIG", params);
        if (serverName.equals(DEFAULT_SVR_CONFIG)) {
            ServerConfiguration.removeServerConfiguration(adminSSOToken, ServerConfiguration.DEFAULT_SERVER_CONFIG, propertyNames);
        } else {
            if (ServerConfiguration.isServerInstanceExist(adminSSOToken, serverName)) {
                ServerConfiguration.removeServerConfiguration(adminSSOToken, serverName, propertyNames);
                outputWriter.printlnMessage(MessageFormat.format(getResourceString("remove-server-config-succeeded"), (Object[]) params));
            } else {
                outputWriter.printlnMessage(MessageFormat.format(getResourceString("remove-server-config-does-not-exists"), (Object[]) params));
            }
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_REMOVE_SERVER_CONFIG", params);
    } catch (IOException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("RemoveServerConfig.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SERVER_CONFIG", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("RemoveServerConfig.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SERVER_CONFIG", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("RemoveServerConfig.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SERVER_CONFIG", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) 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) IOException(java.io.IOException)

Aggregations

IOutput (com.sun.identity.cli.IOutput)152 CLIException (com.sun.identity.cli.CLIException)137 SSOException (com.iplanet.sso.SSOException)123 SSOToken (com.iplanet.sso.SSOToken)99 SMSException (com.sun.identity.sm.SMSException)98 Set (java.util.Set)61 Iterator (java.util.Iterator)53 IdRepoException (com.sun.identity.idm.IdRepoException)45 List (java.util.List)45 AMIdentity (com.sun.identity.idm.AMIdentity)42 Map (java.util.Map)35 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)26 ServiceSchema (com.sun.identity.sm.ServiceSchema)26 IdType (com.sun.identity.idm.IdType)19 IOException (java.io.IOException)18 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)17 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)15 HashMap (java.util.HashMap)15 HashSet (java.util.HashSet)15 AttributeSchema (com.sun.identity.sm.AttributeSchema)14