/************************************************
* Columbia University CS Department
* Network Security Lab
*
* Open and Survivable Embedded Systems (OASES)
*
* Structured Policy Command Language (SPCL)
*
*
* This software is provided as is without any
* warranty or guarantee of merchantibility
* or fitness for a particular purpose. This
* software is released under the terms of the
* GNU General Public License (GPL).
*
* Last updated: March 27, 2003
*
***********************************************/

package spcl.data;

import java.util.Hashtable;
import java.util.Enumeration;

/** 
 * The Group class represents a collection of 
 * associated Principals.
 *
 * Each Principal receives an implicit group.
 * The <code>rules</code> hashtable for this
 * implicit group is always empty, since these
 * Rules already exist inside the Principal.
 *
 * @author locasto@cs.columbia.edu
 *
*/
public class Group{

  private String name;
  private Hashtable rules = new Hashtable();
  private Hashtable members = new Hashtable();

  public Group( String n ){
    this.name = n;
  }

  public String getName(){
    return name;
  }

  public void addRule( Rule r ){
      rules.put( r.getName(), r );
  }

  public Rule getRule( String ruleName ){
    return ((Rule)rules.get( ruleName ));
  }

  public int getNumRules(){
    return (rules.size());
  }

  public Enumeration getRules(){
    return rules.elements();
  }

  public void addMember( Principal p ){
    members.put( p.getName(), p );
  }

  public boolean isMember( String principalName ){
    if( null==members ) return false;
    return members.containsKey( principalName );
  }
}
