use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntitiesModelImpl method addMembers.
/**
* Adds an entities to a membership.
*
* @param universalId Universal ID of the membership.
* @param names Set of Universal ID of entities.
* @throws AMConsoleException if membership addition fails.
*/
public void addMembers(String universalId, Set names) throws AMConsoleException {
if ((names == null) || names.isEmpty()) {
throw new AMConsoleException("entities.members.add.no.selection.message");
}
SSOToken ssoToken = getUserSSOToken();
String currentId = "";
try {
AMIdentity amid = IdUtils.getIdentity(ssoToken, universalId);
String[] params = new String[2];
params[0] = universalId;
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
String id = (String) iter.next();
AMIdentity amidentity = IdUtils.getIdentity(ssoToken, id);
currentId = id;
params[1] = id;
logEvent("ATTEMPT_ADD_IDENTITY_MEMBER", params);
amid.addMember(amidentity);
logEvent("SUCCEED_ADD_IDENTITY_MEMBER", params);
}
} catch (SSOException e) {
String[] paramsEx = { universalId, currentId, getErrorString(e) };
logEvent("SSO_EXCEPTION_ADD_IDENTITY_MEMBER", paramsEx);
debug.warning("EntitiesModelImpl.addMembers", e);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, currentId, getErrorString(e) };
logEvent("IDM_EXCEPTION_ADD_IDENTITY_MEMBER", paramsEx);
debug.warning("EntitiesModelImpl.addMembers", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntitiesModelImpl method modifyEntity.
/**
* Modifies profile of entity.
*
* @param realmName Name of Realm.
* @param universalId Universal ID of the entity.
* @param values Map of attribute name to set of attribute values.
* @throws AMConsoleException if entity cannot be located or modified.
*/
public void modifyEntity(String realmName, String universalId, Map values) throws AMConsoleException {
if ((values != null) && !values.isEmpty()) {
String attrNames = AMAdminUtils.getString(values.keySet(), ",", false);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
validateAttributes(amid, values);
String[] param = { universalId, attrNames };
logEvent("ATTEMPT_MODIFY_IDENTITY_ATTRIBUTE_VALUE", param);
String entityName = amid.getName();
String idType = amid.getType().getName();
// values must be merged
if (amid.getType().equals(IdType.AGENT) && values.containsKey(AGENT_ATTRIBUTE_LIST) && (amid.getAttribute(AGENT_ATTRIBUTE_LIST) != null)) {
Set newDeviceKeyValue = (Set) values.get(AGENT_ATTRIBUTE_LIST);
Set origDeviceKeyValue = amid.getAttribute(AGENT_ATTRIBUTE_LIST);
for (Iterator items = origDeviceKeyValue.iterator(); items.hasNext(); ) {
String olValue = (String) items.next();
String[] olValues = olValue.split("=");
// Check if this attribute exists in new values
boolean found = false;
for (Iterator nt = newDeviceKeyValue.iterator(); nt.hasNext(); ) {
String ntValue = (String) nt.next();
String[] ntValues = ntValue.split("=");
if (ntValues[0].equalsIgnoreCase(olValues[0])) {
if ((ntValues.length > 1) && (ntValues[1].trim().length() == 0)) {
// Remove the entry
nt.remove();
}
found = true;
break;
}
}
if (!found) {
newDeviceKeyValue.add(olValue);
}
}
}
beforeModify(idType, entityName, values);
amid.setAttributes(values);
amid.store();
logEvent("SUCCEED_MODIFY_IDENTITY_ATTRIBUTE_VALUE", param);
} catch (IdRepoException e) {
String[] paramsEx = { universalId, attrNames, getErrorString(e) };
logEvent("IDM_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
if (e.getErrorCode().equals(IdRepoErrorCode.LDAP_EXCEPTION)) {
throw new AMConsoleException(e.getConstraintViolationDetails());
}
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] paramsEx = { universalId, attrNames, getErrorString(e) };
logEvent("SSO_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(getErrorString(e));
}
}
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntitiesModelImpl method setServiceAttributeValues.
/**
* Set service attribute values to an entity.
*
* @param universalId Universal ID of the entity.
* @param serviceName Name of service name.
* @param values Attribute values.
* @throws AMConsoleException if values cannot be set.
*/
public void setServiceAttributeValues(String universalId, String serviceName, Map values) throws AMConsoleException {
if ((values != null) && !values.isEmpty()) {
try {
String[] params = { universalId, serviceName };
logEvent("ATTEMPT_IDENTITY_WRITE_SERVICE_ATTRIBUTE_VALUES", params);
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
amid.modifyService(serviceName, values);
logEvent("SUCCEED_IDENTITY_WRITE_SERVICE_ATTRIBUTE_VALUES", params);
} catch (SSOException e) {
String[] paramsEx = { universalId, serviceName, getErrorString(e) };
logEvent("SSO_EXCEPTION_IDENTITY_WRITE_SERVICE_ATTRIBUTE_VALUES", paramsEx);
debug.warning("EntitiesModelImpl.setServiceAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, serviceName, getErrorString(e) };
logEvent("IDM_EXCEPTION_IDENTITY_WRITE_SERVICE_ATTRIBUTE_VALUES", paramsEx);
debug.warning("EntitiesModelImpl.setServiceAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
}
}
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntityResourceOfferingModelImpl method assignService.
/**
* Assigns service to an entity.
*
* @param universalId Universal ID of the entity.
* @throws AMConsoleException if service cannot be assigned.
*/
public void assignService(String universalId) throws AMConsoleException {
String[] params = { universalId, AMAdminConstants.DISCOVERY_SERVICE };
logEvent("ATTEMPT_IDENTITY_ASSIGN_SERVICE", params);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
amid.assignService(AMAdminConstants.DISCOVERY_SERVICE, Collections.EMPTY_MAP);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("SSO_EXCEPTION_IDENTITY_ASSIGN_SERVICE", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("IDM_EXCEPTION_IDENTITY_ASSIGN_SERVICE", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntityResourceOfferingModelImpl method getEntityDiscoEntry.
/**
* Returns resource offering entry stored for an entity.
*
* @param universalId Universal ID of the entity.
* @return resource offering entry stored.
* @throws AMConsoleException if entry cannot be determined.
*/
public SMDiscoveryServiceData getEntityDiscoEntry(String universalId) throws AMConsoleException {
SMDiscoveryServiceData resourceOffering = null;
String[] params = { universalId, AMAdminConstants.DISCOVERY_SERVICE };
logEvent("ATTEMPT_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", params);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
Map map = new CaseInsensitiveHashMap();
map.putAll(amid.getServiceAttributes(AMAdminConstants.DISCOVERY_SERVICE));
logEvent("SUCCEED_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", params);
resourceOffering = SMDiscoveryServiceData.getEntries((Set) map.get(AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES));
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("SSO_EXCEPTION_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", paramsEx);
debug.error("EntityResourceOfferingModelImpl.getAttributeValues", e);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("IDM_EXCEPTION_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", paramsEx);
debug.error("EntityResourceOfferingModelImpl.getAttributeValues", e);
}
return resourceOffering;
}
Aggregations