001package org.apache.fulcrum.security.model.dynamic.entity;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Set;
023
024import org.apache.fulcrum.security.entity.Permission;
025import org.apache.fulcrum.security.entity.Role;
026import org.apache.fulcrum.security.util.RoleSet;
027
028/**
029 * Represents the "simple" model where permissions are related to roles, roles
030 * are related to groups and groups are related to users, all in many to many
031 * relationships.
032 * 
033 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
034 * @version $Id$
035 */
036public interface DynamicPermission extends Permission
037{
038    /**
039     * Get the roles that this permission belongs to
040     * 
041     * @return a set of roles
042     */
043    public RoleSet getRoles();
044
045    /**
046     * Set the roles that this permission belongs to
047     * 
048     * @param roleSet
049     *            a set of roles
050     */
051    public void setRoles(RoleSet roleSet);
052
053    /**
054     * Add a role to this permission
055     * 
056     * @param role
057     *            the role to add
058     */
059    public void addRole(Role role);
060
061    /**
062     * Remove a role from this permission
063     * 
064     * @param role
065     *            the role to remove
066     */
067    public void removeRole(Role role);
068
069    /**
070     * Set the roles that this permission belongs to as Set
071     * 
072     * @param roles
073     *            a set of roles
074     */
075    public <T extends Role> void setRolesAsSet(Set<T> roles);
076
077    /**
078     * Get the roles that this permission belongs to as Set
079     * 
080     * @return a set of roles
081     */
082    public <T extends Role> Set<T> getRolesAsSet();
083}