Search in sources :

Example 1 with Action

use of org.opencastproject.security.api.Permissions.Action in project opencast by opencast.

the class EventIndexUtils method addAuthorization.

/**
 * Adds authorization fields to the input document.
 *
 * @param doc
 *          the input document
 * @param aclString
 *          the access control list string
 */
private static void addAuthorization(SearchMetadataCollection doc, String aclString) {
    Map<String, List<String>> permissions = new HashMap<String, List<String>>();
    // Define containers for common permissions
    for (Action action : Permissions.Action.values()) {
        permissions.put(action.toString(), new ArrayList<String>());
    }
    AccessControlList acl = AccessControlParser.parseAclSilent(aclString);
    for (AccessControlEntry entry : acl.getEntries()) {
        if (!entry.isAllow()) {
            logger.info("Event index does not support denial via ACL, ignoring {}", entry);
            continue;
        }
        List<String> actionPermissions = permissions.get(entry.getAction());
        if (actionPermissions == null) {
            actionPermissions = new ArrayList<String>();
            permissions.put(entry.getAction(), actionPermissions);
        }
        actionPermissions.add(entry.getRole());
    }
    // Write the permissions to the input document
    for (Map.Entry<String, List<String>> entry : permissions.entrySet()) {
        String fieldName = EventIndexSchema.ACL_PERMISSION_PREFIX.concat(entry.getKey());
        doc.addField(fieldName, entry.getValue(), false);
    }
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) Action(org.opencastproject.security.api.Permissions.Action) HashMap(java.util.HashMap) AccessControlEntry(org.opencastproject.security.api.AccessControlEntry) ArrayList(java.util.ArrayList) ListProviderUtil.splitStringList(org.opencastproject.index.service.util.ListProviderUtil.splitStringList) AccessControlList(org.opencastproject.security.api.AccessControlList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with Action

use of org.opencastproject.security.api.Permissions.Action in project opencast by opencast.

the class SeriesIndexUtils method addAuthorization.

/**
 * Adds authorization fields to the input document.
 *
 * @param doc
 *          the input document
 * @param aclString
 *          the access control list string
 */
private static void addAuthorization(SearchMetadataCollection doc, String aclString) {
    Map<String, List<String>> permissions = new HashMap<String, List<String>>();
    // Define containers for common permissions
    for (Action action : Permissions.Action.values()) {
        permissions.put(action.toString(), new ArrayList<String>());
    }
    AccessControlList acl = AccessControlParser.parseAclSilent(aclString);
    for (AccessControlEntry entry : acl.getEntries()) {
        if (!entry.isAllow()) {
            logger.info("Series index does not support denial via ACL, ignoring {}", entry);
            continue;
        }
        List<String> actionPermissions = permissions.get(entry.getAction());
        if (actionPermissions == null) {
            actionPermissions = new ArrayList<String>();
            permissions.put(entry.getAction(), actionPermissions);
        }
        actionPermissions.add(entry.getRole());
    }
    // Write the permissions to the input document
    for (Map.Entry<String, List<String>> entry : permissions.entrySet()) {
        String fieldName = SeriesIndexSchema.ACL_PERMISSION_PREFIX.concat(entry.getKey());
        doc.addField(fieldName, entry.getValue(), false);
    }
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) Action(org.opencastproject.security.api.Permissions.Action) HashMap(java.util.HashMap) AccessControlEntry(org.opencastproject.security.api.AccessControlEntry) ArrayList(java.util.ArrayList) ListProviderUtil.splitStringList(org.opencastproject.index.service.util.ListProviderUtil.splitStringList) AccessControlList(org.opencastproject.security.api.AccessControlList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 ListProviderUtil.splitStringList (org.opencastproject.index.service.util.ListProviderUtil.splitStringList)2 AccessControlEntry (org.opencastproject.security.api.AccessControlEntry)2 AccessControlList (org.opencastproject.security.api.AccessControlList)2 Action (org.opencastproject.security.api.Permissions.Action)2