APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.net.httpserver

public Class HttpPrincipal

extends Object
implements Principal
Class Inheritance
All Implemented Interfaces
java.security.Principal
Imports
java.security.Principal

Represents a user authenticated by HTTP Basic or Digest authentication.
Since
1.6

Field Summary

Modifier and TypeField and Description
private String
private String

Constructor Summary

AccessConstructor and Description
public
HttpPrincipal(String
the name of the user within the realm
username
,
String
the realm for this user
realm
)

Creates a HttpPrincipal from the given username and realm.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true or false depending on whether objects are equal or not
equals
(Object
the object to compare this instance of HttpPrincipal against
another
)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Compare two instances of HttpPrincipal.

public String

Returns:

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

Implements java.security.Principal.getName.

Returns the contents of this principal in the form realm:username.

public String

Returns:

the realm associated with this object
getRealm
()

Returns the realm this object was created with.

public String

Returns:

the name of the user associated with this object
getUsername
()

Returns the username this object was created with.

public int

Returns:

the hashcode for this object
hashCode
()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

Returns a hashcode for this HttpPrincipal.

public String

Returns:

the name associated with this object
toString
()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Returns the same string as getName().

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

realmback to summary
private String realm
usernameback to summary
private String username

Constructor Detail

HttpPrincipalback to summary
public HttpPrincipal(String username, String realm)

Creates a HttpPrincipal from the given username and realm.

Parameters
username:String

the name of the user within the realm

realm:String

the realm for this user

Exceptions
NullPointerException:
if either username or realm are null

Method Detail

equalsback to summary
public boolean equals(Object another)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Compare two instances of 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.

Parameters
another:Object

the object to compare this instance of HttpPrincipal against

Returns:boolean

true or false depending on whether objects are equal or not

getNameback to summary
public String getName()

Implements java.security.Principal.getName.

Returns the contents of this principal in the form realm:username.

Returns:String

the contents of this principal in the form realm:username

getRealmback to summary
public String getRealm()

Returns the realm this object was created with.

Returns:String

the realm associated with this object

getUsernameback to summary
public String getUsername()

Returns the username this object was created with.

Returns:String

the name of the user associated with this object

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

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

Returns:int

the hashcode for this object

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Returns the same string as getName().

Returns:String

the name associated with this object