changeset 9747:cfc0aab9947f 3.2.x

Enable bind-mounting client configuration in docker container
author Tom Gottfried <tom@intevation.de>
date Mon, 05 Sep 2022 17:55:32 +0200
parents 1a1e627b1483
children edaae6f76fc7
files docker/Dockerfile.gwt-client docker/README docker/docker-compose.yml gwt-client/config/context.xml gwt-client/config/features.xml gwt-client/config/mapfish/config.yaml gwt-client/config/mapfish/images/FLYS_Logo.png gwt-client/config/mapfish/images/bfg_logo.gif gwt-client/config/mapfish/images/north.png gwt-client/config/mapfish/images/white.png gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java gwt-client/src/main/java/org/dive4elements/river/client/server/SamlServlet.java gwt-client/src/main/java/org/dive4elements/river/client/server/auth/was/Authenticator.java gwt-client/src/main/webapp/WEB-INF/config.yaml gwt-client/src/main/webapp/WEB-INF/features.xml gwt-client/src/main/webapp/WEB-INF/web.xml gwt-client/src/main/webapp/images/FLYS_Logo.png gwt-client/src/main/webapp/images/north.png gwt-client/src/main/webapp/images/white.png
diffstat 19 files changed, 315 insertions(+), 298 deletions(-) [+]
line wrap: on
line diff
--- a/docker/Dockerfile.gwt-client	Tue Aug 30 15:02:10 2022 +0200
+++ b/docker/Dockerfile.gwt-client	Mon Sep 05 17:55:32 2022 +0200
@@ -41,6 +41,8 @@
 
 # Configure tomcat
 RUN sed -i '/Connector port="8080"/a \URIEncoding="UTF-8"' /etc/tomcat/server.xml
+RUN ln -sf /opt/d4e/river/gwt-client/config/context.xml /etc/tomcat
+VOLUME /opt/d4e/river/gwt-client/config
 
 USER tomcat
 ADD docker/flys_user_file /usr/share/tomcat/
--- a/docker/README	Tue Aug 30 15:02:10 2022 +0200
+++ b/docker/README	Mon Sep 05 17:55:32 2022 +0200
@@ -3,7 +3,7 @@
   artifacts/doc/conf/floodmap.xml and artifacts/doc/conf/rivermap.xml
 _ Change 'example.com' to the hostname of your docker host plus ':8082' in
   artifacts/doc/conf/conf.xml
-_ Add to gwt-client/src/main/webapp/WEB-INF/config.yaml to enable map printing:
+_ Add to gwt-client/config/mapfish/config.yaml to enable map printing:
   - !dnsMatch
     host: <your-host>
     port: 8081
--- a/docker/docker-compose.yml	Tue Aug 30 15:02:10 2022 +0200
+++ b/docker/docker-compose.yml	Mon Sep 05 17:55:32 2022 +0200
@@ -61,7 +61,7 @@
       - mapserv
       - wiki
     volumes:
-      - ../:/opt/d4e/river
+      - ../gwt-client/config:/opt/d4e/river/gwt-client/config
     ports:
       - 8080:8080
 networks:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/config/context.xml	Mon Sep 05 17:55:32 2022 +0200
