/*
 * $Header: //192.168.205.145/cvsroot/ecs/src/main/se/benefit/auth/jaas/ECSPrincipal.java,v 1.1 2001/05/14 07:31:53 lepe Exp $
 *
 * Copyright 1999 by Benefit AB,
 * Bergendorffsgatan 5A, 652 24 Karlstad, Sweden.
 * All rights reserved.
 * 
 * This software is the confidential and proprietary information
 * of Benefit Partner. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Benefit Partner.
 */
package se.benefit.auth.jaas;

import java.security.Principal;

/** A simple String based implementation of Principal. Typically
a ECSPrincipal is created given a userID which is used
as the Principal name and a client id which is used as a ref to which
client the user is loggin in on.

Based on org.jboss.security.SimplePrincipal

@author <a href="lennart.petersson@benefit.se">Lennart Petersson</a>
@version $id$
*/
public class ECSPrincipal implements Principal, java.io.Serializable
{
  /** Name of the user */
  private String name;
  
  /** Client user is running on */
  private String client;

  /** Constructor
  @param name Name of the user
  */
  public ECSPrincipal(String name)
  {
    this.name = name;
  }

  /** Constructor
  @param name Name of the user
  @param client Where user is running
  */
  public ECSPrincipal(String name, String client)
  {
    this.name = name;
    this.client = client;
  }

  /** Compare this Principal's name against another Principal
      name or null if this.getName() is null.
  @return true if name == another == null || name equals
      another.toString();
   */
  public boolean equals(Object another)
  {
    if (name == null)
      return (another == null);  
    if ((another == null) || !(another instanceof ECSPrincipal))
      return false;
    return name.equals( another.toString() );
  }

  public int hashCode()
  {
    return (name == null ? 0 : name.hashCode());
  }

  public String toString()
  {
    return name;
  }

  public String getName()
  {
    return name;
  }

  public String getClient()
  {
    return client;
  }
} 
/**
 * $Log: ECSPrincipal.java,v $
 * Revision 1.1  2001/05/14 07:31:53  lepe
 * A lot of changes and new fies... :-)
 *
 */