Java HTTP Server

com.sun.net.httpserver
Class HttpPrincipal

java.lang.Object
  extended by com.sun.net.httpserver.HttpPrincipal
All Implemented Interfaces:
Principal

public class HttpPrincipal
extends Object
implements Principal

Represents a user authenticated by HTTP Basic or Digest authentication.


Constructor Summary
HttpPrincipal(String username, String realm)
          creates a HttpPrincipal from the given username and realm
 
Method Summary
 boolean equals(Object another)
          Compares two HttpPrincipal.
 String getName()
          returns the contents of this principal in the form realm:username
 String getRealm()
          returns the realm this object was created with.
 String getUsername()
          returns the username this object was created with.
 int hashCode()
          returns a hashcode for this HttpPrincipal.
 String toString()
          returns the same string as getName()
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpPrincipal

public HttpPrincipal(String username,
                     String realm)
creates a HttpPrincipal from the given username and realm

Parameters:
username - The name of the user within the realm
realm - The realm.
Throws:
NullPointerException - if either username or realm are null
Method Detail

equals

public boolean equals(Object another)
Compares two HttpPrincipal. Returns true if another is an instance of HttpPrincipal, and its username and realm are equal to this object's username and realm. Returns false otherwise.

Specified by:
equals in interface Principal
Overrides:
equals in class Object

getName

public String getName()
returns the contents of this principal in the form realm:username

Specified by:
getName in interface Principal

getUsername

public String getUsername()
returns the username this object was created with.


getRealm

public String getRealm()
returns the realm this object was created with.


hashCode

public int hashCode()
returns a hashcode for this HttpPrincipal. This is calculated as (getUsername()+getRealm().hashCode()

Specified by:
hashCode in interface Principal
Overrides:
hashCode in class Object

toString

public String toString()
returns the same string as getName()

Specified by:
toString in interface Principal
Overrides:
toString in class Object

Java HTTP Server