Search in sources :

Example 76 with IOutput

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

the class ListEntities method handleIDFFRequest.

private void handleIDFFRequest(RequestContext rc) throws CLIException {
    IOutput outputWriter = getOutputWriter();
    Object[] objs = { realm };
    try {
        IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
        Set entities = metaManager.getAllEntities(realm);
        if ((entities == null) || entities.isEmpty()) {
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-entities-no-entities"), objs));
        } else {
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-entities-entity-listing"), objs));
            for (Iterator i = entities.iterator(); i.hasNext(); ) {
                String name = (String) i.next();
                outputWriter.printlnMessage("  " + name);
            }
        }
    } catch (IDFFMetaException e) {
        debugWarning("ListEntities.handleIDFFRequest", e);
        String[] args = { realm, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_ENTITIES", args);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : Set(java.util.Set) IOutput(com.sun.identity.cli.IOutput) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException)

Example 77 with IOutput

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

the class AddPluginSchema 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();
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String interfaceName = getStringOptionValue(ARGUMENT_INTERFACE_NAME);
    String pluginName = getStringOptionValue(ARGUMENT_PLUGIN_NAME);
    String i18nKey = getStringOptionValue(ARGUMENT_I18N_KEY);
    String i18nName = getStringOptionValue(ARGUMENT_I18N_NAME);
    String className = getStringOptionValue(ARGUMENT_CLASS_NAME);
    ServiceManager sm = null;
    try {
        sm = new ServiceManager(adminSSOToken);
    } catch (SMSException smse) {
        throw new CLIException(smse, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException ssoe) {
        throw new CLIException(ssoe, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, interfaceName, pluginName, i18nKey, i18nName, className };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_PLUGIN_SCHEMA", params);
        Document pluginDoc = createPluginSchemaXML(serviceName, interfaceName, pluginName, i18nKey, i18nName, className);
        if (pluginDoc != null) {
            sm.addPluginSchema(pluginDoc);
            String[] params2 = { serviceName, pluginName };
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_PLUGIN_SCHEMA", params2);
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-succeed"), (Object[]) params));
        } else {
            String[] args = { serviceName, pluginName, "Null XML Document" };
            debugError("AddPluginSchema.handleRequest:: Null XML Document");
            writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
            throw new CLIException("Null XML Document", ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
    } catch (SSOException ssoe) {
        String[] args = { serviceName, pluginName, ssoe.getMessage() };
        debugError("AddPluginSchema.handleRequest", ssoe);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-failed"), (Object[]) args));
        throw new CLIException(ssoe, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException smse) {
        String[] args = { serviceName, pluginName, smse.getMessage() };
        debugError("AddPluginSchema.handleRequest", smse);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-failed"), (Object[]) args));
        throw new CLIException(smse, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) ServiceManager(com.sun.identity.sm.ServiceManager) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) Document(org.w3c.dom.Document)

Example 78 with IOutput

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

the class GetAttributeSchemaChoiceValues method handleRequest.

@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeName = getStringOptionValue(IArgument.ATTRIBUTE_NAME);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    String[] params = { serviceName, schemaType, subSchemaName, attributeName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
    AttributeSchema attrSchema = ss.getAttributeSchema(attributeName);
    if (attrSchema == null) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeName, "attribute schema does not exist" };
        attributeSchemaNoExist(attributeName, "FAILED_GET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", args);
    }
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
    getOutputWriter().printlnMessage(FormatUtils.formatMap(getResourceString("attribute-schema-i18nkey"), getResourceString("attribute-schema-choice-value"), getChoiceValues(attrSchema)));
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema)

Example 79 with IOutput

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

the class GetSubConfiguration method printGlobalSubConfig.

private void printGlobalSubConfig(String serviceName, String subConfigName) throws CLIException {
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String[] params = { subConfigName, serviceName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_SUB_CONFIGURATION", params);
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
        ServiceConfig sc = scm.getGlobalConfig(null);
        printSubConfig(sc, subConfigName);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_SUB_CONFIGURATION", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("get-sub-configuration-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { subConfigName, serviceName, e.getMessage() };
        debugError("GetSubConfiguration.printGlobalSubConfig", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_SUB_CONFIGURATION", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { subConfigName, serviceName, e.getMessage() };
        debugError("GetSubConfiguration.printGlobalSubConfig", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_SUB_CONFIGURATION", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 80 with IOutput

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

the class ShowApplicationType method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    String appTypeName = getStringOptionValue(PARAM_APPL_TYPE_NAME);
    String[] params = { appTypeName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_APPLICATION_TYPE", params);
    ApplicationType applType = ApplicationTypeManager.getAppplicationType(getAdminSubject(), appTypeName);
    IOutput writer = getOutputWriter();
    if (applType == null) {
        Object[] param = { appTypeName };
        writer.printlnMessage(MessageFormat.format(getResourceString("show-application-type-not-found"), param));
    } else {
        displayAttrs(writer, applType);
    }
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SHOW_APPLICATION_TYPE", params);
}
Also used : ApplicationType(com.sun.identity.entitlement.ApplicationType) IOutput(com.sun.identity.cli.IOutput)

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