Class ExternalBrowserPagesImpl

java.lang.Object
com.iizix.server.devel.ExternalBrowserPagesImpl
All Implemented Interfaces:
IExternalBrowserPages

public class ExternalBrowserPagesImpl extends Object implements IExternalBrowserPages
Class to handle external web pages with embedded Jetty.
Author:
Christopher Mindus
  • Constructor Details

    • ExternalBrowserPagesImpl

      public ExternalBrowserPagesImpl(ServerShell server)
      Constructor.
  • Method Details

    • doAuthenticate

      public boolean doAuthenticate(PortConfig portConfig, String target)
      Checks if a request URL is a WebSocket request or an Application URI that should not use authentication.
      Specified by:
      doAuthenticate in interface IExternalBrowserPages
      Parameters:
      portConfig - The port configuration.
      target - The target URI.
      Returns:
      true if authentication should be performed, false otherwise.
    • getFileOrResource

      public Object getFileOrResource(String location, String target)
      Gets a File or Resource redirection from a web server target request, used for e.g. Asset resource files when used on the server and the file is inside a Jar.
      Specified by:
      getFileOrResource in interface IExternalBrowserPages
      Parameters:
      location - The location string between '/$' and '$/'
      target - The target string from the Web Server after last '$/' (i.e. after location), does NOT begin with '/'.
      Returns:
      The File or instance of Resource for the resource, null for none.
    • registerRequestPrinter

      public boolean registerRequestPrinter(String target, IWebServerRequestPrinter processor)
      Registers a new request printer.
      Parameters:
      target - The target URL, always starting with "/" and doesn't contain the query.
      processor - The print processor.
      Returns:
      true if added successfully, false if the print processor already exists.
    • unregisterRequestPrinter

      public boolean unregisterRequestPrinter(String target, IWebServerRequestPrinter processor)
      Unregister a previously registered request printer.
      Parameters:
      target - The target URL, always starting with "/" and doesn't contain the query.
      processor - The print processor.
      Returns:
      true if removed successfully, false if the print processor does not exist or doesn't match.
    • isTargetValid

      public boolean isTargetValid(PortConfig portConfig, String target)
      Checks for valid target to handle.
      Specified by:
      isTargetValid in interface IExternalBrowserPages
      Parameters:
      portConfig - The port configuration.
      target - The target URI.
      Returns:
      true if target is processed as an external page, false otherwise.
    • print

      public void print(PortConfig portConfig, PrintWriter pw, String root, String target, HttpServletRequest request, HttpServletResponse response) throws IOException
      Print the page output.
      Specified by:
      print in interface IExternalBrowserPages
      Parameters:
      portConfig - The port configuration.
      pw - The print writer.
      root - The web server root.
      target - Target page.
      request - The request.
      response - The response.
      Throws:
      IOException - For I/O errors.
    • defaultLanguage

      public static String defaultLanguage(TextTable textTable, List<String> langs)
      Gets the language of an application's or a panel's default text table as the member defaultLang of app.json and panel.json carries it (CC-FIX-IIZIRUN-SETTINGS-FOLLOWUPS, SI-D-4, ruled 2026-10-29): the launcher's language chain (pickLanguage of jsr/comrun.js) takes it after the device language and before the first language offered. The code is written only when it is one of the languages offered (langs), so that the member never names a language the launch cannot start with; the comparison is exact, as the codes come from the same text tables. The iiziGo's panel.json writer (com.iizigo.comm.ExternalBrowserPagesImpl.addPanelData) calls this method too.
      Parameters:
      textTable - The default text table, or null for none.
      langs - The language codes offered, as the langs member lists them, or null.
      Returns:
      The language code as the text table spells it, or null when there is no default text table, its language code is not set, or the code is not offered.
    • getCustomizedAppHTML

      public File getCustomizedAppHTML(File file, String appID, String lang)
      Gets a customized "iiziApp.html" file for a specific application ID and optional language.
      Specified by:
      getCustomizedAppHTML in interface IExternalBrowserPages
      Parameters:
      file - The compressed iiziApp.html file without customization.
      appID - The application ID.
      lang - The language requested, or null for default.
      Returns:
      The customized (and probably cached) file to send instead of the un-customized one, or null for none, i.e. in case an application ID is not found.
    • getAppSorryInfo

      public BrowserGate.AppInfo getAppSorryInfo(String appID)
      Gets what iiziAppSorry.html shows for an application (CC-BROWSER-GATE): the name and the description of the app from its Module app settings, as the app list shows them, and the two store URLs from the App Distribution properties.
      Specified by:
      getAppSorryInfo in interface IExternalBrowserPages
      Parameters:
      appID - The application ID, never null nor empty.
      Returns:
      The information, or null for an unknown application.
    • getAppUIModes

      public String getAppUIModes(String appID)
      Gets the appearance modes an application allows a client to show (CC-THEME-DARK-V5): the uiModes choice of its App page, through the chain of getAppSorryInfo.
      Specified by:
      getAppUIModes in interface IExternalBrowserPages
      Parameters:
      appID - The application ID, never null nor empty.
      Returns:
      The choice (ModuleApp.getUIModes()) as UISchemes.modesValue(int) reads it, both for an unknown application.
    • getAppAnalytics

      public AppAnalytics.Settings getAppAnalytics(String appID)
      Gets the Web Analytics settings of an application (CC-ANALYTICS-CONSENT), for the line the servlet injects into iiziApp.html: the Measurement ID and the consent choice from its Module app settings, through the chain of getAppSorryInfo. Only a valid GA4 id is answered, so nothing from a property file reaches the page unchecked.
      Specified by:
      getAppAnalytics in interface IExternalBrowserPages
      Parameters:
      appID - The application ID, never null nor empty.
      Returns:
      The settings, or null for an unknown application or one without a valid Measurement ID.
    • getAppAnalytics

      public AppAnalytics.Settings getAppAnalytics(String appID, String lang)
      Gets the Web Analytics settings of an application for a language (CC-FIX-GA4-V5): the application through ServerShell.getApplication(String), its module application through the module settings, then appAnalytics(ModuleApp,String).
      Specified by:
      getAppAnalytics in interface IExternalBrowserPages
      Parameters:
      appID - The application ID, never null nor empty.
      lang - The language code of the request, null or empty for the default language.
      Returns:
      The settings, or null for an unknown application or one without a valid Measurement ID.
    • getAppDirectory

      public IAppDirectory getAppDirectory(String appID)
      Gets the virtual directory /app/appID/ of an application (CC-PWA-V5A-APPDIR-ROUTE): the segment is checked by IServer.validateAppID(String) first, so nothing a Browser sent that is not an application ID reaches the application table (design F-6); then the application, or the one its alias names, through ServerShell.getApplication(String).
      Specified by:
      getAppDirectory in interface IExternalBrowserPages
      Parameters:
      appID - The path segment after /app/, decoded, never null nor empty.
      Returns:
      The directory, or null for an invalid or unknown ID.
    • isAppRefusedOn

      public boolean isAppRefusedOn(String appID, PortConfig portConfig)
      Tells whether an application is refused on a port configuration (CC-FIX-APP-DEFINITIONS, PR-3/PR-4): ServerAppConfig.isServedOn(AppFactory,PortConfig) on the application ServerShell.getApplication(String) resolves - an unknown one is refused.
      Specified by:
      isAppRefusedOn in interface IExternalBrowserPages
      Parameters:
      appID - The application ID, or an alias.
      portConfig - The port configuration of the request's connector, null for none.
      Returns:
      true when refused, false when served.
    • isOriginAllowed

      public boolean isOriginAllowed(String origin, String requestHost)
      Tells whether a cross-origin page may read this server's responses (CC-FIX-SB-CORS): the server's WebSocket Origin allow-list decides, through ServerShell.isOriginAllowedForCORS(String, String).
      Specified by:
      isOriginAllowed in interface IExternalBrowserPages
      Parameters:
      origin - The request's Origin header field.
      requestHost - The host the request came to, may be null.
      Returns:
      true to grant the origin, false to refuse it.