use of com.sun.identity.authentication.config.AuthConfigurationEntry in project OpenAM by OpenRock.
the class AddAuthConfigurationEntry 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 moduleName = getStringOptionValue(AuthOptions.AUTH_CONFIG_MODULE_NAME);
String criteria = getStringOptionValue(AuthOptions.AUTH_CONFIG_CRITERIA);
String options = getStringOptionValue(AuthOptions.AUTH_CONFIG_OPTIONS);
String[] params = { realm, configName, moduleName };
if (!POSSIBLE_CRITERIA.contains(criteria)) {
throw new CLIException(getResourceString("authentication-add-auth-config-entry-criteria.invalid"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
int pos = getPosition();
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_AUTH_CONFIG_ENTRY", params);
try {
AuthConfigurationEntry ae = new AuthConfigurationEntry(moduleName, criteria, options);
Set instanceNames = getInstanceNames(realm, adminSSOToken);
String instanceName = ae.getLoginModuleName();
if (!instanceNames.contains(instanceName)) {
Object[] p = { instanceName };
throw new CLIException(MessageFormat.format(getResourceString("authentication-add-auth-config-entry-not-found"), p), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
List entries = getConfigEntries(realm, configName, adminSSOToken);
if (entries == null) {
entries = new ArrayList();
}
if ((pos == -1) || (pos >= entries.size())) {
entries.add(ae);
} else {
entries.add(pos, ae);
}
Map configData = new HashMap(2);
Set tmp = new HashSet(2);
String xml = AMAuthConfigUtils.authConfigurationEntryToXMLString(entries);
tmp.add(xml);
configData.put(AuthOptions.AUTH_CONFIG_ATTR, tmp);
IOutput outputWriter = getOutputWriter();
AMAuthConfigUtils.replaceNamedConfig(configName, 0, configData, realm, adminSSOToken);
outputWriter.printlnMessage(getResourceString("authentication-add-auth-config-entry-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_ADD_AUTH_CONFIG_ENTRY", params);
} catch (AMConfigurationException e) {
debugError("GetAuthConfigurationEntries.handleRequest", e);
String[] p = { realm, configName, moduleName, e.getMessage() };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AUTH_CONFIG_ENTRY", p);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
debugError("GetAuthConfigurationEntries.handleRequest", e);
String[] p = { realm, configName, moduleName, e.getMessage() };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AUTH_CONFIG_ENTRY", p);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
debugError("GetAuthConfigurationEntries.handleRequest", e);
String[] p = { realm, configName, moduleName, e.getMessage() };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AUTH_CONFIG_ENTRY", p);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.authentication.config.AuthConfigurationEntry in project OpenAM by OpenRock.
the class UpdateAuthConfigurationEntries method validateEntries.
private void validateEntries(String realm, SSOToken adminSSOToken, List entries, String[] params) throws CLIException {
if ((entries != null) && !entries.isEmpty()) {
Set instanceNames = getInstanceNames(realm, adminSSOToken, params);
for (Iterator i = entries.iterator(); i.hasNext(); ) {
AuthConfigurationEntry token = (AuthConfigurationEntry) i.next();
String instanceName = token.getLoginModuleName();
if (!instanceNames.contains(instanceName)) {
Object[] p = { instanceName };
throw new CLIException(MessageFormat.format(getResourceString("authentication-set-auth-config-entries-instance-not-found"), p), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
}
}
use of com.sun.identity.authentication.config.AuthConfigurationEntry in project OpenAM by OpenRock.
the class ReorderAuthChainsViewBean method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
CCOrderableList list = (CCOrderableList) getChild(REORDER_LIST);
CCOrderableListModel model = (CCOrderableListModel) list.getModel();
String xml = (String) getPageSessionAttribute(AuthConfigViewBean.ENTRY_LIST);
List chains = new ArrayList(AMAuthConfigUtils.xmlToAuthConfigurationEntry(xml));
OptionList optList = new OptionList();
int sz = chains.size();
for (int i = 0; i < sz; i++) {
AuthConfigurationEntry entry = (AuthConfigurationEntry) chains.get(i);
String name = entry.getLoginModuleName();
String flag = entry.getControlFlag();
String options = entry.getOptions();
String displayName = name + " - " + flag;
if ((options != null) && (options.trim().length() > 0)) {
displayName += " - " + options;
}
optList.add(displayName, Integer.toString(i));
}
model.setSelectedOptionList(optList);
}
use of com.sun.identity.authentication.config.AuthConfigurationEntry in project OpenAM by OpenRock.
the class AuthConfigurationModelImpl method getModuleName.
/**
* Gets the module name for the given module index in the current
* authentication configuration attributes
*
* @param idx the index of the module to retrieve name from.
* @return the module name
*/
public String getModuleName(int idx) {
String name = null;
AuthConfigurationEntry entry = (AuthConfigurationEntry) entryList.get(idx);
if (entry != null) {
name = entry.getLoginModuleName();
}
return name;
}
use of com.sun.identity.authentication.config.AuthConfigurationEntry in project OpenAM by OpenRock.
the class AuthConfigurationModelImpl method getModuleOptions.
/**
* Gets the module options string for the given module index in the
* current authentication configuration attributes
*
* @param idx the index of the module to retrieve Flag from.
* @return the module options string
*/
public String getModuleOptions(int idx) {
String options = null;
AuthConfigurationEntry entry = (AuthConfigurationEntry) entryList.get(idx);
if (entry != null) {
options = entry.getOptions();
}
return options;
}
Aggregations