001package systems.dmx.core.service.accesscontrol;
002
003import systems.dmx.core.JSONEnabled;
004
005import org.codehaus.jettison.json.JSONObject;
006
007import java.util.HashMap;
008
009
010
011/**
012 * Calculated permissions for the current user.
013 * <p>
014 * A mapping from operations to booleans.
015 */
016public class Permissions extends HashMap<String, Boolean> implements JSONEnabled {
017
018    // -------------------------------------------------------------------------------------------------- Public Methods
019
020    public Permissions add(Operation operation, boolean allowed) {
021        put(operation.uri, allowed);
022        return this;
023    }
024
025    @Override
026    public JSONObject toJSON() {
027        return new JSONObject(this);
028    }
029}