- All Implemented Interfaces:
Principal
HttpPrincipal
by adding a set of roles.
For HttpPrincipal
, an identity is a user name in a name space
called a "realm". The method HttpPrincipal.getName()
will
return the realm and the user name separated by a colon. The method
HttpPrincipal.getUsername()
returns the user name alone.
A common convention is for the user name to be an email address as this
typically identifies a user uniquely.
Web servers use realms so that multiple independent web sites or web applications running on the same server can have their own name space and passwords for identifying users. Frequently, in an embedded web server, there will be only a single realm.
The EJWS package adds roles, which typically would be used to denote various capabilities. It is useful when EJWS is used with a database that supports SQL roles. Also, the Jakarta Servlet API Documentation contains a method (isUserInRole) that can determine if a user has been assigned a specified role, so supporting roles is useful if code has to migrate from an EJWS server to a full-featured web server that supports Servlets. Keep in mind that the Servlet specification places some restrictions on role names. These are not checked by this class or other EJWS classes.
-
Constructor Summary
ConstructorsConstructorDescriptionEjwsPrincipal
(HttpPrincipal p, Set<String> roles) Constructor based on another principal, but specifying roles.EjwsPrincipal
(String username, String realm) Constructor.EjwsPrincipal
(String username, String realm, Set<String> roles) Constructor specifying a realm and roles. -
Method Summary
Methods inherited from class com.sun.net.httpserver.HttpPrincipal
equals, getRealm, getUsername, hashCode, toString
-
Constructor Details
-
EjwsPrincipal
Constructor.- Parameters:
username
- the user namerealm
- the HTTP realm
-
EjwsPrincipal
Constructor based on another principal, but specifying roles.- Parameters:
p
- the original principalroles
- the roles for this principal
-
EjwsPrincipal
Constructor specifying a realm and roles.- Parameters:
username
- the user namerealm
- the HTTP realmroles
- the roles for this user
-
-
Method Details
-
getName
- Specified by:
getName
in interfacePrincipal
- Overrides:
getName
in classHttpPrincipal
-
getRoles
Get the roles for this principal.- Returns:
- the roles (set at the time this object was created)
-