=== modified file 'src/com/goldencode/p2j/admin/server/AdminRestHandler.java'
--- old/src/com/goldencode/p2j/admin/server/AdminRestHandler.java	2025-04-09 20:13:21 +0000
+++ new/src/com/goldencode/p2j/admin/server/AdminRestHandler.java	2025-04-14 10:25:32 +0000
@@ -94,7 +94,7 @@
  * </ul>
  */
 public class AdminRestHandler
-extends HandlerCollection
+extends ContextHandler
 {
    /** Logger */
    private static final CentralLogger LOG = CentralLogger.get(AdminRestHandler.class);
@@ -102,9 +102,6 @@
    /** The handler used for authentication and authorization. */
    protected final WebAuthHandler authHandler;
    
-   /** The context handler. */
-   private final ContextHandler handler;
-   
    /** The singleton which handles tenant REST requests. */
    private static AdminRestHandler instance;
    
@@ -116,9 +113,8 @@
       // authHandler is used to authenticate all calls to specialized BaseAdminRestHandler classes
       authHandler = new WebAuthHandler("admin", "basic", "/admin/login", "/admin/logout", timeout);
       
-      handler = new ContextHandler(CONTEXT_PREFIX);
-      handler.setAllowNullPathInfo(true);
-      handler.setHandler(this);
+      this.setContextPath(CONTEXT_PREFIX);
+      this.setAllowNullPathInfo(true);
    }
    
    /**
@@ -128,7 +124,7 @@
     * @return  An instance of {@link AdminRestHandler} on success or {@code null} if the directory is not
     *          configured with a REST handler for tenant administration.
     */
-   public static AdminRestHandler initialize()
+   public static HandlerCollection initialize()
    {
       if (!Utils.getDirectoryNodeBoolean(null, "admin-rest/enabled", false, false))
       {
@@ -137,10 +133,14 @@
       
       synchronized (AdminRestHandler.class)
       {
+         HandlerCollection res = null;
          if (instance == null)
          {
             instance = new AdminRestHandler(
                   Utils.getDirectoryNodeInt(null, "admin-rest/timeout", 3600, false));
+
+            res = new HandlerCollection();
+            res.addHandler(instance);
             
             String crtPackage = AdminRestHandler.class.getPackage().getName();
             Reflections reflections = new Reflections(
@@ -183,24 +183,14 @@
                   continue;
                }
                
-               instance.addHandler((BaseAdminRestHandler) result);
+               res.addHandler((BaseAdminRestHandler) result);
             }
          }
          
-         return instance.getHandlers().length == 0 ? null : instance;
+         return res.getHandlers().length == 0 ? null : res;
       }
    }
-   
-   /**
-    * Obtain the {@link ContextHandler}, if one was created by the initialization process.
-    *
-    * @return  the current the {@link ContextHandler}.
-    */
-   public org.eclipse.jetty.server.Handler getHandler()
-   {
-      return handler;
-   }
-   
+
    /**
     * Method for handling the requests. Will perform checking, authentication and authorization before
     * dispatching the execution to proper method/verb.
@@ -215,10 +205,10 @@
     *          The response as the {@link Response} object or a wrapper of that request.
     */
    @Override
-   public void handle(String target,
-                      Request baseRequest,
-                      HttpServletRequest request,
-                      HttpServletResponse response)
+   public void doHandle(String target,
+                        Request baseRequest,
+                        HttpServletRequest request,
+                        HttpServletResponse response)
    throws IOException, ServletException
    {
       // quick validation
@@ -239,14 +229,14 @@
          target = target.substring(0, target.length() - 1);
       }
       
-      // process only the know context subtree
-      if (!target.startsWith(CONTEXT_PREFIX))
+      // /admin is processing only /login and /logout in this handler
+      if (!(target.equals("/login") || target.equals("/logout")))
       {
          return;
       }
       
       // authentication. The authorization will be done by each AdminRestHandler child:
-      authHandler.handle(target, baseRequest, request, response);
+      authHandler.handle(getContextPath() + target, baseRequest, request, response);
       if (baseRequest.isHandled())
       {
          return; // authentication done, nothing else to do

=== modified file 'src/com/goldencode/p2j/admin/server/BaseAdminRestHandler.java'
--- old/src/com/goldencode/p2j/admin/server/BaseAdminRestHandler.java	2025-04-02 14:12:29 +0000
+++ new/src/com/goldencode/p2j/admin/server/BaseAdminRestHandler.java	2025-04-14 10:28:18 +0000
@@ -89,14 +89,11 @@
  * {@code handleDelete()}.
  */
 public abstract class BaseAdminRestHandler
-extends AbstractHandler
+extends ContextHandler
 {
    /** Logger */
    private static final CentralLogger LOG = CentralLogger.get(BaseAdminRestHandler.class);
    
-   /** The URL path it will handle.*/
-   protected final String contextPath;
-   
    /** The handler used for authentication and authorization. */
    protected final WebAuthHandler authenticationHandler;
    
@@ -118,7 +115,7 @@
    {
       this.wsm = SecurityManager.getInstance().legacyWebSm;
       this.authenticationHandler = authenticationHandler; 
-      this.contextPath = contextPath;
+      this.setContextPath(contextPath);
    }
    
    /**
@@ -135,11 +132,12 @@
     *          The response as the {@link Response} object or a wrapper of that request.
     */
    @Override
-   public void handle(String target,
-                      Request baseRequest,
-                      HttpServletRequest request,
-                      HttpServletResponse response)
-   throws IOException, ServletException
+   public void doHandle(String target,
+                        Request baseRequest,
+                        HttpServletRequest request,
+                        HttpServletResponse response)
+   throws IOException, 
+          ServletException
    {
       // quick validation
       if (baseRequest.isHandled()) // already handled by other handler?
@@ -152,16 +150,17 @@
          response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
          return;
       }
-      else if (!target.startsWith(contextPath))
-      {
-         return; // not my business
-      }
       
       baseRequest.setHandled(true);
       response.setContentType("application/json");
       
+      if (target.endsWith("/"))
+      {
+         target = target.substring(0, target.length() - 1);
+      }
       // check authorization:
-      String token = authenticationHandler.authorize(target, request, response);
+      String cpath = getContextPath();
+      String token = authenticationHandler.authorize(cpath + target, request, response);
       if (token == null)
       {
          response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
@@ -169,8 +168,6 @@
       }
       
       String body = request.getReader().lines().collect(Collectors.joining());
-      target = trimContextPrefix(target);
-      
       switch (baseRequest.getMethod())
       {
          case "GET":
@@ -360,30 +357,7 @@
          return false;
       }
    }
-   
-   /**
-    * Cleaning up the target by removing the context path. This information is not useful since all requests
-    * dispatched to this handler are filtered to match this prefix.
-    */
-   private String trimContextPrefix(String originalTarget)
-   {
-      if (!originalTarget.startsWith(contextPath))
-      {
-         LOG.warning(
-               "Invalid context received '" + originalTarget + "'. Was expecting '" + contextPath + "'.");
-         return originalTarget;
-      }
-      
-      String newTarget = originalTarget.substring(contextPath.length());
-      
-      // drop the starting "/" if any:
-      if (newTarget.startsWith("/"))
-      {
-         newTarget = newTarget.substring(1);
-      }
-      return newTarget;
-   }
-   
+
    /**
     * Parse a JSON and extract the value (String, int or boolean for the moment) of a given field.
     *

=== modified file 'src/com/goldencode/p2j/main/StandardServer.java'
--- old/src/com/goldencode/p2j/main/StandardServer.java	2025-04-04 08:58:01 +0000
+++ new/src/com/goldencode/p2j/main/StandardServer.java	2025-04-14 10:17:36 +0000
@@ -1710,7 +1710,7 @@
                boolean virtualDesktop = false;
                boolean ssoEnabled = SecurityManager.getInstance().ssoSm.isSsoEnabled();
                boolean embedded = false;
-               AdminRestHandler adminHandle;
+               HandlerCollection adminHandle;
                
                if (ssoEnabled && ConfigItem.EMBEDDED.read(false))
                {

