Search in sources :

Example 31 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class AgentsModelImpl method getAttributeValues.

/**
     * Returns attribute values of an agent or agent group.
     *
     * @param realmName Realm where agent or agent group resides.
     * @param universalId Universal ID of the agent/agent group.
     * @param withInheritValues <code>true</code> to include inherited values.
     * @return attribute values of an agent or agent group.
     * @throws AMConsoleException if object cannot located.
     */
public Map getAttributeValues(String realmName, String universalId, boolean withInheritValues) throws AMConsoleException {
    String[] param = { universalId };
    logEvent("ATTEMPT_GET_AGENT_ATTRIBUTE_VALUES", param);
    try {
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
        Map values = AgentConfiguration.getAgentAttributes(amid, false);
        if (withInheritValues) {
            String groupId = getAgentGroupId(realmName, universalId);
            if ((groupId != null) && (groupId.trim().length() > 0)) {
                AMIdentity group = IdUtils.getIdentity(getUserSSOToken(), groupId);
                if (!group.isExists()) {
                    Object[] arg = { group.getName() };
                    throw new AMConsoleException(MessageFormat.format(getLocalizedString("agent.group.does.not.exist"), arg));
                }
                Map groupValues = AgentConfiguration.getAgentAttributes(group, false);
                //correctly.
                for (Iterator i = groupValues.keySet().iterator(); i.hasNext(); ) {
                    String key = (String) i.next();
                    Set val = (Set) groupValues.get(key);
                    if (val.size() > 1) {
                        StringBuffer buff = new StringBuffer();
                        boolean bFirst = true;
                        for (Iterator j = val.iterator(); j.hasNext(); ) {
                            if (!bFirst) {
                                buff.append(", ");
                            } else {
                                bFirst = false;
                            }
                            buff.append((String) j.next());
                        }
                        val.clear();
                        val.add(buff.toString());
                    }
                }
                groupValues.putAll(values);
                values = groupValues;
            }
        }
        logEvent("SUCCEED_GET_AGENT_ATTRIBUTE_VALUES", param);
        return values;
    } catch (SSOException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("EXCEPTION_GET_AGENT_ATTRIBUTE_VALUES", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("EXCEPTION_GET_AGENT_ATTRIBUTE_VALUES", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    } catch (IdRepoException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("EXCEPTION_GET_AGENT_ATTRIBUTE_VALUES", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 32 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class AgentsModelImpl method getAuthenticationChains.

/**
     * Returns all the authentication chains in a realm.
     *
     * @return all the authentication chains in a realm.
     * @throws AMConsoleException if authentication chains cannot be returned.
     */
public Set getAuthenticationChains() throws AMConsoleException {
    try {
        Set chains = new TreeSet();
        chains.addAll(AgentConfiguration.getChoiceValues("authenticationChain", "WSPAgent").keySet());
        return chains;
    } catch (SSOException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) TreeSet(java.util.TreeSet) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 33 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class AgentsModelImpl method getSTSConfigurations.

/**
     * Returns map of secure token service configurations.
     *
     * @return map of secure token service configurations.
     * @throws AMConsoleException if secure token service configurations cannot
     *         be returned.
     */
public Map getSTSConfigurations() {
    try {
        Map map = AgentConfiguration.getChoiceValues("STS", "WSCAgent");
        if ((map != null) && !map.isEmpty()) {
            if (rbAgent != null) {
                Map localizedMap = new HashMap();
                for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
                    String k = (String) i.next();
                    localizedMap.put((String) map.get(k), Locale.getString(rbAgent, k));
                }
                return localizedMap;
            } else {
                return map;
            }
        }
    } catch (SSOException e) {
        debug.error("AgentModelImpl.getSTSConfigurations", e);
    } catch (SMSException e) {
        debug.error("AgentModelImpl.getSTSConfigurations", e);
    }
    return Collections.EMPTY_MAP;
}
Also used : HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 34 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class AMObjectImpl method getDefaultAcis.

/**
     * Gets the aci description and DN:ACI of the role type that matches the
     * permission
     * 
     * @param permission
     *            Permission in the role type
     * @param aciDesc
     *            StringBuffer to store aci description
     * @return Set of DN:ACI
     * @throws AMException
     *             if there is an internal problem with AM Store.
     * @throws SSOException
     *             if the sign-on is no longer valid.
     */
Set getDefaultAcis(String permission, StringBuffer aciDesc) throws AMException, SSOException {
    Map map;
    try {
        map = AMServiceUtils.getServiceConfig(token, ADMINISTRATION_SERVICE, SchemaType.GLOBAL);
    } catch (SMSException smsex) {
        debug.error(smsex.toString());
        throw new AMException(AMSDKBundle.getString("158", locale), "158");
    }
    Set defaultAcis = (Set) map.get("iplanet-am-admin-console-dynamic-aci-list");
    Iterator iter = defaultAcis.iterator();
    String aci = null;
    while (iter.hasNext()) {
        String defaultAci = (String) iter.next();
        if (defaultAci.startsWith(permission + "|")) {
            aci = defaultAci;
            break;
        }
    }
    if (aci == null) {
        throw new AMException(AMSDKBundle.getString("158", locale), "158");
    }
    StringTokenizer stz = new StringTokenizer(aci, "|");
    if (stz.countTokens() < 3) {
        throw new AMException(AMSDKBundle.getString("159", locale), "159");
    }
    permission = stz.nextToken();
    aciDesc.append(stz.nextToken());
    int index = aci.indexOf('|', permission.length() + 1);
    String acis = aci.substring(index + 1);
    stz = new StringTokenizer(acis, "##");
    Set aciSet = new HashSet();
    while (stz.hasMoreTokens()) {
        aciSet.add(stz.nextToken());
    }
    return aciSet;
}
Also used : StringTokenizer(java.util.StringTokenizer) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 35 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class ComplianceServicesImpl method getDeletedObjectFilter.

/**
     * Protected method to get the search filter to be used for searching for
     * deleted objects.
     * 
     */
public String getDeletedObjectFilter(int objectType) throws AMException, SSOException {
    Set values = new HashSet();
    try {
        if (gsc == null) {
            ServiceSchemaManager scm = new ServiceSchemaManager(ADMINISTRATION_SERVICE, internalToken);
            gsc = scm.getGlobalSchema();
        }
        Map attrMap = gsc.getAttributeDefaults();
        if (attrMap != null)
            values = (Set) attrMap.get(COMPLIANCE_SPECIAL_FILTER_ATTR);
        if (debug.messageEnabled()) {
            debug.message("Compliance.getDeletedObjectSearchFilter = " + values.toString());
        }
    } catch (SMSException ex) {
        debug.error(AMSDKBundle.getString("359"), ex);
        throw new AMException(AMSDKBundle.getString("359"), "359");
    } catch (SSOException ex) {
        debug.error(AMSDKBundle.getString("359"), ex);
        throw new AMException(AMSDKBundle.getString("359"), "359");
    }
    String org_filter = null;
    String group_filter = null;
    String user_filter = null;
    String def_filter = null;
    String res_filter = null;
    Iterator iter = values.iterator();
    while (iter.hasNext()) {
        String thisFilter = (String) iter.next();
        if (thisFilter.startsWith("Organization=")) {
            org_filter = thisFilter.substring(13);
        } else if (thisFilter.startsWith("Group=")) {
            group_filter = thisFilter.substring(6);
        } else if (thisFilter.startsWith("User=")) {
            user_filter = thisFilter.substring(5);
        } else if (thisFilter.startsWith("Misc=")) {
            def_filter = thisFilter.substring(5);
        } else if (thisFilter.startsWith("Resource=")) {
            res_filter = thisFilter.substring(9);
        }
    }
    org_filter = (org_filter == null) ? DEFAULT_DELETED_ORG_FILTER : org_filter;
    group_filter = (group_filter == null) ? DEFAULT_DELETED_GROUP_FILTER : group_filter;
    user_filter = (user_filter == null) ? DEFAULT_DELETED_USER_FILTER : user_filter;
    def_filter = (def_filter == null) ? DEFAULT_DELETED_OBJECT_FILTER : def_filter;
    res_filter = (res_filter == null) ? DEFAULT_DELETED_RESOURCE_FILTER : res_filter;
    switch(objectType) {
        case AMObject.ORGANIZATION:
            return (org_filter);
        case AMObject.USER:
            return (user_filter);
        case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
        case AMObject.DYNAMIC_GROUP:
        case AMObject.STATIC_GROUP:
        case AMObject.GROUP:
            return (group_filter);
        case AMObject.RESOURCE:
            return (res_filter);
        default:
            return ("(|" + org_filter + group_filter + user_filter + def_filter + res_filter + ")");
    }
}
Also used : HashSet(java.util.HashSet) AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) HashSet(java.util.HashSet)

Aggregations

SMSException (com.sun.identity.sm.SMSException)704 SSOException (com.iplanet.sso.SSOException)525 Set (java.util.Set)272 HashSet (java.util.HashSet)200 SSOToken (com.iplanet.sso.SSOToken)185 Map (java.util.Map)166 ServiceConfig (com.sun.identity.sm.ServiceConfig)164 HashMap (java.util.HashMap)158 CLIException (com.sun.identity.cli.CLIException)149 ServiceSchema (com.sun.identity.sm.ServiceSchema)138 Iterator (java.util.Iterator)133 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)104 IOutput (com.sun.identity.cli.IOutput)96 IdRepoException (com.sun.identity.idm.IdRepoException)86 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)83 AttributeSchema (com.sun.identity.sm.AttributeSchema)66 IOException (java.io.IOException)55 List (java.util.List)51