use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class UpdateAuthInstance method handleRequest.
/**
* Handles request.
*
* @param rc Request Context.
* @throws CLIException if request cannot be processed.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
String realm = getStringOptionValue(IArgument.REALM_NAME);
String instanceName = getStringOptionValue(AuthOptions.AUTH_INSTANCE_NAME);
String datafile = getStringOptionValue(IArgument.DATA_FILE);
List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
if ((datafile == null) && (attrValues == null)) {
throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
}
Map<String, Set<String>> attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
attributeValues = processFileAttributes(attributeValues);
String[] params = { realm, instanceName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_UPDATE_AUTH_INSTANCE", params);
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realm);
AMAuthenticationInstance ai = mgr.getAuthenticationInstance(instanceName);
if (ai != null) {
ai.setAttributeValues(attributeValues);
getOutputWriter().printlnMessage(getResourceString("authentication-update-auth-instance-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_UPDATE_AUTH_INSTANCE", params);
} else {
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
throw new CLIException(getResourceString("authentication-update-auth-instance-not-found"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
} catch (AMConfigurationException e) {
debugError("UpdateAuthInstance.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
debugError("UpdateAuthInstance.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
debugError("UpdateAuthInstance.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthConfigViewBean method getTableData.
private List getTableData() throws ModelControlException {
List entryList = new ArrayList();
CCActionTable table = (CCActionTable) getChild(AUTH_ENTRY_TABLE);
table.restoreStateData();
int size = entryTableModel.getNumRows();
for (int i = 0; i < size; i++) {
entryTableModel.setRowIndex(i);
String module = (String) entryTableModel.getValue(MODULE_NAME);
String flag = (String) entryTableModel.getValue(CRITERIA);
String option = (String) entryTableModel.getValue(OPTION_FIELD);
try {
AuthConfigurationEntry ae = new AuthConfigurationEntry(module, flag, option);
entryList.add(ae);
} catch (AMConfigurationException e) {
debug.warning("AuthConfigViewBean.getTableData() " + "Couldn't create the auth configuration entry", e);
}
}
return entryList;
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthConfigViewBean method handleAddEntryButtonRequest.
/**
* Handles add auth instances request.
*
* @param event Request invocation event
*/
public void handleAddEntryButtonRequest(RequestInvocationEvent event) throws ModelControlException {
// get the current values from the table so we don't
// overwrite any changes already made by the user.
List currentEntries = getTableData();
// create a new entry, add it to the list, and generat the xml
// use the first entry from the available instances list as default
Iterator i = getInstanceNames().iterator();
String moduleName = (String) i.next();
try {
AuthConfigurationEntry ace = new AuthConfigurationEntry(moduleName, REQUIRED_FLAG, "");
currentEntries.add(ace);
acModel.setEntries(currentEntries);
setPageSessionAttribute(ENTRY_LIST, acModel.getXMLValue(getRealmName(), getConfigName()));
} catch (AMConfigurationException a) {
debug.warning("AuthConfigViewBean.handleAddEntryButtonRequest() " + "Adding new config entry failed", a);
}
cacheValues();
populateEntryTable();
forwardTo();
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class GetAuthConfigurationEntries method handleRequest.
/**
* Handles request.
*
* @param rc Request Context.
* @throws CLIException if request cannot be processed.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
String realm = getStringOptionValue(IArgument.REALM_NAME);
String configName = getStringOptionValue(AuthOptions.AUTH_CONFIG_NAME);
String[] params = { realm, configName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_AUTH_CONFIG_ENTRIES", params);
try {
Map configData = AMAuthConfigUtils.getNamedConfig(configName, realm, adminSSOToken);
IOutput outputWriter = getOutputWriter();
boolean hasData = false;
if ((configData != null) && !configData.isEmpty()) {
Set tmp = (Set) configData.get(AuthOptions.AUTH_CONFIG_ATTR);
if ((tmp != null) && !tmp.isEmpty()) {
hasData = true;
String xml = (String) tmp.iterator().next();
List entryList = new ArrayList(AMAuthConfigUtils.xmlToAuthConfigurationEntry(xml));
outputWriter.printlnMessage(getResourceString("authentication-get-auth-config-entries-succeeded"));
for (Iterator i = entryList.iterator(); i.hasNext(); ) {
AuthConfigurationEntry e = (AuthConfigurationEntry) i.next();
String options = e.getOptions();
if (options == null) {
options = "";
}
Object[] args = { e.getLoginModuleName(), e.getControlFlag(), options };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("authentication-get-auth-config-entries-entry"), args));
}
}
} else {
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", params);
throw new CLIException(getResourceString("authentication-get-auth-config-entries-not-found"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
if (!hasData) {
outputWriter.printlnMessage(getResourceString("authentication-get-auth-config-entries-no-values"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_GET_AUTH_CONFIG_ENTRIES", params);
} catch (AMConfigurationException e) {
debugError("GetAuthConfigurationEntries.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
debugError("GetAuthConfigurationEntries.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
debugError("GetAuthConfigurationEntries.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class CreateAuthConfiguration method handleRequest.
/**
* Handles request.
*
* @param rc Request Context.
* @throws CLIException if request cannot be processed.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
String realm = getStringOptionValue(IArgument.REALM_NAME);
String name = getStringOptionValue(AuthOptions.AUTH_CONFIG_NAME);
String[] params = { realm, name };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_AUTH_CONFIGURATION", params);
try {
AMAuthConfigUtils.createNamedConfig(name, 0, new HashMap(), realm, adminSSOToken);
getOutputWriter().printlnMessage(getResourceString("authentication-created-auth-configuration-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_CREATE_AUTH_CONFIGURATION", params);
} catch (AMConfigurationException e) {
debugError("CreateAuthConfiguration.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_AUTH_CONFIGURATION", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
debugError("CreateAuthConfiguration.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_AUTH_CONFIGURATION", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
debugError("CreateAuthConfiguration.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_AUTH_CONFIGURATION", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations