Class AdminServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.netscape.cms.servlet.admin.AdminServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
ACLAdminServlet, AuthAdminServlet, CMSAdminServlet, JobsAdminServlet, LogAdminServlet, PolicyAdminServlet, RegistryAdminServlet, UsrGrpAdminServlet

public class AdminServlet extends javax.servlet.http.HttpServlet
A class represents an administration servlet that is responsible to serve administrative operation such as configuration parameter updates. Since each administration servlet needs to perform authentication information parsing and response formulation, it makes sense to encapsulate the commonalities into this class. By extending this serlvet, the subclass does not need to re-implement the request parsing code (i.e. authentication information parsing). If a subsystem needs to expose configuration parameters management, it should create an administration servlet (i.e. CAAdminServlet) and register it to RemoteAdmin subsystem. public class CAAdminServlet extends AdminServlet { ... }
Version:
$Revision$, $Date$
See Also:
  • Field Details

  • Constructor Details

    • AdminServlet

      public AdminServlet()
      Constructs generic administration servlet.
  • Method Details

    • init

      public void init(javax.servlet.ServletConfig sc) throws javax.servlet.ServletException
      Initializes the servlet.
      Specified by:
      init in interface javax.servlet.Servlet
      Overrides:
      init in class javax.servlet.GenericServlet
      Throws:
      javax.servlet.ServletException
    • outputHttpParameters

      public void outputHttpParameters(javax.servlet.http.HttpServletRequest httpReq)
    • service

      public void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException
      Serves HTTP admin request.
      Overrides:
      service in class javax.servlet.http.HttpServlet
      Throws:
      javax.servlet.ServletException
      IOException
    • authenticate

      protected void authenticate(javax.servlet.http.HttpServletRequest req) throws IOException
      Authenticates to the identity scope with the given userid and password via identity manager.

      • signed.audit LOGGING_SIGNED_AUDIT_AUTH_FAIL used when authentication fails (in case of SSL-client auth, only webserver env can pick up the SSL violation; CMS authMgr can pick up cert mis-match, so this event is used)
      • signed.audit LOGGING_SIGNED_AUDIT_AUTH_SUCCESS used when authentication succeeded
      Throws:
      IOException - an input/output error has occurred
    • getAuthCreds

      public static AuthCredentials getAuthCreds(AuthManager authMgr, X509Certificate clientCert) throws EBaseException
      Throws:
      EBaseException
    • authorize

      protected AuthzToken authorize(javax.servlet.http.HttpServletRequest req)
      Authorize must occur after Authenticate

      • signed.audit LOGGING_SIGNED_AUDIT_AUTHZ_FAIL used when authorization has failed
      • signed.audit LOGGING_SIGNED_AUDIT_AUTHZ_SUCCESS used when authorization is successful
      • signed.audit LOGGING_SIGNED_AUDIT_ROLE_ASSUME used when user assumes a role (in current CMS that's when one accesses a role port)
      Parameters:
      req - HTTP servlet request
      Returns:
      the authorization token
    • getLocale

      protected Locale getLocale(javax.servlet.http.HttpServletRequest req)
      Retrieves locale based on the request.
    • sendResponse

      protected void sendResponse(int returnCode, String errorMsg, NameValuePairs params, javax.servlet.http.HttpServletResponse resp) throws IOException
      Sends response.
      Parameters:
      returnCode - return code
      errorMsg - localized error message
      params - result parameters
      resp - HTTP servlet response
      Throws:
      IOException
    • URLdecode

      protected String URLdecode(String s)
      URL decodes the given string.
    • getParameter

      protected String getParameter(javax.servlet.http.HttpServletRequest req, String name)
    • getConfig

      protected void getConfig(ConfigStore config, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException, EBaseException
      Generic configuration store get operation.
      Throws:
      javax.servlet.ServletException
      IOException
      EBaseException
    • setConfig

      protected void setConfig(ConfigStore config, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException, EBaseException
      Generic configuration store set operation. The caller is responsible to do validiation before calling this, and commit changes after this call.
      Throws:
      javax.servlet.ServletException
      IOException
      EBaseException
    • listConfig

      protected void listConfig(ConfigStore config, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException, EBaseException
      Lists configuration store.
      Throws:
      javax.servlet.ServletException
      IOException
      EBaseException
    • authorize

      public boolean authorize(IAuthToken token) throws EBaseException
      authorize a user based on its authentication credentials.
      Throws:
      EBaseException
    • commit

      protected void commit(boolean createBackup) throws EBaseException
      FileConfigStorage functionality The original config file is moved to .. Commits the current properties to the configuration file.

      Parameters:
      createBackup - true if a backup file should be created
      Throws:
      EBaseException
    • audit

      protected void audit(String msg)
      Signed Audit Log This method is inherited by all extended admin servlets and is called to store messages to the signed audit log.

      Parameters:
      msg - signed audit log message
    • audit

      protected void audit(LogEvent event)
    • auditSubjectID

      protected String auditSubjectID()
      Signed Audit Log Subject ID This method is inherited by all extended "CMSServlet"s, and is called to obtain the "SubjectID" for a signed audit log message.

      Returns:
      id string containing the signed audit log message SubjectID
    • auditParams

      protected String auditParams(javax.servlet.http.HttpServletRequest req)
      Signed Audit Parameters This method is inherited by all extended admin servlets and is called to extract parameters from the HttpServletRequest and return a string of name;;value pairs separated by a '+' if more than one name;;value pair exists.

      Parameters:
      req - HTTP servlet request
      Returns:
      a delimited string of one or more delimited name/value pairs
    • convertStringArrayToNVPairs

      protected NameValuePairs convertStringArrayToNVPairs(String[] s)
    • getClassByNameAsExtendedPluginInfo

      protected static IExtendedPluginInfo getClassByNameAsExtendedPluginInfo(String className)