use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class AgentsModelImpl method deleteAgents.
/**
* Deletes agents.
*
* @param realmName Realm where agent resides.
* @param agents Set of agent names to be deleted.
* @throws AMConsoleException if agents cannot be deleted.
*/
public void deleteAgents(String realmName, Set agents) throws AMConsoleException {
if ((agents != null) && !agents.isEmpty()) {
String idNames = AMFormatUtils.toCommaSeparatedFormat(agents);
String[] params = { realmName, idNames };
logEvent("ATTEMPT_DELETE_AGENT", params);
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
repo.deleteIdentities(getAMIdentity(agents));
logEvent("SUCCEED_DELETE_AGENT", params);
} catch (IdRepoException e) {
String[] paramsEx = { realmName, idNames, getErrorString(e) };
logEvent("EXCEPTION_DELETE_AGENT", paramsEx);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] paramsEx = { realmName, idNames, getErrorString(e) };
logEvent("EXCEPTION_DELETE_AGENT", paramsEx);
throw new AMConsoleException(getErrorString(e));
}
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class AgentsModelImpl method getAgentGroupNames.
/**
* Returns agent group names.
*
* @param realmName Realm where agent groups reside.
* @param setTypes Agent Types.
* @param pattern Search Pattern.
* @param results Set to contains the results.
* @return error code.
* @throws AMConsoleException if result cannot be returned.
*/
public int getAgentGroupNames(String realmName, Set setTypes, String pattern, Set results) throws AMConsoleException {
int sizeLimit = getSearchResultLimit();
int timeLimit = getSearchTimeOutLimit();
String[] params = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit) };
try {
IdSearchControl idsc = new IdSearchControl();
idsc.setMaxResults(sizeLimit);
idsc.setTimeOut(timeLimit);
idsc.setAllReturnAttributes(false);
logEvent("ATTEMPT_SEARCH_AGENT_GROUP", params);
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
IdSearchResults isr = repo.searchIdentities(IdType.AGENTGROUP, pattern, idsc);
Set res = isr.getSearchResults();
if ((res != null) && !res.isEmpty()) {
for (Iterator i = res.iterator(); i.hasNext(); ) {
AMIdentity amid = (AMIdentity) i.next();
if (matchType(amid, setTypes)) {
results.add(amid);
}
}
}
logEvent("SUCCEED_SEARCH_AGENT_GROUP", params);
return isr.getErrorCode();
} catch (IdRepoException e) {
String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
logEvent("EXCEPTION_SEARCH_AGENT_GROUP", paramsEx);
if (debug.warningEnabled()) {
debug.warning("AgentsModelImpl.getAgentGroupNames " + getErrorString(e));
}
throw new AMConsoleException("no.properties");
} catch (SSOException e) {
String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
logEvent("EXCEPTION_SEARCH_AGENT_GROUP", paramsEx);
debug.warning("AgentsModelImpl.getAgentGroupNames ", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class AgentsModelImpl method getAgentNames.
/**
* Returns agent names.
*
* @param realmName Realm where agents reside.
* @param setTypes Agent Types.
* @param pattern Search Pattern.
* @param results Set to contains the results.
* @return error code.
* @throws AMConsoleException if result cannot be returned.
*/
public int getAgentNames(String realmName, Set setTypes, String pattern, Set results) throws AMConsoleException {
int sizeLimit = getSearchResultLimit();
int timeLimit = getSearchTimeOutLimit();
String[] params = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit) };
try {
IdSearchControl idsc = new IdSearchControl();
idsc.setMaxResults(sizeLimit);
idsc.setTimeOut(timeLimit);
idsc.setAllReturnAttributes(false);
logEvent("ATTEMPT_SEARCH_AGENT", params);
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
IdSearchResults isr = repo.searchIdentities(IdType.AGENTONLY, pattern, idsc);
Set res = isr.getSearchResults();
if ((res != null) && !res.isEmpty()) {
for (Iterator i = res.iterator(); i.hasNext(); ) {
AMIdentity amid = (AMIdentity) i.next();
if (matchType(amid, setTypes)) {
results.add(amid);
}
}
}
logEvent("SUCCEED_SEARCH_AGENT", params);
return isr.getErrorCode();
} catch (IdRepoException e) {
String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
logEvent("EXCEPTION_SEARCH_AGENT", paramsEx);
if (debug.warningEnabled()) {
debug.warning("AgentsModelImpl.getAgentNames " + getErrorString(e));
}
throw new AMConsoleException("no.properties");
} catch (SSOException e) {
String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
logEvent("EXCEPTION_SEARCH_AGENT", paramsEx);
debug.warning("AgentsModelImpl.getAgentNames ", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class AMModelBase method getConsoleAttributes.
/**
* Returns a map of the cosole service attributes configured at the realm
* where the user started (typically where they logged in at.) If the
* admin service is not configured in that realm, the defaults are taken
* from global configuration.
*/
protected Map getConsoleAttributes() {
if (consoleAttributes == null) {
try {
AMIdentityRepository repo = new AMIdentityRepository(adminSSOToken, getStartDN());
AMIdentity realmIdentity = repo.getRealmIdentity();
Set servicesFromIdRepo = realmIdentity.getAssignedServices();
if (servicesFromIdRepo.contains(ADMIN_CONSOLE_SERVICE)) {
consoleAttributes = realmIdentity.getServiceAttributes(ADMIN_CONSOLE_SERVICE);
} else {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(adminSSOToken, getStartDN());
consoleAttributes = orgCfgMgr.getServiceAttributes(ADMIN_CONSOLE_SERVICE);
}
} catch (SSOException e) {
debug.error("AMModelBase.getConsoleAttributes", e);
} catch (SMSException e) {
debug.error("AMModelBase.getConsoleAttributes", e);
} catch (IdRepoException e) {
debug.error("AMModelBase.getConsoleAttributes", e);
}
}
return consoleAttributes;
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class AMModelBase method getSpecialUsers.
/**
* Returns a set of special user identities. This set of identities
* typically should not be displayed in the console.
*
* @param realmName Name of Realm.
* @return a set of <code>AMIdentity</code> entries that should not be
* displayed in the console.
*/
public Set getSpecialUsers(String realmName) {
Set identities = null;
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
IdSearchResults results = repo.getSpecialIdentities(IdType.USER);
identities = results.getSearchResults();
} catch (IdRepoException e) {
debug.warning("AMModelBase.getSpecialUsers", e);
} catch (SSOException e) {
debug.warning("AMModelBase.getSpecialUsers", e);
}
return (identities == null) ? Collections.EMPTY_SET : identities;
}
Aggregations