use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ServicesModelImpl method addIdentityUnassignedServices.
private void addIdentityUnassignedServices(String realmName, Set names) {
/*
* It is ok that administrator such as policy administrator
* does not have access to AMIdentityRepository. We just ignore it.
*/
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
AMIdentity realmIdentity = repo.getRealmIdentity();
names.addAll(realmIdentity.getAssignableServices());
} catch (IdRepoException e) {
debug.warning("ServicesModelImpl.addIdentityUnassignedServices", e);
} catch (SSOException e) {
debug.warning("ServicesModelImpl.addIdentityUnassignedServices", e);
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ServicesProfileModelImpl method getAttributeValues.
/**
* Returns attribute values of the service profile.
*
* @return attribute values of the service profile.
*/
public Map getAttributeValues() {
Map map = null;
String[] params = { currentRealm, serviceName, "*" };
logEvent("ATTEMPT_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), currentRealm);
AMIdentity realmIdentity = repo.getRealmIdentity();
Set servicesFromIdRepo = realmIdentity.getAssignedServices();
if (servicesFromIdRepo.contains(serviceName)) {
map = realmIdentity.getServiceAttributes(serviceName);
} else {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), currentRealm);
map = orgCfgMgr.getServiceAttributes(serviceName);
}
logEvent("SUCCEED_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("SSO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
debug.error("ServicesProfileModelImpl.getAttributeValues", e);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("IDREPO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
debug.error("ServicesProfileModelImpl.getAttributeValues", e);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("SMS_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
debug.error("ServicesProfileModelImpl.getAttributeValues", e);
}
return (map != null) ? map : Collections.EMPTY_MAP;
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class UserDevicesDao method getIdentity.
/**
* Gets the {@code AMIdentity} for the authenticated user.
*
* @param userName The user's name.
* @param realm The user's realm.
* @return An {@code AMIdentity}.
* @throws InternalServerErrorException If there is a problem getting the user's identity.
*/
private AMIdentity getIdentity(String userName, String realm) throws InternalServerErrorException {
final AMIdentity amIdentity;
final AMIdentityRepository amIdRepo = AuthD.getAuth().getAMIdentityRepository(realm);
final IdSearchControl idsc = new IdSearchControl();
idsc.setAllReturnAttributes(true);
Set<AMIdentity> results = Collections.emptySet();
try {
idsc.setMaxResults(NO_LIMIT);
IdSearchResults searchResults = amIdRepo.searchIdentities(IdType.USER, userName, idsc);
if (searchResults != null) {
results = searchResults.getSearchResults();
}
if (results.isEmpty()) {
throw new IdRepoException("getIdentity : User " + userName + " is not found");
} else if (results.size() > 1) {
throw new IdRepoException("getIdentity : More than one user found for the userName " + userName);
}
amIdentity = results.iterator().next();
} catch (IdRepoException | SSOException e) {
throw new InternalServerErrorException(e.getMessage(), e);
}
return amIdentity;
}
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));
}
}
Aggregations