Search in sources :

Example 41 with SMSException

use of com.sun.identity.sm.SMSException 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 42 with SMSException

use of com.sun.identity.sm.SMSException 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 43 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class UpdateAuthConfigProperties method handleRequest.

@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    String configName = getStringOptionValue(AuthOptions.AUTH_CONFIG_NAME);
    String datafile = getStringOptionValue(IArgument.DATA_FILE);
    List<String> listValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
    if ((datafile == null) && (listValues == null)) {
        throw new CLIException(getResourceString("authentication-set-auth-config-props-missing-data"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
    }
    String[] params = { realm, configName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_AUTH_CONFIG_ENTRIES", params);
    Map<String, Set<String>> attributeValues = AttributeValues.parse(getCommandManager(), datafile, listValues);
    validateProperties(attributeValues);
    Map configData = new HashMap();
    configData.putAll(attributeValues);
    try {
        AMAuthConfigUtils.replaceNamedConfig(configName, 0, configData, realm, ssoToken);
        getOutputWriter().printlnMessage(getResourceString("authentication-set-auth-config-props-succeeded"));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SET_AUTH_CONFIG_ENTRIES", params);
    } catch (SMSException smse) {
        debugError("GetAuthConfigurationEntries.handleRequest", smse);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_AUTH_CONFIG_ENTRIES", params);
        throw new CLIException(smse, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException ssoe) {
        debugError("GetAuthConfigurationEntries.handleRequest", ssoe);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_AUTH_CONFIG_ENTRIES", params);
        throw new CLIException(ssoe, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (AMConfigurationException amce) {
        debugError("GetAuthConfigurationEntries.handleRequest", amce);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_AUTH_CONFIG_ENTRIES", params);
        throw new CLIException(amce, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) CLIException(com.sun.identity.cli.CLIException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 44 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class FSSAMLServiceModelImpl method setAttributeValues.

/**
     * Set SAMLv1.x attribute values.
     *
     * @param values Attribute values. Map of attribute name to set of values.
     * @throws AMConsoleException if values cannot be set.
     */
public void setAttributeValues(Map values) throws AMConsoleException {
    String[] params = new String[3];
    params[0] = SAML_SERVICE_NAME;
    params[1] = "-";
    String curAttrSchemaName = "";
    try {
        for (Iterator iter = values.entrySet().iterator(); iter.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iter.next();
            String name = (String) entry.getKey();
            curAttrSchemaName = name;
            params[2] = name;
            logEvent("ATTEMPT_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
            AttributeSchema as = (AttributeSchema) attributeSchemas.get(name);
            as.setDefaultValues((Set) entry.getValue());
            logEvent("SUCCEED_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
        }
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { SAML_SERVICE_NAME, "-", curAttrSchemaName, strError };
        logEvent("SSO_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { SAML_SERVICE_NAME, "-", curAttrSchemaName, strError };
        logEvent("SMS_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 45 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class FSSAMLServiceModelImpl method modifyTrustPartners.

/*
     * modify trusted partners.
     *
     * @param values a Set of trusted partners .
     * @throws AMConsoleException if name cannot be set.
     */
public void modifyTrustPartners(Set values) throws AMConsoleException {
    String curAttrSchemaName = SAML_TRUSTED_PARTNERS;
    String[] params = new String[5];
    params[0] = SAML_SERVICE_NAME;
    params[1] = "-";
    params[2] = curAttrSchemaName;
    params[3] = "-";
    params[4] = values.toString();
    try {
        AttributeSchema as = (AttributeSchema) attributeSchemas.get(curAttrSchemaName);
        as.setDefaultValues(values);
        logEvent("SUCCEED_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { SAML_SERVICE_NAME, "-", curAttrSchemaName, strError };
        logEvent("SSO_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { SAML_SERVICE_NAME, "-", curAttrSchemaName, strError };
        logEvent("SMS_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

SMSException (com.sun.identity.sm.SMSException)704 SSOException (com.iplanet.sso.SSOException)525 Set (java.util.Set)272 HashSet (java.util.HashSet)200 SSOToken (com.iplanet.sso.SSOToken)185 Map (java.util.Map)166 ServiceConfig (com.sun.identity.sm.ServiceConfig)164 HashMap (java.util.HashMap)158 CLIException (com.sun.identity.cli.CLIException)149 ServiceSchema (com.sun.identity.sm.ServiceSchema)138 Iterator (java.util.Iterator)133 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)104 IOutput (com.sun.identity.cli.IOutput)96 IdRepoException (com.sun.identity.idm.IdRepoException)86 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)83 AttributeSchema (com.sun.identity.sm.AttributeSchema)66 IOException (java.io.IOException)55 List (java.util.List)51