Class ServerAppConfig

java.lang.Object
com.iizix.prop.GProp<GProp<?>[]>
com.iizix.prop.PropCnr
com.iizix.server.prop.ServerAppConfig
All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, Cloneable
Direct Known Subclasses:
EditorServerAppConfig

public class ServerAppConfig extends PropCnr
Property container for the configuration of an App of the iiziServer: its definition (CC-FIX-APP-DEFINITIONS). The atom name of the container is the application ID; the entry holds the jar file name, the aliases, the description (Atom.DESCR), the groups and the ports.

The property container parent is the ServerAppConfigs container of a ServerConfigEnvProps instance: the environment owns its applications. An application ID and every alias is unique among ALL IDs and aliases of ALL environments of the server configuration (a server runs several environments at once and an application reference carries no environment); ServerSettings.verify reports a duplicate, and the server does not start with one.

At the server's start every -app <id>[:alias...] -appjar <file> of the command line is added to the configuration IN MEMORY (not saved, isFromCommandLine()) unless the file already defines the application - the file wins, the command line's definition is logged INFO and ignored - and then ALL applications are loaded from the configuration, one path. An application loaded from Module project directories (-project, the debug server) is never written into the configuration; an entry of its ID carries its settings (groups, ports).

The groups of the configuration are the access rule of the application (T1-139, CC-SERVER-USERS-APP-ACCESS): a user signs in to the application only by an ENABLED group that is one of them, or by an enabled group that allows all applications (GroupInfo.areAllAppsAllowed()) - refusal(BasicUserInfo), applied by UserAuthentication.validateUser at every successful answer for an application. The configuration of a loaded application is found by of(AppFactory); an application that has none admits every user.

  • Field Details

    • FILENAME

      public static final String FILENAME
      File name to application (Jar file name or directory path containing ".iiziModuleProject" file).
      See Also:
    • GROUPS

      public static final String GROUPS
      The groups of this app.
      See Also:
    • ALIASES

      public static final String ALIASES
      The aliases of this app: a comma-separated list of application IDs that name this application besides its ID (the atom name of this container), e.g. in /app/<alias>/ and app=<alias>. Each alias is a valid application ID (IServer.validateAppID(String)) and unique among all IDs and aliases of the server configuration; the command line's -app id:alias1:alias2 form gives the same aliases.
      See Also:
    • PORTS

      public static final String PORTS
      The port configurations this application is served on: a comma-separated list of port configuration names (WebServerPortConfig.NAME, by default a configuration's atom name, case-sensitive like every property name). The deployment decides, not the application module. An application that has NO ServerAppConfig entry - for instance an application loaded from a database in a distributed deployment, where server-local port configuration names make no sense - is served on ALL port configurations. Empty or absent ports = all ports (the default). A name that matches no port configuration matches nothing: the application is not served there, and never on all ports instead (fail closed). Module end points, such as /iizi/MLS.ws, are not applications and are outside this rule.
      See Also:
    • KEY_GOOGLE_MAPS

      public static final String KEY_GOOGLE_MAPS
      The Google Maps key of this application for Browser clients, set by the deployment (CC-FIX-MAPS-KEY-SERVER): an optional override, for this application alone, of the key of the application's distribution and of the environment's key. The server hands it to the application's distribution properties when the application is loaded (AppDefinition), where the map component reads it first; the environment's key is the fallback of both. Set in ServerAdmin's application page or in the file.
      See Also:
  • Constructor Details

    • ServerAppConfig

      public ServerAppConfig()
      Creates the App configuration without a name. The name must be set in all cases using the setPropertyAtom call.
    • ServerAppConfig

      public ServerAppConfig(Atom atom)
      Creates the App configuration with a name.
      Parameters:
      atom - The name of the property.
  • Method Details

    • getServerDirectory

      public File getServerDirectory()
      Gets the base server directory (current directory for server).
      Returns:
      The directory of the server.
    • onPropInvalidateCache

      protected void onPropInvalidateCache()
      Cache invalidation required.
      Overrides:
      onPropInvalidateCache in class GProp<GProp<?>[]>
    • clone

      public ServerAppConfig clone()
      Clones the instance.
      Overrides:
      clone in class PropCnr
      Returns:
      The cloned instance.
    • getFileName

      public String getFileName()
      Gets the file name to application (Jar file name or directory path containing ".iiziModuleProject" file).
      Returns:
      The path, or null if not defined.
    • getDescription

      public String getDescription()
      Gets the description of the App configuration.
      Returns:
      The description, or null if not defined.
    • getServerConfigEnvironment

      public ServerConfigEnvProps getServerConfigEnvironment()
      Gets the server configuration environment that owns this application definition.
      Returns:
      The environment, or null when the definition is not inside one.
    • getAppID

      public String getAppID()
      Gets the application ID: the atom name of this definition.
      Returns:
      The application ID.
    • isFromCommandLine

      public boolean isFromCommandLine()
      Checks if this definition was added in memory from the command line at the server's start (CC-FIX-APP-DEFINITIONS): such an entry is editable in ServerAdmin like one of the file and is written into the file when the configuration is saved.
      Returns:
      true for an entry merged from the command line, false for one of the file.
    • markFromCommandLine

      public void markFromCommandLine()
      Marks this definition as added in memory from the command line.
    • getAliasesString

      public String getAliasesString()
      Gets the aliases of this app.
      Returns:
      The aliases separated by commas, null for none.
    • getAliasNames

      public String[] getAliasNames()
      Gets the alias names array of this app: trimmed, empty names dropped, duplicates dropped (case-sensitive, as application IDs are).
      Returns:
      An array of unique alias names, empty for none.
    • getPortsString

      public String getPortsString()
      Gets the port configuration names of this app.
      Returns:
      The port configuration names separated by commas, null for none (= all ports).
    • getPortNames

      public String[] getPortNames()
      Gets the port configuration names array of this app: trimmed, empty names dropped, duplicates dropped (case-sensitive, like every property name).
      Returns:
      An array of unique port configuration names, empty for none (= served on all ports).
    • getGroupsString

      public String getGroupsString()
      Gets the app groups associated.
      Returns:
      The app groups separated by commas, null for none.
    • getKeyGoogleMaps

      public String getKeyGoogleMaps()
      Gets the Google Maps key of this application for Browser clients (CC-FIX-MAPS-KEY-SERVER).
      Returns:
      The key, or null for none (the application's distribution key, else the environment's, applies).
    • getGroupNames

      public String[] getGroupNames()
      Gets the group names array associated with this app.
      Returns:
      An array of unique group names.
    • getGroups

      public GroupInfo[] getGroups(boolean reload) throws NotFoundException, SQLException
      Gets the groups for this app.
      Parameters:
      reload - Flag to reload the group informations from the database.
      Returns:
      The groups for this app.
      Throws:
      NotFoundException - If a group is not found.
      SQLException - For SQL errors.
    • of

      public static ServerAppConfig of(AppFactory appFactory)
      Finds the configuration of a loaded application: the definition named as the application ID in the ServerAppConfigs container of the server configuration environment the application runs in.
      Parameters:
      appFactory - The application.
      Returns:
      The configuration, or null when the application has none - an application loaded from Module project directories (-project) or from IZS.APPS without one, which admits every user and is served on every port configuration.
    • find

      public static ServerAppConfig find(ServerConfigEnvProps env, String appID)
      Finds the configuration of an application in a server configuration environment: the entry of that ID in the environment's ServerAppConfigs container, or, when the container holds none, a definition added directly to the environment at run time (a test, ServerAdmin's Add page until it writes into the container). An alias is not looked up.
      Parameters:
      env - The environment, null for none.
      appID - The application ID.
      Returns:
      The configuration, or null when the environment holds none of that name.
    • isServedOn

      public boolean isServedOn(String portConfigName)
      Decides whether this application is served on a port configuration, by name: served when its ports list is empty or absent, else only when the name is in the list (case-sensitive). A null name - a connector built without a configuration name - is in no list.
      Parameters:
      portConfigName - The name of the port configuration the request arrived on, null for none.
      Returns:
      true when served, false when refused.
    • isServedOn

      public static boolean isServedOn(String[] portNames, String portConfigName)
      The rule of isServedOn(String) on the names already split, so that its table of cases can be proven without a configuration.
      Parameters:
      portNames - The port configuration names of the application, empty for all ports.
      portConfigName - The name of the port configuration the request arrived on, null for none.
      Returns:
      true when served, false when refused.
    • isServedOn

      public static boolean isServedOn(AppFactory app, PortConfig portConfig)
      The gate: decides whether a loaded application is served on the port configuration a request arrived on (PR-3: the LISTENING port configuration only, never the Host header). An application without a definition is served on every port configuration (PR-11); a request whose connector carries no port configuration (HTTP/3 before CC-FIX-APP-DEFINITIONS, a test server without one) is served only by an application whose ports list is empty (D-19, fail closed); a name that matches no configuration matches nothing (PR-6).
      Parameters:
      app - The application, null for an unknown one - which is never served.
      portConfig - The port configuration of the request's connector, null for none.
      Returns:
      true when served, false when refused: the caller answers as it answers an unknown application ID (PR-4).
    • refusal

      public String refusal(BasicUserInfo user) throws SQLException
      Decides whether a user may use the application of this configuration, by the user's groups (T1-139): admitted when some ENABLED group of the user allows all applications (GroupInfo.areAllAppsAllowed()), or is one of the groups configured here - the wildcard "*" standing for every group, so that any enabled group admits. A configuration that names no group admits the "all apps" groups only; a configured name that is no group of the server admits nobody, and the reason says so: the verification of the settings flags it, and the administrator corrects it. A disabled group grants nothing, as everywhere. The groups are read from the database on every call: a sign-in is where the decision is taken, and a group disabled since must count.
      Parameters:
      user - The user, as read from the database.
      Returns:
      null when admitted, otherwise the reason of the refusal, for the log - never for the client, which is answered SigninResult.APP_ACCESS_DENIED.
      Throws:
      SQLException - For SQL errors reading the groups.
    • refusal

      public static String refusal(String appID, GroupInfo[] allowed, String userName, GroupInfo[] groups)
      The rule of refusal(BasicUserInfo) on groups already read, so that its table of cases can be proven without a database.
      Parameters:
      appID - The application ID, for the reason.
      allowed - The groups the application allows, resolved: every group of the server for the wildcard, none for a configuration that names no group.
      userName - The user name, for the reason.
      groups - The groups of the user.
      Returns:
      null when admitted, otherwise the reason of the refusal, naming the application, the user, the groups allowed and the user's groups.
    • verify

      public boolean verify(PropVerification verification)
      Verifies this property container. The check performed is the extension of classes and that no circular reference is present.
      Specified by:
      verify in interface IGProp<GProp<?>[]>
      Overrides:
      verify in class PropCnr
      Parameters:
      verification - The property verification class.
      Returns:
      true if verification should proceed, false if disposed of and verification should not take place.