Search in sources :

Example 51 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException 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 52 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class EntitiesModelImpl method createEntity.

/**
     * Creates an entity.
     *
     * @param realmName Name of Realm.
     * @param entityName Name of Entity.
     * @param idType Type of Entity.
     * @param values Map of attribute name to Set of attribute values.
     * @throws AMConsoleException if entity cannot be created.
     */
public void createEntity(String realmName, String entityName, String idType, Map values) throws AMConsoleException {
    if (entityName.trim().length() == 0) {
        String msg = getLocalizedString("entities.missing.entityName");
        String[] param = { getLocalizedString(idType) };
        throw new AMConsoleException(MessageFormat.format(msg, (Object[]) param));
    }
    if (realmName == null) {
        realmName = "/";
    }
    validateAttributes(values);
    setAgentDefaultValues(values);
    try {
        String[] params = { entityName, idType, realmName };
        logEvent("ATTEMPT_IDENTITY_CREATION", params);
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
        beforeCreate(idType, entityName, values);
        repo.createIdentity(IdUtils.getType(idType), entityName, values);
        logEvent("IDENTITY_CREATED", params);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] params = { entityName, idType, realmName, strError };
        logEvent("IDM_EXCEPTION_IDENTITY_CREATION", params);
        throw new AMConsoleException(strError);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] params = { entityName, idType, realmName, strError };
        logEvent("SSO_EXCEPTION_IDENTITY_CREATION", params);
        throw new AMConsoleException(strError);
    }
}
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 53 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class EntitiesModelImpl method getIdTypeBeMemberOf.

/**
     * Returns a set of entity types that can be member of a given type.
     *
     * @param realmName Name of Realm.
     * @param idType Type of Entity.
     * @return a set of entity types that can be member of a given type.
     * @throws AMConsoleException if <code>idType</code> is not supported.
     */
public Set getIdTypeBeMemberOf(String realmName, String idType) throws AMConsoleException {
    try {
        IdType type = IdUtils.getType(idType);
        Set beMemberOfs = new HashSet();
        beMemberOfs.addAll(type.canHaveMembers());
        discardUnsupportedIdType(realmName, beMemberOfs);
        return beMemberOfs;
    } catch (IdRepoException e) {
        debug.warning("EntitiesModelImpl.getIdTypeBeMemberOf", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) 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 54 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException 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 55 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException 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

AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)701 Map (java.util.Map)255 Set (java.util.Set)206 HashMap (java.util.HashMap)193 HashSet (java.util.HashSet)148 SSOException (com.iplanet.sso.SSOException)126 Iterator (java.util.Iterator)122 List (java.util.List)97 SMSException (com.sun.identity.sm.SMSException)83 ArrayList (java.util.ArrayList)78 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)76 IdRepoException (com.sun.identity.idm.IdRepoException)58 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)47 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)46 AMIdentity (com.sun.identity.idm.AMIdentity)44 SAMLv2Model (com.sun.identity.console.federation.model.SAMLv2Model)41 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)41 CCActionTable (com.sun.web.ui.view.table.CCActionTable)40 TreeSet (java.util.TreeSet)39 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)38