/************************************************
* 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: April 10, 2003
*
***********************************************/

package spcl.data;

import java.util.Vector;
import java.util.Enumeration;

/**
 * An object representing a Principal to the
 * policy engine. It has a cache for log or
 * notify events. Some background thread should
 * actually run through this cache periodically
 * and use the contact information to actually
 * forward it to the user.
 *
 * @author locasto@cs.columbia.edu
 *
*/
public class Principal{

  private String name;
  private Vector aliases = new Vector();
  private Vector groups = new Vector();
  private String emailaddr ="";
  private String phone = "";

  //@deprecated
  private String url="";

  private Vector rules = new Vector( 25 );
  
  private Vector notifyBuffer = new Vector( 20 );

  public Principal( String id ){
    this.name = id;
  }

  public String getName(){
    return name;
  }
  
  public void addAlias( String a ){ 
    aliases.add( a );
  }
  
  public void addGroup( Group g ){
     groups.add( g );
  }
  
  public void addRule( Rule r ){
    rules.add( r );
  }

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

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

  public void setEmailaddr( String e ){
    emailaddr = e;
  }
  public String getEmailaddr(){
    return emailaddr;
  }

  public void setPhone( String p ){
    phone = p;
  }
  public String getPhone(){
    return phone;
  }

  /** @deprecated with no replacement */
  public void setURL( String u ){
   url = u;
  }

  public Vector getGroups(){
    return groups;
  }
  
  public boolean hasAlias( String a ){
     return (aliases.contains( a ));
  }
  
  public boolean inGroup( Group group ){
     return (groups.contains(group));
  }

}
