Class EjwsPrincipal

All Implemented Interfaces:
Principal

public class EjwsPrincipal extends HttpPrincipal
Class representing an embedded web-server principal. This class extends 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 Details

    • EjwsPrincipal

      public EjwsPrincipal(String username, String realm)
      Constructor.
      Parameters:
      username - the user name
      realm - the HTTP realm
    • EjwsPrincipal

      public EjwsPrincipal(HttpPrincipal p, Set<String> roles)
      Constructor based on another principal, but specifying roles.
      Parameters:
      p - the original principal
      roles - the roles for this principal
    • EjwsPrincipal

      public EjwsPrincipal(String username, String realm, Set<String> roles)
      Constructor specifying a realm and roles.
      Parameters:
      username - the user name
      realm - the HTTP realm
      roles - the roles for this user
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface Principal
      Overrides:
      getName in class HttpPrincipal
    • getRoles

      public Set<String> getRoles()
      Get the roles for this principal.
      Returns:
      the roles (set at the time this object was created)