use of com.sun.identity.authentication.config.AMAuthenticationManager in project OpenAM by OpenRock.
the class AuthPropertiesModelImpl method createAuthInstance.
public void createAuthInstance(String name, String type) throws AMConsoleException {
String[] params = { currentRealm, name, type };
logEvent("ATTEMPT_CREATE_AUTH_INSTANCE", params);
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
AMAuthenticationSchema as = mgr.getAuthenticationSchema(type);
mgr.createAuthenticationInstance(name, type, as.getAttributeValues());
logEvent("SUCCEED_CREATE_AUTH_INSTANCE", params);
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, name, type, strError };
logEvent("AUTH_CONFIG_EXCEPTION_CREATE_AUTH_INSTANCE", paramsEx);
debug.warning("AuthPropertiesModelImpl.createAuthInstance ", e);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.authentication.config.AMAuthenticationManager in project OpenAM by OpenRock.
the class AuthPropertiesModelImpl method removeAuthInstance.
public void removeAuthInstance(Set names) throws AMConsoleException {
StringBuilder errorList = new StringBuilder();
String message = null;
try {
String[] params = new String[2];
params[0] = currentRealm;
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
for (Iterator i = names.iterator(); i.hasNext(); ) {
String instance = (String) i.next();
params[1] = instance;
logEvent("ATTEMPT_REMOVE_AUTH_INSTANCE", params);
try {
mgr.deleteAuthenticationInstance(instance);
logEvent("SUCCEED_REMOVE_AUTH_INSTANCE", params);
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, instance, strError };
logEvent("AUTH_CONFIG_EXCEPTION_REMOVE_AUTH_INSTANCE", paramsEx);
debug.warning("failed to delete", e);
message = e.getMessage();
if (errorList.length() > 0) {
errorList.append(", ");
}
errorList.append(instance);
}
}
} catch (AMConfigurationException ace) {
String strError = getErrorString(ace);
String[] paramsEx = { currentRealm, "*", strError };
logEvent("AUTH_CONFIG_EXCEPTION_REMOVE_AUTH_INSTANCE", paramsEx);
debug.error("cant delete auth instance: ", ace);
throw new AMConsoleException(strError);
}
if (errorList.length() > 0) {
String[] tmp = { errorList.toString(), message };
throw new AMConsoleException(MessageFormat.format(getLocalizedString("authentication.instance.delete.failed"), (Object[]) tmp));
}
}
use of com.sun.identity.authentication.config.AMAuthenticationManager in project OpenAM by OpenRock.
the class AuthPropertiesModelImpl method getAuthTypes.
public Map getAuthTypes() {
Map authAndLocalizedTypes = Collections.EMPTY_MAP;
try {
logEvent("ATTEMPT_GET_AUTH_TYPE", getServerInstanceForLogMsg());
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), "/");
Set types = mgr.getAuthenticationTypes();
authAndLocalizedTypes = new HashMap(types.size());
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
String authType = (String) iter.next();
AMAuthenticationSchema schema = mgr.getAuthenticationSchema(authType);
String svcName = schema.getServiceName();
String localizedName = (svcName != null && svcName.length() > 0) ? getLocalizedServiceName(svcName) : authType;
authAndLocalizedTypes.put(authType, localizedName);
}
logEvent("SUCCEED_GET_AUTH_TYPE", getServerInstanceForLogMsg());
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramEx = { strError };
logEvent("SMS_EXCEPTION_GET_AUTH_TYPE", paramEx);
debug.warning("AuthPropertiesModelImpl.getAuthTypes", e);
}
return authAndLocalizedTypes;
}
use of com.sun.identity.authentication.config.AMAuthenticationManager in project OpenAM by OpenRock.
the class AuthPropertiesModelImpl method setInstanceValues.
public void setInstanceValues(String instance, Map values) throws AMConsoleException {
String[] params = { currentRealm, instance };
logEvent("ATTEMPT_MODIFY_AUTH_INSTANCE_PROFILE", params);
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
AMAuthenticationInstance ai = mgr.getAuthenticationInstance(instance);
ai.setAttributeValues(values);
logEvent("SUCCEED_MODIFY_AUTH_INSTANCE_PROFILE", params);
} catch (AMConfigurationException e) {
debug.warning("AuthPropertiesModelImpl.setInstanceValues", e);
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, instance, strError };
logEvent("AUTH_CONFIGURATION_EXCEPTION_MODIFY_AUTH_INSTANCE_PROFILE", paramsEx);
throw new AMConsoleException(strError);
} catch (SMSException e) {
debug.warning("AuthPropertiesModelImpl.setInstanceValues", e);
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, instance, strError };
logEvent("SMS_EXCEPTION_MODIFY_AUTH_INSTANCE_PROFILE", paramsEx);
throw new AMConsoleException(strError);
} catch (SSOException e) {
debug.warning("AuthPropertiesModelImpl.setInstanceValues", e);
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, instance, strError };
logEvent("SSO_EXCEPTION_MODIFY_AUTH_INSTANCE_PROFILE", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.authentication.config.AMAuthenticationManager 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;
}
Aggregations