use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthPropertiesModelImpl method getAuthInstances.
public Set getAuthInstances() {
Set instances = null;
if (currentRealm != null) {
String[] param = { currentRealm };
logEvent("ATTEMPT_GET_AUTH_INSTANCE", param);
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
instances = mgr.getAuthenticationInstances();
logEvent("SUCCEED_GET_AUTH_INSTANCE", param);
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, strError };
logEvent("AUTH_CONFIG_EXCEPTION_GET_AUTH_INSTANCE", paramsEx);
debug.warning("AuthPropertiesModelImpl.getAuthInstances", e);
}
}
return (instances == null) ? Collections.EMPTY_SET : instances;
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthConfigurationModelImpl method initialize.
/**
* Initialize configuration entry information for the given realm
* and named configuration.
*
* @param realm name where configuration is locate.
* @param config name of entry.
*/
public void initialize(String realm, String config) {
verifyConfigurationService(realm);
try {
if (configData == null) {
String[] params = { realm, config };
logEvent("ATTEMPT_GET_AUTH_CONFIG_PROFILE", params);
configData = AMAuthConfigUtils.getNamedConfig(config, realm, getUserSSOToken());
logEvent("SUCCEED_GET_AUTH_CONFIG_PROFILE", params);
}
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, config, strError };
logEvent("SSO_EXCEPTION_GET_AUTH_CONFIG_PROFILE", paramsEx);
debug.warning("AuthConfigurationModelImpl.initialize", e);
configData = Collections.EMPTY_MAP;
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, config, strError };
logEvent("AUTH_CONFIGURATION_EXCEPTION_GET_AUTH_CONFIG_PROFILE", paramsEx);
debug.error("AuthConfigurationModelImpl.initialize", e);
configData = Collections.EMPTY_MAP;
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, config, strError };
logEvent("SMS_EXCEPTION_GET_AUTH_CONFIG_PROFILE", paramsEx);
debug.error("AuthConfigurationModelImpl.initialize", e);
configData = Collections.EMPTY_MAP;
}
if ((configData != null) && !configData.isEmpty() && (xmlValue == null)) {
Set tmp = (Set) configData.get(AUTH_CONFIG_ATTR);
if ((tmp != null) && (!tmp.isEmpty())) {
xmlValue = (String) tmp.iterator().next();
entryList = new ArrayList(AMAuthConfigUtils.xmlToAuthConfigurationEntry(xmlValue));
}
}
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthConfigurationModelImpl method deleteAuthConfiguration.
/**
* Deletes the named authentication configuration object.
*
* @param realm name where configuration is locate.
* @param names names of entries.
*/
public void deleteAuthConfiguration(String realm, Set names) throws AMConsoleException {
StringBuilder errorList = new StringBuilder();
String message = null;
for (Iterator i = names.iterator(); i.hasNext(); ) {
String config = (String) i.next();
message = null;
try {
AMAuthConfigUtils.removeNamedConfig(config, realm, getUserSSOToken());
} catch (AMConfigurationException e) {
debug.warning("failed to delete", e);
message = e.getMessage();
errorList.append(config);
} catch (SMSException e) {
debug.warning("failed to delete", e);
message = e.getMessage();
errorList.append(config);
} catch (SSOException e) {
debug.warning("failed to delete", e);
message = e.getMessage();
errorList.append(config);
}
if (message != null) {
if (errorList.length() > 0) {
errorList.append(", ");
}
}
}
if (errorList.length() > 0) {
String[] tmp = { errorList.toString(), message };
throw new AMConsoleException(MessageFormat.format(getLocalizedString("authentication.config.delete.failed"), (Object[]) tmp));
}
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class UpdateAuthConfigurationEntries 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 datafile = getStringOptionValue(IArgument.DATA_FILE);
List listEntries = rc.getOption(AuthOptions.AUTH_CONFIG_ENTRIES);
if ((datafile == null) && (listEntries == null)) {
throw new CLIException(getResourceString("authentication-set-auth-config-entries-missing-data"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
}
String[] params = { realm, configName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_AUTH_CONFIG_ENTRIES", params);
try {
List entries = parse(datafile, listEntries);
validateEntries(realm, adminSSOToken, entries, params);
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-set-auth-config-entries-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SET_AUTH_CONFIG_ENTRIES", params);
} catch (AMConfigurationException e) {
debugError("GetAuthConfigurationEntries.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_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_SET_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_SET_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 UpdateAuthConfigurationEntries method getInstanceNames.
private Set getInstanceNames(String realm, SSOToken adminSSOToken, String[] params) throws CLIException {
Set names = new HashSet();
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realm);
Set instances = mgr.getAuthenticationInstances();
for (Iterator i = instances.iterator(); i.hasNext(); ) {
AMAuthenticationInstance instance = (AMAuthenticationInstance) i.next();
names.add(instance.getName());
}
} catch (AMConfigurationException e) {
debugError("ListAuthInstances.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_AUTH_CONFIG_ENTRIES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
return names;
}
Aggregations