use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class EntitiesModelImpl method unassignServices.
/**
* Unassigns services from an entity.
*
* @param universalId Universal ID of the entity.
* @param serviceNames Set of service names to be unassigned.
* @throws AMConsoleException if services cannot be unassigned.
*/
public void unassignServices(String universalId, Set serviceNames) throws AMConsoleException {
if ((serviceNames != null) && !serviceNames.isEmpty()) {
String[] params = new String[2];
params[0] = universalId;
String currentSvc = "";
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
for (Iterator iter = serviceNames.iterator(); iter.hasNext(); ) {
currentSvc = (String) iter.next();
params[1] = currentSvc;
logEvent("ATTEMPT_IDENTITY_UNASSIGN_SERVICE", params);
amid.unassignService(currentSvc);
logEvent("SUCCEED_IDENTITY_UNASSIGN_SERVICE", params);
}
} catch (SSOException e) {
String[] paramsEx = { universalId, currentSvc, getErrorString(e) };
logEvent("SSO_EXCEPTION_IDENTITY_UNASSIGN_SERVICE", paramsEx);
debug.warning("EntitiesModelImpl.unassignServices", e);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, currentSvc, getErrorString(e) };
logEvent("IDM_EXCEPTION_IDENTITY_UNASSIGN_SERVICE", paramsEx);
debug.warning("EntitiesModelImpl.unassignServices", e);
throw new AMConsoleException(getErrorString(e));
}
}
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class EntitiesModelImpl method removeMembers.
/**
* Removes a set of entities from a membership.
*
* @param universalId Universal ID of the membership.
* @param names Set of Universal ID of entities.
* @throws AMConsoleException if membership removal fails.
*/
public void removeMembers(String universalId, Set names) throws AMConsoleException {
if ((names == null) || names.isEmpty()) {
throw new AMConsoleException("entities.members.remove.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_REMOVE_IDENTITY_MEMBER", params);
amid.removeMember(amidentity);
logEvent("SUCCEED_REMOVE_IDENTITY_MEMBER", params);
}
} catch (SSOException e) {
String[] paramsEx = { universalId, currentId, getErrorString(e) };
logEvent("SSO_EXCEPTION_REMOVE_IDENTITY_MEMBER", paramsEx);
debug.warning("EntitiesModelImpl.removeMembers", e);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, currentId, getErrorString(e) };
logEvent("IDM_EXCEPTION_REMOVE_IDENTITY_MEMBER", paramsEx);
debug.warning("EntitiesModelImpl.removeMembers", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class EntitiesModelImpl method getAssignableServiceNames.
/**
* Returns assignable services. Map of service name to its display name.
*
* @param universalId Universal ID of the entity.
* @return assignable services.
* @throws AMConsoleException if service information cannot be determined.
*/
public Map getAssignableServiceNames(String universalId) throws AMConsoleException {
Map assignable = null;
String[] param = { universalId };
logEvent("ATTEMPT_READ_IDENTITY_ASSIGNABLE_SERVICE", param);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
Set serviceNames = amid.getAssignableServices();
/*
* don't show the auth config, user, or saml service.
*/
IdType type = amid.getType();
if (type.equals(IdType.USER)) {
serviceNames.remove(AMAdminConstants.USER_SERVICE);
serviceNames.remove(AMAdminConstants.AUTH_CONFIG_SERVICE);
serviceNames.remove(AMAdminConstants.SAML_SERVICE);
}
discardServicesWithoutAttributeSchema(serviceNames, amid);
assignable = getLocalizedServiceNames(serviceNames);
logEvent("SUCCEED_READ_IDENTITY_ASSIGNABLE_SERVICE", param);
} catch (SSOException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("SSO_EXCEPTION_READ_IDENTITY_ASSIGNABLE_SERVICE", paramsEx);
debug.warning("EntitiesModelImpl.getAssignableServiceNames", e);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("IDM_EXCEPTION_READ_IDENTITY_ASSIGNABLE_SERVICE", paramsEx);
debug.warning("EntitiesModelImpl.getAssignableServiceNames", e);
throw new AMConsoleException(getErrorString(e));
}
return (assignable != null) ? assignable : Collections.EMPTY_MAP;
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class EntitiesModelImpl method createEntity.
/**
* Creates an entity.
*
* @param realmName Name of Realm.
* @param entityName Name of Entity.
* @param idType Type of Entity.
* @param values Map of attribute name to Set of attribute values.
* @throws AMConsoleException if entity cannot be created.
*/
public void createEntity(String realmName, String entityName, String idType, Map values) throws AMConsoleException {
if (entityName.trim().length() == 0) {
String msg = getLocalizedString("entities.missing.entityName");
String[] param = { getLocalizedString(idType) };
throw new AMConsoleException(MessageFormat.format(msg, (Object[]) param));
}
if (realmName == null) {
realmName = "/";
}
validateAttributes(values);
setAgentDefaultValues(values);
try {
String[] params = { entityName, idType, realmName };
logEvent("ATTEMPT_IDENTITY_CREATION", params);
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
beforeCreate(idType, entityName, values);
repo.createIdentity(IdUtils.getType(idType), entityName, values);
logEvent("IDENTITY_CREATED", params);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] params = { entityName, idType, realmName, strError };
logEvent("IDM_EXCEPTION_IDENTITY_CREATION", params);
throw new AMConsoleException(strError);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] params = { entityName, idType, realmName, strError };
logEvent("SSO_EXCEPTION_IDENTITY_CREATION", params);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class EntitiesModelImpl method getIdTypeBeMemberOf.
/**
* Returns a set of entity types that can be member of a given type.
*
* @param realmName Name of Realm.
* @param idType Type of Entity.
* @return a set of entity types that can be member of a given type.
* @throws AMConsoleException if <code>idType</code> is not supported.
*/
public Set getIdTypeBeMemberOf(String realmName, String idType) throws AMConsoleException {
try {
IdType type = IdUtils.getType(idType);
Set beMemberOfs = new HashSet();
beMemberOfs.addAll(type.canHaveMembers());
discardUnsupportedIdType(realmName, beMemberOfs);
return beMemberOfs;
} catch (IdRepoException e) {
debug.warning("EntitiesModelImpl.getIdTypeBeMemberOf", e);
throw new AMConsoleException(getErrorString(e));
}
}
Aggregations