Class HttpPrincipal
- java.lang.Object
-
- 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.
Constructors
Constructor | Description |
---|---|
HttpPrincipal(String username,
String realm) | creates a HttpPrincipal from the given username and realm |
Methods
Modifier and Type | Method | Description |
---|---|---|
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 declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods declared in interface java.security.Principal
implies
Constructors
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
Methods
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 interfacePrincipal
- Overrides:
-
equals
in classObject
- Parameters:
-
another
- the reference object with which to compare. - Returns:
-
true
if this object is the same as the obj argument;false
otherwise. - See Also:
-
Object.hashCode()
,HashMap
getName
public String getName()
returns the contents of this principal in the form realm:username
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 interfacePrincipal
- Overrides:
-
hashCode
in classObject
- Returns:
- a hash code value for this object.
- See Also:
-
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
toString
public String toString()
returns the same string as getName()
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/jdk.httpserver/com/sun/net/httpserver/HttpPrincipal.html