@@ -0,0 +1,5 @@
+<Context>
+    <!-- Override context parameters in web.xml of gwt-client deployment here.
+         E.g. uncomment the following to use SSO via GGinA: -->
+    <!-- <Parameter name="authentication" value="ggina" override="false"/> -->
+</Context>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/config/features.xml	Mon Sep 05 17:55:32 2022 +0200
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ftr:features xmlns:ftr="http://www.intevation.de/2012/flys/features">
+    <ftr:role name="d4e_demo_all">
+        <ftr:feature>module:winfo</ftr:feature>
+        <ftr:feature>module:minfo</ftr:feature>
+        <ftr:feature>module:new_map</ftr:feature>
+        <ftr:feature>module:new_chart</ftr:feature>
+        <ftr:feature>module:fixanalysis</ftr:feature>
+        <ftr:feature>river:Beispielfluss</ftr:feature>
+    </ftr:role>
+    <ftr:role name="d4e_demo_extern">
+        <ftr:feature>module:winfo</ftr:feature>
+        <ftr:feature>module:minfo</ftr:feature>
+        <ftr:feature>river:Beispielfluss</ftr:feature>
+    </ftr:role>
+</ftr:features>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/config/mapfish/config.yaml	Mon Sep 05 17:55:32 2022 +0200
@@ -0,0 +1,266 @@
+#===========================================================================
+# allowed DPIs
+#===========================================================================
+dpis: [254, 190, 127, 72, 56]
+
+#===========================================================================
+# allowed Formats
+#===========================================================================
+formats: ['*']
+
+#===========================================================================
+# the allowed scales
+#===========================================================================
+scales:
+  - 500
+  - 750
+  - 1000
+  - 1250
+  - 1500
+  - 1750
+  - 2000
+  - 2250
+  - 2500
+  - 2750
+  - 3000
+  - 3250
+  - 3500
+  - 3750
+  - 4000
+  - 4250
+  - 4500
+  - 4750
+  - 5000
+  - 5500
+  - 6000
+  - 6500
+  - 7000
+  - 7500
+  - 8000
+  - 8500
+  - 9000
+  - 9500
+  - 10000
+  - 12500
+  - 15000
+  - 17500
+  - 20000
+  - 22500
+  - 25000
+  - 30000
+  - 35000
+  - 40000
+  - 45000
+  - 50000
+  - 75000
+  - 100000
+  - 200000
+  - 500000
+  - 1000000
+  - 2000000
+  - 4000000
+
+outputFilename: 'd4e-${date}.pdf'
+
+#===========================================================================
+# the list of allowed hosts
+#===========================================================================
+hosts:
+  - !localMatch
+    dummy: true
+  - !dnsMatch
+    host: www.pegelonline.wsv.de
+    port: 80
+  - !dnsMatch
+    host: tile.openstreetmap.org
+    port: 80
+  # Catch all
+  #- !dnsMatch
+  #  host: #regex that catches host plus path
+  #  port: 80
+  - !dnsMatch
+    host: osm.intevation.de
+    port: 80
+
+# We need a font with unicode support the defaults only
+# have latin1
+fonts:
+  - /usr/share/fonts/gnu-free/FreeSans.ttf
+
+layouts:
+  #===========================================================================
+  A4 landscape:
+  #===========================================================================
+    metaData:
+      title: '${mapTitle}'
+      author: 'Dive4Elements River'
+      subject: 'Kartendruck'
+      keywords: 'map,print'
+      creator: 'd4e-river'
+
+    #-------------------------------------------------------------------------
+    mainPage:
+       # 842 * 595
+      pageSize: A4
+      landscape: true
+      marginLeft: 20
+      marginRight: 20
+      marginTop: 20
+      marginBottom: 20
+      items:
+        - !map
+          absoluteX: 20
+          align: left
+          absoluteY: 575
+          width: 587
+          height: 555
+          spacingAfter: 0
+        # The north arrow
+        - !columns
+          absoluteX: 627
+          absoluteY: 65
+          width: 32
+          items:
+            - !image
+              maxWidth: 20
+              maxHeight: 40
+              url: '${configDir}/images/north.png'
+        # The scale text
+        - !columns
+          absoluteX: 615
+          absoluteY: 30
+          width: 45
+          items:
+            - !text
+              fontSize: 8
+              text: '1:${scale}'
+              align: center
+              fontEncoding: Identity-H
+              font: FreeSans
+              backgroundColor: #FFFFFF
+        #Flys and BFG Logo
+        - !columns
+          absoluteX: 760
+          absoluteY: 70
+          width: 50
+          items:
+            - !image
+              maxWidth: 50
+              maxHeight: 50
+              url: '${configDir}/images/FLYS_Logo.png'
+        - !columns
+          absoluteX: 665
+          absoluteY: 70
+          width: 75
+          items:
+            - !image
+              maxWidth: 75
+              maxHeight: 50
+              url: '${configDir}/${logo}'
+        # Scalebar
+        - !columns
+          absoluteX: 455
+          absoluteY: 40
+          width: 150
+          items:
+            - !scalebar
+              type: bar
+              maxSize: 150
+              barSize: 5
+              barBgColor: white
+              fontSize: 8
+              backgroundColor: #FFFFFF
+        # The legend
+        - !columns
+          absoluteX: 612
+          absoluteY: 385
+          width: 200
+          items:
+            - !legends
+              maxHeight: 350
+              maxWidth: 0
+              maxIconHeight: 0
+              inline: true
+              classIndentation: 10
+              layerSpace: 0
+              classSpace: 5
+              layerFontSize: 0
+              classFontSize: 10
+              fontEncoding: Identity-H
+              classFont: FreeSans
+              layerFont: FreeSans
+              defaultScale: 0.7
+          config:
+            borderWidthLeft: 1
+            borderWidthRight: 1
+            borderWidthTop: 1
+            borderWidthBottom: 1
+        # The stamp background
+        - !columns
+          absoluteX: 557
+          absoluteY: 575
+          width: 260
+          items:
+            - !image
+              maxWidth: 260
+              maxHeight: 190
+              url: '${configDir}/images/white.png'
+
+        # Title of the map
+        - !columns
+          absoluteX: 562
+          absoluteY: 575
+          width: 250
+          condition: mapTitle
+          items:
+            - !text
+              fontSize: 18
+              text: '${mapTitle}'
+
+        # The Stamp
+        - !columns
+          absoluteX: 562
+          absoluteY: 550
+          width: 250
+          config:
+            borderWidth: 1
+          items:
+            - !attributes
+              source: data
+              spacingAfter: 0
+              columnDefs:
+                info:
+                  columnWeight: 7
+                  header: !text
+                    text: info
+                    fontSize: 0
+                  cell: !columns
+                    config:
+                      cells:
+                        - borderWidth: 0.5
+                          padding: 5
+                    items:
+                      - !text
+                        text: '${info}'
+                        fontSize: 10
+                        fontEncoding: Identity-H
+                        font: FreeSans
+                        fontSize: 10
+                    backgroundColor: #FFFFFF
+                value:
+                  columnWeight: 15
+                  header: !text
+                    text: value
+                    fontSize: 0
+                  cell: !columns
+                    config:
+                      cells:
+                        - borderWidth: 0.5
+                          padding: 5
+                    items:
+                      - !text
+                        text: '${value}'
+                        fontEncoding: Identity-H
+                        font: FreeSans
+                        fontSize: 10
+                    backgroundColor: #FFFFFF
Binary file gwt-client/config/mapfish/images/FLYS_Logo.png has changed
Binary file gwt-client/config/mapfish/images/bfg_logo.gif has changed
Binary file gwt-client/config/mapfish/images/north.png has changed
Binary file gwt-client/config/mapfish/images/white.png has changed
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java	Tue Aug 30 15:02:10 2022 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java	Mon Sep 05 17:55:32 2022 +0200
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.client.server;
 
