Search in sources :

Example 61 with AMIdentity

use of com.sun.identity.idm.AMIdentity 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));
    }
}
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)

Example 62 with AMIdentity

use of com.sun.identity.idm.AMIdentity 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));
        }
    }
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 63 with AMIdentity

use of com.sun.identity.idm.AMIdentity 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));
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 64 with AMIdentity

use of com.sun.identity.idm.AMIdentity 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;
}
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) IdType(com.sun.identity.idm.IdType)

Example 65 with AMIdentity

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

the class EntitiesModelImpl method getServiceAttributeValues.

/**
     * Returns service attribute values of an entity.
     *
     * @param universalId Universal ID of the entity.
     * @param serviceName Name of service name.
     * @return service attribute values of entity.
     * @throws AMConsoleException if values cannot be returned.
     */
public Map getServiceAttributeValues(String universalId, String serviceName) throws AMConsoleException {
    Map values = null;
    try {
        String[] params = { universalId, serviceName };
        logEvent("ATTEMPT_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", params);
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
        values = amid.getServiceAttributes(serviceName);
        values = correctAttributeNames(amid, serviceName, values);
        logEvent("SUCCEED_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", params);
    } catch (SSOException e) {
        String[] paramsEx = { universalId, serviceName, getErrorString(e) };
        logEvent("SSO_EXCEPTION_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", paramsEx);
        debug.warning("EntitiesModelImpl.getServiceAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (IdRepoException e) {
        String[] paramsEx = { universalId, serviceName, getErrorString(e) };
        logEvent("IDM_EXCEPTION_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", paramsEx);
        debug.warning("EntitiesModelImpl.getServiceAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    }
    return (values != null) ? values : Collections.EMPTY_MAP;
}
Also used : 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)

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