001 package de.deepamehta.plugins.accesscontrol.model; 002 003 import de.deepamehta.core.JSONEnabled; 004 import de.deepamehta.core.util.DeepaMehtaUtils; 005 006 import org.codehaus.jettison.json.JSONObject; 007 008 import java.util.HashMap; 009 010 011 012 /** 013 * A mapping from operations to booleans. 014 * <p> 015 * Permissions objects are used to represent both: 016 * - a part of a static ACL entry ### FIXDOC 017 * - calculated permissions for the current user 018 */ 019 public class Permissions extends HashMap<String, Boolean> implements JSONEnabled { 020 021 // ---------------------------------------------------------------------------------------------------- Constructors 022 023 public Permissions() { 024 } 025 026 public Permissions(JSONObject permissions) { 027 DeepaMehtaUtils.toMap(permissions, this); 028 } 029 030 // -------------------------------------------------------------------------------------------------- Public Methods 031 032 public Permissions add(Operation operation, boolean allowed) { 033 put(operation.uri, allowed); 034 return this; 035 } 036 037 @Override 038 public JSONObject toJSON() { 039 return new JSONObject(this); 040 } 041 }