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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations