Search in sources :

Example 66 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class EntitiesModelImpl method getAssignedServiceNames.

/**
     * Returns assigned services. Map of service name to its display name.
     *
     * @param universalId Universal ID of the entity.
     * @return assigned services.
     * @throws AMConsoleException if service information cannot be determined.
     */
public Map getAssignedServiceNames(String universalId) throws AMConsoleException {
    Map assigned = null;
    String[] param = { universalId };
    logEvent("ATTEMPT_READ_IDENTITY_ASSIGNED_SERVICE", param);
    try {
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
        Set serviceNames = amid.getAssignedServices();
        // don't show auth config or user services in the user profile.
        IdType type = amid.getType();
        if (type.equals(IdType.USER)) {
            serviceNames.remove(AMAdminConstants.USER_SERVICE);
            serviceNames.remove(AMAdminConstants.AUTH_CONFIG_SERVICE);
        }
        assigned = getLocalizedServiceNames(serviceNames);
        logEvent("SUCCEED_READ_IDENTITY_ASSIGNED_SERVICE", param);
    } catch (SSOException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("SSO_EXCEPTION_READ_IDENTITY_ASSIGNED_SERVICE", paramsEx);
        debug.warning("EntitiesModelImpl.getAssignedServiceNames", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (IdRepoFatalException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("IDM_EXCEPTION_READ_IDENTITY_ASSIGNED_SERVICE", paramsEx);
        debug.warning("EntitiesModelImpl.getAssignedServiceNames", e);
        // exception is too cryptic
        if (e.getErrorCode().equals(IdRepoErrorCode.PLUGIN_OPERATION_NOT_SUPPORTED)) {
            isServicesSupported = false;
            throw new AMConsoleException(getLocalizedString("idrepo.sevices.not.supported"));
        } else {
            throw new AMConsoleException(getErrorString(e));
        }
    } catch (IdRepoException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("IDM_EXCEPTION_READ_IDENTITY_ASSIGNED_SERVICE", paramsEx);
        debug.warning("EntitiesModelImpl.getAssignedServiceNames", e);
        throw new AMConsoleException(getErrorString(e));
    }
    return (assigned != null) ? assigned : Collections.EMPTY_MAP;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) IdRepoFatalException(com.sun.identity.idm.IdRepoFatalException) IdType(com.sun.identity.idm.IdType)

Example 67 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class ServicesAddViewBean method getDefaultValuesForIdentity.

private Map getDefaultValuesForIdentity(String universalId, EntitiesModel model) {
    Map defaultValues = null;
    try {
        AMIdentity amid = IdUtils.getIdentity(model.getUserSSOToken(), universalId);
        defaultValues = model.getDefaultValues(amid.getType().getName(), serviceName);
        AMAdminUtils.makeMapValuesEmpty(defaultValues);
    } catch (AMConsoleException e) {
        defaultValues = Collections.EMPTY_MAP;
    } catch (IdRepoException e) {
        defaultValues = Collections.EMPTY_MAP;
    }
    return defaultValues;
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 68 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class IdServicesImpl method combineMembers.

private Set combineMembers(SSOToken token, Set membersSet, IdType type, String orgName, boolean amsdkIncluded, Set amsdkMemberships) {
    Set results = new HashSet();
    Map resultsMap = new CaseInsensitiveHashMap();
    if (amsdkIncluded) {
        if (amsdkMemberships != null) {
            Iterator it = amsdkMemberships.iterator();
            while (it.hasNext()) {
                String m = (String) it.next();
                String mname = DNUtils.DNtoName(m);
                AMIdentity id = new AMIdentity(token, mname, type, orgName, m);
                results.add(id);
                resultsMap.put(mname, id);
            }
        }
    }
    Iterator miter = membersSet.iterator();
    while (miter.hasNext()) {
        Set first = (Set) miter.next();
        if (first == null) {
            continue;
        }
        Iterator it = first.iterator();
        while (it.hasNext()) {
            String m = (String) it.next();
            String mname = DNUtils.DNtoName(m);
            // add to results, if not already there!
            if (!resultsMap.containsKey(mname)) {
                AMIdentity id = new AMIdentity(token, mname, type, orgName, null);
                results.add(id);
                resultsMap.put(mname, id);
            }
        }
    }
    return results;
}
Also used : Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 69 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class IdRepoJAXRPCObjectImpl method getMembers_idrepo.

public Set getMembers_idrepo(String token, String type, String name, String amOrgName, String membersType, String amsdkDN) throws RemoteException, IdRepoException, SSOException {
    SSOToken ssoToken = getSSOToken(token);
    Set results = new HashSet();
    IdType idtype = IdUtils.getType(type);
    IdType mtype = IdUtils.getType(membersType);
    Set idSet = idServices.getMembers(ssoToken, idtype, name, amOrgName, mtype, amsdkDN);
    if (idSet != null) {
        Iterator it = idSet.iterator();
        while (it.hasNext()) {
            AMIdentity id = (AMIdentity) it.next();
            results.add(IdUtils.getUniversalId(id));
        }
    }
    return results;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) NotificationSet(com.iplanet.services.comm.share.NotificationSet) Set(java.util.Set) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) HashSet(java.util.HashSet) IdType(com.sun.identity.idm.IdType)

Example 70 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class ResourceResultCache method getRESTResultsFromServer.

private Set getRESTResultsFromServer(SSOToken appToken, String serviceName, SSOToken token, String resourceName, String scope, Set actionNames, Map env) throws InvalidAppSSOTokenException, SSOException, PolicyException {
    Set<ResourceResult> resourceResults = null;
    try {
        AMIdentity userIdentity = IdUtils.getIdentity(token);
        String restUrl = getRESTPolicyServiceURL(token, scope);
        String queryString = buildEntitlementRequestQueryString("/", serviceName, token, resourceName, actionNames, env);
        restUrl = restUrl + "?" + queryString;
        if (debug.messageEnabled()) {
            debug.message("ResourceResultCache.getRESTResultsFromServer():" + ":serviceName=" + serviceName + ":token=" + token.getPrincipal().getName() + ":resourceName=" + resourceName + ":scope=" + scope + ":actionNames=" + actionNames + ":env" + ":restUrl=" + restUrl + ":entering");
        }
        String jsonString = getResourceContent(appToken, token, restUrl);
        if (debug.messageEnabled()) {
            debug.message("ResourceResultCache.getRESTResultsFromServer():" + ":server response jsonString=" + jsonString);
        }
        resourceResults = jsonResourceContentToResourceResults(jsonString, serviceName);
    } catch (InvalidAppSSOTokenException e) {
        throw e;
    } catch (Exception e) {
        String[] args = { e.getMessage() };
        throw new PolicyEvaluationException(ResBundleUtils.rbName, "rest_policy_request_exception", args, e);
    }
    if (debug.messageEnabled()) {
        debug.message("ResourceResultCache.getRESTResultsFromServer():" + "returning");
    }
    return resourceResults;
}
Also used : ResourceResult(com.sun.identity.policy.ResourceResult) AMIdentity(com.sun.identity.idm.AMIdentity) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException) JSONException(org.json.JSONException) PolicyException(com.sun.identity.policy.PolicyException) SendRequestException(com.iplanet.services.comm.client.SendRequestException) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException) URLNotFoundException(com.iplanet.services.naming.URLNotFoundException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AlreadyRegisteredException(com.iplanet.services.comm.client.AlreadyRegisteredException) IOException(java.io.IOException) SessionException(com.iplanet.dpro.session.SessionException)

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