use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class AMCommonNameGenerator method addFormats.
/**
* Adds format by retrieving the globalization service
* attributes to get the list of formats and add them
* accordingly.
*
* @param realm Realm Name
* @return map of locale to formats
*/
private Map addFormats(String realm) {
Set values = null;
Map map = null;
try {
AMIdentityRepository repo = new AMIdentityRepository(adminSSOToken, realm);
AMIdentity realmIdentity = repo.getRealmIdentity();
Set servicesFromIdRepo = realmIdentity.getAssignedServices();
if (servicesFromIdRepo.contains(G11N_SERVICE_NAME)) {
map = realmIdentity.getServiceAttributes(G11N_SERVICE_NAME);
} else {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(adminSSOToken, realm);
map = orgCfgMgr.getServiceAttributes(G11N_SERVICE_NAME);
}
} catch (SSOException e) {
debug.warning("AMCommonNameGenerator.addFormats", e);
} catch (SMSException e) {
debug.warning("AMCommonNameGenerator.addFormats", e);
} catch (IdRepoException e) {
debug.warning("AMCommonNameGenerator.addFormats", e);
}
if ((map != null) && !map.isEmpty()) {
values = (Set) map.get(G11N_SERIVCE_COMMON_NAME_FORMAT);
}
if ((values == null) || values.isEmpty()) {
if (serviceSchemaManager != null) {
try {
values = AMAdminUtils.getAttribute(serviceSchemaManager, SchemaType.ORGANIZATION, G11N_SERIVCE_COMMON_NAME_FORMAT);
} catch (SMSException e) {
debug.error("AMCommonNameGenerator.addFormats", e);
}
} else {
debug.error("AMCommonNameGenerator.addFormats: " + "formats are not added because Console cannot get " + "an instance of service schema manager.");
}
}
Map mapFormats = getFormatMap(values);
synchronized (mapRealmToFormat) {
mapRealmToFormat.put(realm, mapFormats);
}
return mapFormats;
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class AMCommonNameGenerator method getUserAttributeValues.
private Map getUserAttributeValues(String univId) {
Map values = null;
try {
AMIdentity amid = IdUtils.getIdentity(adminSSOToken, univId);
if (amid != null) {
Map map = amid.getAttributes();
Map attributeSchemasNames = getAttributeSchemaExactNames(amid.getType().getName());
values = new HashMap(map.size() * 2);
/*
* Need to get the attribute name to the proper case.
* SDK makes them all lowercased
*/
for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
String name = (String) i.next();
String exactName = (String) attributeSchemasNames.get(name);
if (exactName == null) {
exactName = name;
}
values.put(exactName, map.get(name));
}
}
} catch (SSOException e) {
debug.warning("AMCommonNameGenerator.getUserAttributeValues", e);
} catch (SMSException e) {
debug.warning("AMCommonNameGenerator.getUserAttributeValues", e);
} catch (IdRepoException e) {
debug.warning("AMCommonNameGenerator.getUserAttributeValues", e);
}
return (values != null) ? values : Collections.EMPTY_MAP;
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class AMModelBase method getUserOrganization.
/**
* Returns the <code>DN</code> of the users organization.
*
* @return <code>DN</code> of the users organization.
*/
public String getUserOrganization() {
String orgDN = "";
if (userDN != null) {
try {
AMIdentity amid = IdUtils.getIdentity(ssoToken);
orgDN = amid.getRealm();
} catch (SSOException e) {
debug.error("AMModelBase.getUserOrganization", e);
} catch (IdRepoException e) {
debug.error("AMModelBase.getUserOrganization", e);
}
}
return orgDN;
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntityEditViewBean method getOptionListForEntities.
protected OptionList getOptionListForEntities(Collection entities) {
OptionList optList = new OptionList();
if ((entities != null) && !entities.isEmpty()) {
EntitiesModel model = (EntitiesModel) getModel();
Map lookup = new HashMap(entities.size() * 2);
Set unsorted = new HashSet(entities.size() * 2);
for (Iterator iter = entities.iterator(); iter.hasNext(); ) {
AMIdentity entity = (AMIdentity) iter.next();
String name = AMFormatUtils.getIdentityDisplayName(model, entity);
String universalId = IdUtils.getUniversalId(entity);
lookup.put(universalId, name);
unsorted.add(name);
}
List list = AMFormatUtils.sortItems(unsorted, model.getUserLocale());
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
String id = null;
String tmp = null;
for (Iterator it = lookup.keySet().iterator(); it.hasNext(); ) {
id = (String) it.next();
if (lookup.get(id).equals(name)) {
tmp = name + "(" + LDAPUtils.rdnValueFromDn(id) + ")";
optList.add(tmp, id);
}
}
}
}
return optList;
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntityMembersViewBean method removeAlreadyAssignedMembers.
/*
* Remove the users who are already members of this entity
* and also remove those members who are 'special users'.
*/
private void removeAlreadyAssignedMembers(Set assignable) {
for (Iterator i = assignedMembers.iterator(); i.hasNext(); ) {
Object obj = i.next();
if (obj instanceof AMIdentity) {
assignable.remove(obj);
} else {
boolean removed = false;
for (Iterator iter = assignable.iterator(); iter.hasNext() && !removed; ) {
AMIdentity amid = (AMIdentity) iter.next();
if (IdUtils.getUniversalId(amid).equalsIgnoreCase((String) obj)) {
iter.remove();
removed = true;
}
}
}
}
}
Aggregations