use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class EntitiesModelImpl method getMembers.
/**
* Returns members of an entity.
*
* @param realmName Name of Realm.
* @param universalId Universal ID of the entity.
* @param type Type of membership.
* @return members of an entity.
* @throws AMConsoleException if members cannot be returned.
*/
public Set getMembers(String realmName, String universalId, String type) throws AMConsoleException {
String[] params = { universalId, type };
logEvent("ATTEMPT_READ_IDENTITY_MEMBER", params);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
Set results = amid.getMembers(IdUtils.getType(type));
logEvent("SUCCEED_READ_IDENTITY_MEMBER", params);
return results;
} catch (SSOException e) {
String[] paramsEx = { universalId, type, getErrorString(e) };
logEvent("SSO_EXCEPTION_READ_IDENTITY_MEMBER", paramsEx);
debug.warning("EntitiesModelImpl.getMembers", e);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, type, getErrorString(e) };
logEvent("IDM_EXCEPTION_READ_IDENTITY_MEMBER", paramsEx);
debug.warning("EntitiesModelImpl.getMembers", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class EntitiesModelImpl method canAddMember.
/**
* Returns true of members can be added to a type.
*
* @param realmName Name of Realm.
* @param idType Type of Entity.
* @param containerIDType Type of Entity of Container.
* @return true of members can be added to a type.
*/
public boolean canAddMember(String realmName, String idType, String containerIDType) throws AMConsoleException {
boolean can = false;
try {
IdType type = IdUtils.getType(idType);
Set canAdd = type.canAddMembers();
IdType ctype = IdUtils.getType(containerIDType);
can = canAdd.contains(ctype);
} catch (IdRepoException e) {
debug.warning("EntitiesModelImpl.canAddMember", e);
throw new AMConsoleException(getErrorString(e));
}
return can;
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class EntitiesModelImpl method getDefaultAttributeValues.
/**
* Returns defauls values for an Entity Type.
*
* @param idType Type of Entity.
* @param agentType mainly for agent type
* @param bCreate true for creation page.
* @throws AMConsoleException if default values cannot be obtained.
*/
public Map getDefaultAttributeValues(String idType, String agentType, boolean bCreate) throws AMConsoleException {
try {
Set attributeSchemas = getAttributeSchemas(idType, agentType, bCreate);
Map values = new HashMap(attributeSchemas.size() * 2);
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
values.put(as.getName(), as.getDefaultValues());
}
if (isWSSEnabled && bCreate && idType.equalsIgnoreCase("agent")) {
Set set = new HashSet(2);
set.add(RADIO_AGENT_TYPE_GENERIC);
values.put(RADIO_AGENT_TYPE, set);
}
return values;
} catch (IdRepoException e) {
debug.warning("EntitiesModelImpl.getDefaultAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
debug.warning("EntitiesModelImpl.getDefaultAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
debug.warning("EntitiesModelImpl.getDefaultAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.console.base.model.AMConsoleException 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.console.base.model.AMConsoleException 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));
}
}
Aggregations