Search in sources :

Example 51 with IdRepoException

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

the class EntityResourceOfferingModelImpl method assignService.

/**
     * Assigns service to an entity.
     *
     * @param universalId Universal ID of the entity.
     * @throws AMConsoleException if service cannot be assigned.
     */
public void assignService(String universalId) throws AMConsoleException {
    String[] params = { universalId, AMAdminConstants.DISCOVERY_SERVICE };
    logEvent("ATTEMPT_IDENTITY_ASSIGN_SERVICE", params);
    try {
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
        amid.assignService(AMAdminConstants.DISCOVERY_SERVICE, Collections.EMPTY_MAP);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SSO_EXCEPTION_IDENTITY_ASSIGN_SERVICE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("IDM_EXCEPTION_IDENTITY_ASSIGN_SERVICE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
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)

Example 52 with IdRepoException

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

the class EntityResourceOfferingModelImpl method getEntityDiscoEntry.

/**
     * Returns resource offering entry stored for an entity.
     *
     * @param universalId Universal ID of the entity.
     * @return resource offering entry stored.
     * @throws AMConsoleException if entry cannot be determined.
     */
public SMDiscoveryServiceData getEntityDiscoEntry(String universalId) throws AMConsoleException {
    SMDiscoveryServiceData resourceOffering = null;
    String[] params = { universalId, AMAdminConstants.DISCOVERY_SERVICE };
    logEvent("ATTEMPT_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", params);
    try {
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
        Map map = new CaseInsensitiveHashMap();
        map.putAll(amid.getServiceAttributes(AMAdminConstants.DISCOVERY_SERVICE));
        logEvent("SUCCEED_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", params);
        resourceOffering = SMDiscoveryServiceData.getEntries((Set) map.get(AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES));
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SSO_EXCEPTION_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", paramsEx);
        debug.error("EntityResourceOfferingModelImpl.getAttributeValues", e);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { universalId, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("IDM_EXCEPTION_IDENTITY_READ_SERVICE_ATTRIBUTE_VALUES", paramsEx);
        debug.error("EntityResourceOfferingModelImpl.getAttributeValues", e);
    }
    return resourceOffering;
}
Also used : SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) Set(java.util.Set) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 53 with IdRepoException

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

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

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

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