use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ConfigMonitoring method getAgents.
private void getAgents(String realm) {
String classMethod = "ConfigMonitoring.getAgents: ";
StringBuffer sb = new StringBuffer(classMethod);
try {
IdSearchControl isc = new IdSearchControl();
isc.setMaxResults(0);
// should use set value, but for now...
isc.setTimeOut(3000);
isc.setAllReturnAttributes(false);
AMIdentityRepository airepo = new AMIdentityRepository(ssoToken, realm);
IdSearchResults isr = airepo.searchIdentities(IdType.AGENT, "*", isc);
// set of AMIdentitys
Set results = isr.getSearchResults();
sb = new StringBuffer("Agents for realm ");
sb.append(realm).append("; size = ").append(results.size()).append(":\n");
for (Iterator it = results.iterator(); it.hasNext(); ) {
AMIdentity aid = (AMIdentity) it.next();
processAgentIdentity(aid, sb);
}
debug.error(classMethod + sb.toString());
} catch (IdRepoException e) {
debug.error(classMethod + "idrepo error getting agents: " + e.getMessage());
} catch (SSOException e) {
debug.error(classMethod + "sso error getting agents: " + e.getMessage());
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ConfigMonitoring method getSupportedEntityTypes.
private Set getSupportedEntityTypes(String realm) {
String classMethod = "ConfigMonitoring.getSupportedEntityTypes: ";
Set supportedTypes = Collections.EMPTY_SET;
try {
AMIdentityRepository repo = new AMIdentityRepository(ssoToken, realm);
supportedTypes = repo.getSupportedIdTypes();
} catch (IdRepoException e) {
debug.error(classMethod + "idrepo exception getting supported entity types; " + e.getMessage());
} catch (SSOException e) {
debug.error(classMethod + "sso exception getting supported entity types; " + e.getMessage());
}
return supportedTypes;
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class DeleteAgents method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
String realm = getStringOptionValue(IArgument.REALM_NAME);
List agentNames = (List) rc.getOption(IArgument.AGENT_NAMES);
String file = getStringOptionValue(IArgument.FILE);
if (agentNames == null) {
agentNames = new ArrayList();
}
if (file != null) {
agentNames.addAll(AttributeValues.parseValues(file));
}
if (agentNames.isEmpty()) {
throw new CLIException(getResourceString("missing-agent-names"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
String displayableNames = tokenize(agentNames);
String[] params = { realm, displayableNames };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_AGENTS", params);
try {
AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
Set setDelete = new HashSet();
for (Iterator i = agentNames.iterator(); i.hasNext(); ) {
String name = (String) i.next();
AMIdentity amid = new AMIdentity(adminSSOToken, name, IdType.AGENTONLY, realm, null);
setDelete.add(amid);
}
amir.deleteIdentities(setDelete);
IOutput outputWriter = getOutputWriter();
outputWriter.printlnMessage(getResourceString("delete-agent-succeeded"));
for (Iterator i = agentNames.iterator(); i.hasNext(); ) {
outputWriter.printlnMessage(" " + (String) i.next());
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_DELETE_AGENTS", params);
} catch (IdRepoException e) {
String[] args = { realm, displayableNames, e.getMessage() };
debugError("DeleteAgents.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_AGENTS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, displayableNames, e.getMessage() };
debugError("DeleteAgents.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_AGENTS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ListAgents method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String realm = getStringOptionValue(IArgument.REALM_NAME);
String patternType = getStringOptionValue(IArgument.AGENT_TYPE);
String filter = getStringOptionValue(IArgument.FILTER);
if (patternType == null) {
patternType = "";
}
if ((filter == null) || (filter.length() == 0)) {
filter = "*";
}
String[] params = { realm, patternType, filter };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_AGENTS", params);
try {
AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
IdSearchResults isr = amir.searchIdentities(IdType.AGENTONLY, filter, new IdSearchControl());
Set results = isr.getSearchResults();
if ((results != null) && !results.isEmpty()) {
for (Iterator i = results.iterator(); i.hasNext(); ) {
AMIdentity amid = (AMIdentity) i.next();
if (!matchType(amid, patternType)) {
i.remove();
}
}
}
if ((results != null) && !results.isEmpty()) {
for (Iterator i = results.iterator(); i.hasNext(); ) {
AMIdentity amid = (AMIdentity) i.next();
Object[] args = { amid.getName(), amid.getUniversalId() };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("format-search-agent-results"), args));
}
} else {
outputWriter.printlnMessage(getResourceString("search-agent-no-entries"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_LIST_AGENTS", params);
} catch (IdRepoException e) {
String[] args = { realm, patternType, filter, e.getMessage() };
debugError("ListAgents.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_AGENTS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, patternType, filter, e.getMessage() };
debugError("ListAgents.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_AGENTS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class DevicePrintModule method init.
/**
* {@inheritDoc}
*/
@Override
public void init(Subject subject, Map sharedState, Map options) {
userName = (String) sharedState.get(getUserKey());
if (StringUtils.isEmpty(userName)) {
ResourceBundle bundle = amCache.getResBundle(AUTH_MODULE_NAME, getLoginLocale());
DEBUG.warning(bundle.getString("authModuleNotSetUpWithUsername"));
}
AMIdentityRepository amIdentityRepository = getAMIdentityRepository(getRequestOrg());
AMIdentity amIdentity = getIdentity();
HOTPService hotpService = moduleInitialiser.getHOTPService(getLoginLocale(), amCache, userName, amIdentityRepository, options);
devicePrintAuthenticationService = moduleInitialiser.getDevicePrintAuthenticationService(amIdentity, getHttpServletRequest(), hotpService, options);
}
Aggregations