From 146a0fb8b0e90f9196e569152f649baf60d6cc8f Mon Sep 17 00:00:00 2001
From: Joaquín Reñé <jrene@curisit.net>
Date: Tue, 07 Oct 2025 14:52:57 +0000
Subject: [PATCH] #4410 - Comments on classes

---
 securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java |  112 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 96 insertions(+), 16 deletions(-)

diff --git a/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java b/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java
index 8cdfa22..5bc1ef4 100644
--- a/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java
+++ b/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java
@@ -1,3 +1,6 @@
+/*
+* Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved.
+*/
 package net.curisit.securis.ioc;
 
 import java.io.File;
@@ -18,6 +21,25 @@
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
 
+/**
+* SecurisModule
+* <p>
+* Guice module that provides application-level infrastructural dependencies
+* (base URI, app directories, DB files list, support email/hash, etc.).
+* <p>
+* Configuration:
+* - Reads server port from /securis-server.properties (key: "port").
+* - Defaults to port 9997 when not present or on read errors.
+* - Constructs base URI as http://0.0.0.0:{port}/ with UriBuilder.
+* - Creates working directories under ${user.home}/.SeCuris on demand.
+*
+* Security note:
+* - getPassword/getFilePassword are simple helpers; secrets should be
+*   managed via a secure vault/env vars in production.
+*
+* @author JRA
+* Last reviewed by JRA on Oct 7, 2025.
+*/
 public class SecurisModule extends AbstractModule {
 
     private static final int DEFAULT_PORT = 9997;
@@ -25,28 +47,51 @@
 
     private static final Logger LOG = LogManager.getLogger(SecurisModule.class);
 
+    /** configure<p>Currently no explicit bindings; providers below supply instances. */
     @Override
-    protected void configure() {
+    protected void configure() { }
 
-    }
-
+    /**
+    * getPassword<p>
+    * Composite password (example use with encrypted H2 URL).
+    *
+    * @return concatenated password string
+    */
     public String getPassword() {
         return getFilePassword() + " " + "53curi5";
     }
 
+    /**
+    * getFilePassword<p>
+    * Standalone file password (for H2 CIPHER).
+    *
+    * @return file password string
+    */
     public String getFilePassword() {
         return "cur151T";
     }
 
+    /**
+    * getUrl<p>
+    * H2 JDBC URL with AES cipher pointing to {appDir}/db/securis.
+    *
+    * @param appDir application working directory
+    * @return JDBC URL (H2)
+    */
     public String getUrl(File appDir) {
         return String.format("jdbc:h2:%s/db/securis;CIPHER=AES", appDir.getAbsolutePath());
     }
 
+    /**
+    * getBaseURI<p>
+    * Provide the base URI for the HTTP server using configured or default port.
+    *
+    * @return base URI (http://0.0.0.0:{port}/)
+    */
     @Named("base-uri")
     @Provides
     @ApplicationScoped
     public URI getBaseURI() {
-        // Read from configuration, where?
         try {
             String url = MessageFormat.format("http://{0}/", "0.0.0.0");
             LOG.debug("Server url{}", url);
@@ -56,33 +101,46 @@
         }
     }
 
+    /**
+    * getPort<p>
+    * Read port from properties file or return default.
+    *
+    * @return HTTP port
+    */
     private int getPort() {
         Integer port;
         Properties prop = new Properties();
         try {
             prop.load(getClass().getResourceAsStream(PROPERTIES_FILE_NAME));
             port = Integer.valueOf(prop.getProperty("port"));
-            if (port == null) {
-                return DEFAULT_PORT;
-            } else {
-                return port;
-            }
+            return (port == null ? DEFAULT_PORT : port);
         } catch (Exception ex) {
             return DEFAULT_PORT;
         }
     }
 
+    /**
+    * getAppDbFiles<p>
+    * List of SQL files to initialize the application DB.
+    *
+    * @return list of classpath resource paths
+    */
     protected List<String> getAppDbFiles() {
-
         return Arrays.asList("/db/schema.sql");
     }
 
+    /**
+    * getTemporaryDir<p>
+    * Provide a temp directory inside the app working dir (.TEMP).
+    * Creates it if missing and marks for deletion on exit.
+    *
+    * @return temp directory or null if creation failed
+    */
     @Named("temporary-dir")
     @Provides
     @ApplicationScoped
     public File getTemporaryDir() {
-        String tmp = getAppDir().getAbsolutePath();
-        tmp += File.separator + ".TEMP";
+        String tmp = getAppDir().getAbsolutePath() + File.separator + ".TEMP";
         File ftmp = new File(tmp);
         if (!ftmp.exists()) {
             if (!ftmp.mkdirs()) {
@@ -94,14 +152,18 @@
         return ftmp;
     }
 
+    /**
+    * getAppDir<p>
+    * Provide the app working directory under ${user.home}/.SeCuris (creates if missing).
+    *
+    * @return working directory or null if creation failed
+    */
     @Named("app-dir")
     @Provides
     @ApplicationScoped
     public File getAppDir() {
         String appDir = System.getProperty("user.home", System.getProperty("user.dir"));
-        if (appDir == null) {
-            appDir = ".";
-        }
+        if (appDir == null) appDir = ".";
         appDir += File.separator + ".SeCuris";
         File fAppDir = new File(appDir);
         if (!fAppDir.exists()) {
@@ -113,6 +175,12 @@
         return fAppDir;
     }
 
+    /**
+    * getSupportEmail<p>
+    * Provide support email address.
+    *
+    * @return email
+    */
     @Named("support-email")
     @Provides
     @ApplicationScoped
@@ -120,6 +188,12 @@
         return "support@curisit.net";
     }
 
+    /**
+    * getHashLogo<p>
+    * Provide a static content hash for the logo (cache-busting or integrity).
+    *
+    * @return hex SHA-256
+    */
     @Named("hash-logo")
     @Provides
     @ApplicationScoped
@@ -127,11 +201,17 @@
         return "1b42616809d4cd8ccf109e3c30d0ab25067f160b30b7354a08ddd563de0096ba";
     }
 
+    /**
+    * getDbFiles<p>
+    * Provide DB initialization files list (delegates to {@link #getAppDbFiles()}).
+    *
+    * @return list of SQL resource paths
+    */
     @Named("db-files")
     @Provides
     @ApplicationScoped
     public List<String> getDbFiles() {
         return getAppDbFiles();
     }
-
 }
+

--
Gitblit v1.3.2