Search in sources :

Example 1 with ISaveIndex

use of com.sun.identity.entitlement.interfaces.ISaveIndex in project OpenAM by OpenRock.

the class EntitlementService method getApplicationData.

private Map<String, Set<String>> getApplicationData(Application appl) {
    Map<String, Set<String>> map = new HashMap<String, Set<String>>();
    Set<String> setServiceID = new HashSet<String>(2);
    map.put(SMSEntry.ATTR_SERVICE_ID, setServiceID);
    setServiceID.add("application");
    Set<String> setObjectClass = new HashSet<String>(4);
    map.put(SMSEntry.ATTR_OBJECTCLASS, setObjectClass);
    setObjectClass.add(SMSEntry.OC_TOP);
    setObjectClass.add(SMSEntry.OC_SERVICE_COMP);
    Set<String> data = new HashSet<String>();
    map.put(SMSEntry.ATTR_KEYVAL, data);
    data.add(EntitlementUtils.APPLICATION_TYPE + '=' + appl.getApplicationType().getName());
    if (appl.getDescription() != null) {
        data.add(EntitlementUtils.CONFIG_DESCRIPTION + "=" + appl.getDescription());
    } else {
        data.add(EntitlementUtils.CONFIG_DESCRIPTION + "=");
    }
    data.add(CONFIG_ENTITLEMENT_COMBINER + "=" + appl.getEntitlementCombiner().getClass().getName());
    Set<String> conditions = appl.getConditions();
    if ((conditions != null) && !conditions.isEmpty()) {
        for (String c : conditions) {
            data.add(CONFIG_CONDITIONS + "=" + c);
        }
    } else {
        data.add(CONFIG_CONDITIONS + "=");
    }
    Set<String> subjects = appl.getSubjects();
    if ((subjects != null) && !subjects.isEmpty()) {
        for (String s : subjects) {
            data.add(CONFIG_SUBJECTS + "=" + s);
        }
    } else {
        data.add(CONFIG_SUBJECTS + "=");
    }
    ISaveIndex sIndex = appl.getSaveIndex();
    if (sIndex != null) {
        String saveIndexClassName = sIndex.getClass().getName();
        data.add(CONFIG_SAVE_INDEX_IMPL + "=" + saveIndexClassName);
    }
    ISearchIndex searchIndex = appl.getSearchIndex();
    if (searchIndex != null) {
        String searchIndexClassName = searchIndex.getClass().getName();
        data.add(CONFIG_SEARCH_INDEX_IMPL + "=" + searchIndexClassName);
    }
    ResourceName recComp = appl.getResourceComparator(false);
    if (recComp != null) {
        String resCompClassName = recComp.getClass().getName();
        data.add(CONFIG_RESOURCE_COMP_IMPL + "=" + resCompClassName);
    }
    Set<String> sbjAttributes = appl.getAttributeNames();
    if ((sbjAttributes != null) && !sbjAttributes.isEmpty()) {
        for (String s : sbjAttributes) {
            data.add(ATTR_NAME_SUBJECT_ATTR_NAMES + "=" + s);
        }
    } else {
        data.add(ATTR_NAME_SUBJECT_ATTR_NAMES + "=");
    }
    for (String m : appl.getMetaData()) {
        data.add(ATTR_NAME_META + "=" + m);
    }
    if (!appl.getResourceTypeUuids().isEmpty()) {
        Set<String> searchableAttributes = new HashSet<String>();
        for (String resourceTypeUuid : appl.getResourceTypeUuids()) {
            searchableAttributes.add(EntitlementUtils.CONFIG_RESOURCE_TYPE_UUIDS + "=" + resourceTypeUuid);
        }
        map.put(SMSEntry.ATTR_XML_KEYVAL, searchableAttributes);
    }
    map.put("ou", getApplicationIndices(appl));
    return map;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ISearchIndex(com.sun.identity.entitlement.interfaces.ISearchIndex) ResourceName(com.sun.identity.entitlement.interfaces.ResourceName) ISaveIndex(com.sun.identity.entitlement.interfaces.ISaveIndex) HashSet(java.util.HashSet)

Example 2 with ISaveIndex

use of com.sun.identity.entitlement.interfaces.ISaveIndex in project OpenAM by OpenRock.

the class ApplicationImpl method getSaveIndex.

private Class getSaveIndex(Map<String, Set<String>> attributeValues) throws CLIException {
    String saveIndex = getString(ATTR_SAVE_INDEX, attributeValues);
    if ((saveIndex == null) || (saveIndex.trim().length() == 0)) {
        return null;
    }
    try {
        Class clazz = Class.forName(saveIndex);
        Object obj = clazz.newInstance();
        if (obj instanceof ISaveIndex) {
            return clazz;
        }
        Object[] params = { saveIndex };
        throw new CLIException(MessageFormat.format("save-index-does-not-extend-interface", params), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (InstantiationException ex) {
        throw new CLIException(ex, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IllegalAccessException ex) {
        throw new CLIException(ex, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ClassNotFoundException ex) {
        Object[] params = { saveIndex };
        throw new CLIException(MessageFormat.format("save-index-class-not-found", params), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ISaveIndex(com.sun.identity.entitlement.interfaces.ISaveIndex) CLIException(com.sun.identity.cli.CLIException)

Example 3 with ISaveIndex

use of com.sun.identity.entitlement.interfaces.ISaveIndex in project OpenAM by OpenRock.

the class EntitlementService method getApplicationTypeData.

private Map<String, Set<String>> getApplicationTypeData(ApplicationType applType) {
    Map<String, Set<String>> data = new HashMap<String, Set<String>>();
    data.put(EntitlementUtils.CONFIG_ACTIONS, EntitlementUtils.getActionSet(applType.getActions()));
    ISaveIndex sIndex = applType.getSaveIndex();
    String saveIndexClassName = (sIndex != null) ? sIndex.getClass().getName() : null;
    data.put(CONFIG_SAVE_INDEX_IMPL, (saveIndexClassName == null) ? Collections.EMPTY_SET : getSet(saveIndexClassName));
    ISearchIndex searchIndex = applType.getSearchIndex();
    String searchIndexClassName = (searchIndex != null) ? searchIndex.getClass().getName() : null;
    data.put(CONFIG_SEARCH_INDEX_IMPL, (searchIndexClassName == null) ? Collections.EMPTY_SET : getSet(searchIndexClassName));
    ResourceName recComp = applType.getResourceComparator();
    String resCompClassName = (recComp != null) ? recComp.getClass().getName() : null;
    data.put(CONFIG_RESOURCE_COMP_IMPL, (resCompClassName == null) ? Collections.EMPTY_SET : getSet(resCompClassName));
    return data;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ISearchIndex(com.sun.identity.entitlement.interfaces.ISearchIndex) ResourceName(com.sun.identity.entitlement.interfaces.ResourceName) ISaveIndex(com.sun.identity.entitlement.interfaces.ISaveIndex)

Example 4 with ISaveIndex

use of com.sun.identity.entitlement.interfaces.ISaveIndex in project OpenAM by OpenRock.

the class UpgradeEntitlementsStep method processEntry.

private Set<String> processEntry(SearchResultEntry entry) throws Exception {
    Set<String> keyValues = entry.parseAttribute(SUN_KEY_VALUE).asSetOfString();
    Set<String> newPathIndexes = new HashSet<String>(1);
    ISaveIndex saveImpl = Class.forName(NEW_SAVE_IMPL).asSubclass(ISaveIndex.class).newInstance();
    for (String value : keyValues) {
        if (value.startsWith(SERIALIZABLE_PREFIX)) {
            String jsonData = value.substring(SERIALIZABLE_PREFIX.length());
            Privilege privilege = Privilege.getInstance(new JSONObject(jsonData));
            Set<String> pathIndexes = generatePathIndexes(saveImpl, privilege.getEntitlement().getResourceNames());
            for (String pathIndex : pathIndexes) {
                newPathIndexes.add(PATH_INDEX_PREFIX + pathIndex);
            }
        }
    }
    Set<String> values = entry.parseAttribute(SUN_XML_KEY_VALUE).asSetOfString();
    Iterator<String> it = values.iterator();
    while (it.hasNext()) {
        if (it.next().startsWith(PATH_INDEX_PREFIX)) {
            it.remove();
        }
    }
    values.addAll(newPathIndexes);
    return values;
}
Also used : JSONObject(org.json.JSONObject) ISaveIndex(com.sun.identity.entitlement.interfaces.ISaveIndex) Privilege(com.sun.identity.entitlement.Privilege) HashSet(java.util.HashSet)

Aggregations

ISaveIndex (com.sun.identity.entitlement.interfaces.ISaveIndex)4 HashSet (java.util.HashSet)3 ISearchIndex (com.sun.identity.entitlement.interfaces.ISearchIndex)2 ResourceName (com.sun.identity.entitlement.interfaces.ResourceName)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 CLIException (com.sun.identity.cli.CLIException)1 Privilege (com.sun.identity.entitlement.Privilege)1 JSONObject (org.json.JSONObject)1