Search in sources :

Example 81 with AMIdentity

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) AMIdentity(com.sun.identity.idm.AMIdentity) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 82 with AMIdentity

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;
}
Also used : HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 83 with AMIdentity

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;
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 84 with AMIdentity

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;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) OptionList(com.iplanet.jato.view.html.OptionList) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel) HashSet(java.util.HashSet)

Example 85 with AMIdentity

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;
                }
            }
        }
    }
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator)

Aggregations

AMIdentity (com.sun.identity.idm.AMIdentity)373 IdRepoException (com.sun.identity.idm.IdRepoException)243 SSOException (com.iplanet.sso.SSOException)215 Set (java.util.Set)170 HashSet (java.util.HashSet)150 SSOToken (com.iplanet.sso.SSOToken)112 Iterator (java.util.Iterator)91 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)85 Map (java.util.Map)83 HashMap (java.util.HashMap)78 IdType (com.sun.identity.idm.IdType)52 SMSException (com.sun.identity.sm.SMSException)52 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)44 CLIException (com.sun.identity.cli.CLIException)43 IOutput (com.sun.identity.cli.IOutput)42 IdSearchResults (com.sun.identity.idm.IdSearchResults)39 IdSearchControl (com.sun.identity.idm.IdSearchControl)35 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)23 Test (org.testng.annotations.Test)23 List (java.util.List)22