use of com.sun.identity.authentication.config.AMAuthenticationManager in project OpenAM by OpenRock.
the class AuthenticationModuleCollectionHandler method getSchemaManager.
private ServiceSchemaManager getSchemaManager(String authType) throws SSOException, SMSException, AMConfigurationException {
AMAuthenticationManager authenticationManager = new AMAuthenticationManager(adminToken, "/");
AMAuthenticationSchema schema = authenticationManager.getAuthenticationSchema(authType);
return new ServiceSchemaManager(schema.getServiceName(), adminToken);
}
use of com.sun.identity.authentication.config.AMAuthenticationManager 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;
}
use of com.sun.identity.authentication.config.AMAuthenticationManager 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.AMAuthenticationManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getAuthenticationLevel.
/**
* Returns authentication level of an authentication instance.
*
* @param realmName Name of realm.
* @param name Authentication Instance name.
* @return authentication level of an authentication instance.
*/
public String getAuthenticationLevel(String realmName, String name) {
String level = "0";
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realmName);
AMAuthenticationInstance ai = mgr.getAuthenticationInstance(name);
Map map = ai.getAttributeValues();
String authType = ai.getType();
Set set = (Set) map.get(AMAuthConfigUtils.getAuthLevelAttribute(map, authType));
if ((set != null) && !set.isEmpty()) {
level = (String) set.iterator().next();
}
} catch (AMConfigurationException e) {
debug.warning("PolicyModelImpl.getInstanceValues", e);
}
return level;
}
use of com.sun.identity.authentication.config.AMAuthenticationManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getAuthInstances.
/**
* Returns authentication instances configured for the realm.
*
* @param realmName Name of realm.
* @return authentication instances configured for the realm.
*/
public Set getAuthInstances(String realmName) {
Set instances = null;
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realmName);
Set inst = mgr.getAuthenticationInstances();
if ((inst != null) && !inst.isEmpty()) {
instances = new HashSet(inst.size() * 2);
for (Iterator iter = inst.iterator(); iter.hasNext(); ) {
AMAuthenticationInstance i = (AMAuthenticationInstance) iter.next();
instances.add(i.getName());
}
}
} catch (AMConfigurationException e) {
debug.warning("PolicyModelImpl.getAuthInstances", e);
}
return (instances == null) ? Collections.EMPTY_SET : instances;
}
Aggregations