+import java.io.File;
 import java.io.IOException;
 
 import javax.servlet.ServletContext;
@@ -33,12 +34,14 @@
     public void  contextInitialized(ServletContextEvent sce) {
         ServletContext sc = sce.getServletContext();
 
-        String filename = sc.getInitParameter("features-file");
+        File file = new File(sc.getInitParameter("features-file"));
+        String path = file.isAbsolute()
+            ? file.getPath()
+            : sc.getRealPath(file.getPath());
 
         log.debug("Initializing ServletContext");
         try {
-            XMLFileFeatures features = new XMLFileFeatures(
-                sc.getRealPath(filename));
+            XMLFileFeatures features = new XMLFileFeatures(path);
             sc.setAttribute(Features.CONTEXT_ATTRIBUTE, features);
         } catch(IOException e) {
             log.error(e);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/SamlServlet.java	Tue Aug 30 15:02:10 2022 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/SamlServlet.java	Mon Sep 05 17:55:32 2022 +0200
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.client.server;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringBufferInputStream;
@@ -71,12 +72,14 @@
 
         Assertion assertion = null;
         try {
-            String keyfile =
-                (String)sc.getInitParameter("saml-trusted-public-key");
+            File keyfile = new File(
+                sc.getInitParameter("saml-trusted-public-key"));
+            String path = keyfile.isAbsolute()
+                ? keyfile.getPath()
+                : sc.getRealPath(keyfile.getPath());
             int timeEps = Integer.parseInt(
                 sc.getInitParameter("saml-time-tolerance"));
-            TicketValidator validator =
-                new TicketValidator(sc.getRealPath(keyfile), timeEps);
+            TicketValidator validator = new TicketValidator(path, timeEps);
 
             InputStream in = new StringBufferInputStream(samlTicketXML);
             assertion = validator.checkTicket(new Base64InputStream(in));
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/auth/was/Authenticator.java	Tue Aug 30 15:02:10 2022 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/auth/was/Authenticator.java	Mon Sep 05 17:55:32 2022 +0200
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.client.server.auth.was;
 
+import java.io.File;
 import java.io.IOException;
 import java.security.GeneralSecurityException;
 import javax.servlet.ServletContext;
@@ -62,12 +63,15 @@
                     return null;
                 }
                 else {
-                    String trustedKey =
-                    (String)context.getInitParameter("saml-trusted-public-key");
+                    File trustedKey = new File(
+                        context.getInitParameter("saml-trusted-public-key"));
+                    String path = trustedKey.isAbsolute()
+                        ? trustedKey.getPath()
+                        : context.getRealPath(trustedKey.getPath());
                     String timeEpsilon = context.getInitParameter(
                         "saml-time-tolerance");
                     return new Response(entity, username, password, features,
-                        context.getRealPath(trustedKey), timeEpsilon);
+                        path, timeEpsilon);
                 }
             }
             catch(GeneralSecurityException e) {
--- a/gwt-client/src/main/webapp/WEB-INF/config.yaml	Tue Aug 30 15:02:10 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,266 +0,0 @@
-#===========================================================================
-# allowed DPIs
-#===========================================================================
-dpis: [254, 190, 127, 72, 56]
-
-#===========================================================================
-# allowed Formats
-#===========================================================================
-formats: ['*']
-
-#===========================================================================
-# the allowed scales
-#===========================================================================
-scales:
-  - 500
-  - 750
-  - 1000
-  - 1250
-  - 1500
-  - 1750
-  - 2000
-  - 2250
-  - 2500
-  - 2750
-  - 3000
-  - 3250
-  - 3500
-  - 3750
-  - 4000
-  - 4250
-  - 4500
-  - 4750
-  - 5000
-  - 5500
-  - 6000
-  - 6500
-  - 7000
-  - 7500
-  - 8000
-  - 8500
-  - 9000
-  - 9500
-  - 10000
-  - 12500
-  - 15000
-  - 17500
-  - 20000
-  - 22500
-  - 25000
-  - 30000
-  - 35000
-  - 40000
-  - 45000
-  - 50000
-  - 75000
-  - 100000
-  - 200000
-  - 500000
-  - 1000000
-  - 2000000
-  - 4000000
-
-outputFilename: 'd4e-${date}.pdf'
-
-#===========================================================================
-# the list of allowed hosts
-#===========================================================================
-hosts:
-  - !localMatch
-    dummy: true
-  - !dnsMatch
-    host: www.pegelonline.wsv.de
-    port: 80
-  - !dnsMatch
-    host: tile.openstreetmap.org
-    port: 80
-  # Catch all
-  #- !dnsMatch
-  #  host: #regex that catches host plus path
-  #  port: 80
-  - !dnsMatch
-    host: osm.intevation.de
-    port: 80
-
-# We need a font with unicode support the defaults only
-# have latin1
-fonts:
-  - /usr/share/fonts/gnu-free/FreeSans.ttf
-
-layouts:
-  #===========================================================================
-  A4 landscape:
-  #===========================================================================
-    metaData:
-      title: '${mapTitle}'
-      author: 'Dive4Elements River'
-      subject: 'Kartendruck'
-      keywords: 'map,print'
-      creator: 'd4e-river'
-
-    #-------------------------------------------------------------------------
-    mainPage:
-       # 842 * 595
-      pageSize: A4
-      landscape: true
-      marginLeft: 20
-      marginRight: 20
-      marginTop: 20
-      marginBottom: 20
-      items:
-        - !map
-          absoluteX: 20
-          align: left
-          absoluteY: 575
-          width: 587
-          height: 555
-          spacingAfter: 0
-        # The north arrow
-        - !columns
-          absoluteX: 627
-          absoluteY: 65
-          width: 32
-          items:
-            - !image
-              maxWidth: 20
-              maxHeight: 40
-              url: '${configDir}/../images/north.png'
-        # The scale text
-        - !columns
-          absoluteX: 615
-          absoluteY: 30
-          width: 45
-          items:
-            - !text
-              fontSize: 8
-              text: '1:${scale}'
-              align: center
-              fontEncoding: Identity-H
-              font: FreeSans
-              backgroundColor: #FFFFFF
-        #Flys and BFG Logo
-        - !columns
-          absoluteX: 760
-          absoluteY: 70
-          width: 50
-          items:
-            - !image
-              maxWidth: 50
-              maxHeight: 50
-              url: '${configDir}/../images/FLYS_Logo.png'
-        - !columns
-          absoluteX: 665
-          absoluteY: 70
-          width: 75
-          items:
-            - !image
-              maxWidth: 75
-              maxHeight: 50
-              url: '${configDir}/../${logo}'
-        # Scalebar
-        - !columns
-          absoluteX: 455
-          absoluteY: 40
-          width: 150
-          items:
-            - !scalebar
-              type: bar
-              maxSize: 150
-              barSize: 5
-              barBgColor: white
-              fontSize: 8
-              backgroundColor: #FFFFFF
-        # The legend
-        - !columns
-          absoluteX: 612
-          absoluteY: 385
-          width: 200
-          items:
-            - !legends
-              maxHeight: 350
-              maxWidth: 0
-              maxIconHeight: 0
-              inline: true
-              classIndentation: 10
-              layerSpace: 0
-              classSpace: 5
-              layerFontSize: 0
-              classFontSize: 10
-              fontEncoding: Identity-H
-              classFont: FreeSans
-              layerFont: FreeSans
-              defaultScale: 0.7
-          config:
-            borderWidthLeft: 1
-            borderWidthRight: 1
-            borderWidthTop: 1
-            borderWidthBottom: 1
-        # The stamp background
-        - !columns
-          absoluteX: 557
-          absoluteY: 575
-          width: 260
-          items:
-            - !image
-              maxWidth: 260
-              maxHeight: 190
-              url: '${configDir}/../images/white.png'
-
-        # Title of the map
-        - !columns
-          absoluteX: 562
-          absoluteY: 575
-          width: 250
-          condition: mapTitle
-          items:
-            - !text
-              fontSize: 18
-              text: '${mapTitle}'
-
-        # The Stamp
-        - !columns
-          absoluteX: 562
-          absoluteY: 550
-          width: 250
-          config:
-            borderWidth: 1
-          items:
-            - !attributes
-              source: data
-              spacingAfter: 0
-              columnDefs:
-                info:
-                  columnWeight: 7
-                  header: !text
-                    text: info
-                    fontSize: 0
-                  cell: !columns
-                    config:
-                      cells:
-                        - borderWidth: 0.5
-                          padding: 5
-                    items:
-                      - !text
-                        text: '${info}'
-                        fontSize: 10
-                        fontEncoding: Identity-H
-                        font: FreeSans
-                        fontSize: 10
-                    backgroundColor: #FFFFFF
-                value:
-                  columnWeight: 15
-                  header: !text
-                    text: value
-                    fontSize: 0
-                  cell: !columns
-                    config:
-                      cells:
-                        - borderWidth: 0.5
-                          padding: 5
-                    items:
-                      - !text
-                        text: '${value}'
-                        fontEncoding: Identity-H
-                        font: FreeSans
-                        fontSize: 10
-                    backgroundColor: #FFFFFF
--- a/gwt-client/src/main/webapp/WEB-INF/features.xml	Tue Aug 30 15:02:10 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ftr:features xmlns:ftr="http://www.intevation.de/2012/flys/features">
-    <ftr:role name="d4e_demo_all">
-        <ftr:feature>module:winfo</ftr:feature>
-        <ftr:feature>module:minfo</ftr:feature>
-        <ftr:feature>module:new_map</ftr:feature>
-        <ftr:feature>module:new_chart</ftr:feature>
-        <ftr:feature>module:fixanalysis</ftr:feature>
-        <ftr:feature>river:Beispielfluss</ftr:feature>
-    </ftr:role>
-    <ftr:role name="d4e_demo_extern">
-        <ftr:feature>module:winfo</ftr:feature>
-        <ftr:feature>module:minfo</ftr:feature>
-        <ftr:feature>river:Beispielfluss</ftr:feature>
-    </ftr:role>
-</ftr:features>
--- a/gwt-client/src/main/webapp/WEB-INF/web.xml	Tue Aug 30 15:02:10 2022 +0200
+++ b/gwt-client/src/main/webapp/WEB-INF/web.xml	Mon Sep 05 17:55:32 2022 +0200
@@ -49,7 +49,7 @@
     <context-param>
         <!-- Path to public key for validation of SAML tickets -->
         <param-name>saml-trusted-public-key</param-name>
-        <param-value>/WEB-INF/saml-signer-cert.pem</param-value>
+        <param-value>/opt/d4e/river/gwt-client/config/saml-signer-cert.pem</param-value>
     </context-param>
 
     <context-param>
@@ -61,7 +61,7 @@
 
     <context-param>
         <param-name>features-file</param-name>
-        <param-value>/WEB-INF/features.xml</param-value>
+        <param-value>/opt/d4e/river/gwt-client/config/features.xml</param-value>
     </context-param>
 
     <listener>
@@ -336,7 +336,7 @@
     <servlet-class>org.mapfish.print.servlet.MapPrinterServlet</servlet-class>
     <init-param>
       <param-name>config</param-name>
-      <param-value>WEB-INF/config.yaml</param-value>
+      <param-value>/opt/d4e/river/gwt-client/config/mapfish/config.yaml</param-value>
     </init-param>
   </servlet>
 
@@ -351,7 +351,7 @@
     <servlet-class>org.dive4elements.river.client.server.MapPrintServiceImpl</servlet-class>
     <init-param>
       <param-name>config</param-name>
-      <param-value>WEB-INF/config.yaml</param-value>
+      <param-value>/opt/d4e/river/gwt-client/config/mapfish/config.yaml</param-value>
     </init-param>
     <init-param>
       <param-name>print-url</param-name>
Binary file gwt-client/src/main/webapp/images/FLYS_Logo.png has changed
Binary file gwt-client/src/main/webapp/images/north.png has changed
Binary file gwt-client/src/main/webapp/images/white.png has changed

http://dive4elements.wald.intevation.org