Search in sources :

Example 61 with IdRepoException

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

the class EntitiesModelImpl method getIdTypeMemberOf.

/**
     * Returns a set of entity types of which a given type can have member of.
     *
     * @param realmName Name of Realm.
     * @param idType Type of Entity.
     * @return a set of entity types of which a given type can have member of.
     * @throws AMConsoleException if <code>idType</code> is not supported.
     */
public Set getIdTypeMemberOf(String realmName, String idType) throws AMConsoleException {
    try {
        IdType ltype = IdUtils.getType(idType);
        Set memberOfs = new HashSet();
        memberOfs.addAll(ltype.canBeMemberOf());
        discardUnsupportedIdType(realmName, memberOfs);
        for (Iterator i = memberOfs.iterator(); i.hasNext(); ) {
            IdType t = (IdType) i.next();
            Set canAdd = t.canAddMembers();
            if (!canAdd.contains(ltype)) {
                i.remove();
            }
        }
        return memberOfs;
    } catch (IdRepoException e) {
        debug.warning("EntitiesModelImpl.getIdTypeMemberOf", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) IdType(com.sun.identity.idm.IdType) HashSet(java.util.HashSet)

Example 62 with IdRepoException

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

Example 63 with IdRepoException

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

the class EntitiesModelImpl method deleteEntities.

/**
     * Deletes entities.
     *
     * @param realmName Name of Realm.
     * @param names Name of Entities to be deleted.
     * @throws AMConsoleException if entity cannot be deleted.
     */
public void deleteEntities(String realmName, Set names) throws AMConsoleException {
    if ((names != null) && !names.isEmpty()) {
        String idNames = AMFormatUtils.toCommaSeparatedFormat(names);
        String[] params = { realmName, idNames };
        logEvent("ATTEMPT_DELETE_IDENTITY", params);
        try {
            AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
            repo.deleteIdentities(getAMIdentity(names));
            logEvent("SUCCEED_DELETE_IDENTITY", params);
        } catch (IdRepoException e) {
            String[] paramsEx = { realmName, idNames, getErrorString(e) };
            logEvent("IDM_EXCEPTION_DELETE_IDENTITY", paramsEx);
            throw new AMConsoleException(getErrorString(e));
        } catch (SSOException e) {
            String[] paramsEx = { realmName, idNames, getErrorString(e) };
            logEvent("SSO_EXCEPTION_DELETE_IDENTITY", paramsEx);
            throw new AMConsoleException(getErrorString(e));
        }
    }
}
Also used : AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 64 with IdRepoException

use of com.sun.identity.idm.IdRepoException 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 65 with IdRepoException

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

Aggregations

IdRepoException (com.sun.identity.idm.IdRepoException)403 SSOException (com.iplanet.sso.SSOException)275 Set (java.util.Set)224 AMIdentity (com.sun.identity.idm.AMIdentity)221 HashSet (java.util.HashSet)183 Map (java.util.Map)121 Iterator (java.util.Iterator)118 SSOToken (com.iplanet.sso.SSOToken)112 HashMap (java.util.HashMap)110 SMSException (com.sun.identity.sm.SMSException)103 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)96 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)67 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)58 IdType (com.sun.identity.idm.IdType)57 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)51 CLIException (com.sun.identity.cli.CLIException)48 IOutput (com.sun.identity.cli.IOutput)45 IdSearchResults (com.sun.identity.idm.IdSearchResults)44 IdSearchControl (com.sun.identity.idm.IdSearchControl)39 IdRepoUnsupportedOpException (com.sun.identity.idm.IdRepoUnsupportedOpException)35