Search in sources :

Example 46 with AMConsoleException

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

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

the class EntitiesModelImpl method canAddMember.

/**
     * Returns true of members can be added to a type.
     *
     * @param realmName Name of Realm.
     * @param idType Type of Entity.
     * @param containerIDType Type of Entity of Container.
     * @return true of members can be added to a type.
     */
public boolean canAddMember(String realmName, String idType, String containerIDType) throws AMConsoleException {
    boolean can = false;
    try {
        IdType type = IdUtils.getType(idType);
        Set canAdd = type.canAddMembers();
        IdType ctype = IdUtils.getType(containerIDType);
        can = canAdd.contains(ctype);
    } catch (IdRepoException e) {
        debug.warning("EntitiesModelImpl.canAddMember", e);
        throw new AMConsoleException(getErrorString(e));
    }
    return can;
}
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)

Example 48 with AMConsoleException

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

the class EntitiesModelImpl method getDefaultAttributeValues.

/**
     * Returns defauls values for an Entity Type.
     *
     * @param idType Type of Entity.
     * @param agentType mainly for agent type
     * @param bCreate true for creation page.
     * @throws AMConsoleException if default values cannot be obtained.
     */
public Map getDefaultAttributeValues(String idType, String agentType, boolean bCreate) throws AMConsoleException {
    try {
        Set attributeSchemas = getAttributeSchemas(idType, agentType, bCreate);
        Map values = new HashMap(attributeSchemas.size() * 2);
        for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) i.next();
            values.put(as.getName(), as.getDefaultValues());
        }
        if (isWSSEnabled && bCreate && idType.equalsIgnoreCase("agent")) {
            Set set = new HashSet(2);
            set.add(RADIO_AGENT_TYPE_GENERIC);
            values.put(RADIO_AGENT_TYPE, set);
        }
        return values;
    } catch (IdRepoException e) {
        debug.warning("EntitiesModelImpl.getDefaultAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        debug.warning("EntitiesModelImpl.getDefaultAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        debug.warning("EntitiesModelImpl.getDefaultAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) 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) HashSet(java.util.HashSet)

Example 49 with AMConsoleException

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

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

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