Alon Bar-Lev has uploaded a new change for review.

Change subject: packaging: setup: move customization of authentication to 
property file
......................................................................

packaging: setup: move customization of authentication to property file

this will enable us not to edit files within the war.

Change-Id: Ib8503fd98fdba775c62e038b953e8100244ec8da
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M .gitignore
M Makefile
M ovirt-engine-reports/EngineAuthentication/pom.xml
M 
ovirt-engine-reports/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java
R 
packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml.in
M packaging/legacy-setup/ovirt-engine-reports-setup.py
6 files changed, 47 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/37/23537/1

diff --git a/.gitignore b/.gitignore
index 78f7108..d4d4333 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,5 +16,6 @@
 ###########################
 build/python-check.sh
 ovirt-engine-reports.spec
+packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml
 packaging/jasper-customizations/WEB-INF/log4j.properties
 packaging/sys-etc/ovirt-engine/engine.conf.d/50-ovirt-engine-reports.conf
diff --git a/Makefile b/Makefile
index 32e75e2..2f97890 100644
--- a/Makefile
+++ b/Makefile
@@ -120,6 +120,7 @@
 GENERATED = \
        build/python-check.sh \
        ovirt-engine-reports.spec \
+       
packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml \
        packaging/jasper-customizations/WEB-INF/log4j.properties \
        
packaging/sys-etc/ovirt-engine/engine.conf.d/50-ovirt-engine-reports.conf \
        $(NULL)
diff --git a/ovirt-engine-reports/EngineAuthentication/pom.xml 
b/ovirt-engine-reports/EngineAuthentication/pom.xml
index 1b617ed..e6da908 100644
--- a/ovirt-engine-reports/EngineAuthentication/pom.xml
+++ b/ovirt-engine-reports/EngineAuthentication/pom.xml
@@ -58,8 +58,8 @@
         <plugin>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
-            <source>1.6</source>
-            <target>1.6</target>
+            <source>1.7</source>
+            <target>1.7</target>
               <includes>
                 <include>**/*.java</include>
               </includes>
diff --git 
a/ovirt-engine-reports/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java
 
b/ovirt-engine-reports/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java
index a064f0e..1fd67c6 100755
--- 
a/ovirt-engine-reports/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java
+++ 
b/ovirt-engine-reports/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java
@@ -2,6 +2,7 @@
 
 import java.io.BufferedReader;
 import java.io.DataOutputStream;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -17,6 +18,7 @@
 import java.security.cert.X509Certificate;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Properties;
 
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;
@@ -63,6 +65,33 @@
     private String sslProtocol = "TLS";
     private boolean sslInsecure = false;
     private boolean sslNoHostVerification = false;
+    private String authenticationProperties;
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        super.afterPropertiesSet();
+
+        if (authenticationProperties != null) {
+            File authenticationPropertiesFile = new 
File(authenticationProperties);
+            if (!authenticationPropertiesFile.exists()) {
+                logger.warn(String.format("authenticationProperties '%s' 
cannot be found", authenticationProperties));
+            }
+            else {
+                try(InputStream in = new 
FileInputStream(authenticationPropertiesFile)) {
+                    Properties props = new Properties();
+                    props.load(in);
+                    getSessionUserGetSessionUserServletURL = 
props.getProperty("getSessionUserGetSessionUserServletURL", 
getSessionUserGetSessionUserServletURL);
+                    pollingTimeout = 
Integer.valueOf(props.getProperty("pollingTimeout", 
Integer.toString(pollingTimeout)));
+                    sslTrustStoreType = props.getProperty("sslTrustStoreType", 
sslTrustStoreType);
+                    sslTrustStorePath = props.getProperty("sslTrustStorePath", 
sslTrustStorePath);
+                    sslTrustStorePassword = 
props.getProperty("sslTrustStorePassword", sslTrustStorePassword);
+                    sslProtocol = props.getProperty("sslProtocol", 
sslProtocol);
+                    sslInsecure = 
Boolean.valueOf(props.getProperty("sslInsecure", 
Boolean.toString(sslInsecure)));
+                    sslNoHostVerification = 
Boolean.valueOf(props.getProperty("sslNoHostVerification", 
Boolean.toString(sslNoHostVerification)));
+                }
+            }
+        }
+    }
 
     protected AuthenticationDetailsSource authenticationDetailsSource = new 
WebAuthenticationDetailsSource();
 
@@ -325,4 +354,8 @@
     public void setSslNoHostVerification(boolean sslNoHostVerification) {
         this.sslNoHostVerification = sslNoHostVerification;
     }
+
+    public void setAuthenticationProperties(String authenticationProperties) {
+        this.authenticationProperties = authenticationProperties;
+    }
 }
diff --git 
a/packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml 
b/packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml.in
similarity index 95%
rename from 
packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml
rename to 
packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml.in
index ba94be9..099e6b5 100644
--- 
a/packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml
+++ 
b/packaging/jasper-customizations/WEB-INF/applicationContext-ovirt-override.xml.in
@@ -31,8 +31,7 @@
         <property name="authenticationManager">
             <ref bean="authenticationManager"/>
         </property>
-        <property name="getSessionUserServletURL" 
value="https://localhost/ovirt-engine/services/get-session-user"/>
-        <property name="sslInsecure" value="true"/>
+       <property name="authenticationProperties" 
value="@PKG_SYSCONF_DIR@/authentication.properties"/>
     </bean>
 
     <bean 
class="org.ovirt.jasperreports.querymodifier.CustomOvirtReportsQueryManipulator"
 id="CustomOvirtReportsQueryManipulator">
diff --git a/packaging/legacy-setup/ovirt-engine-reports-setup.py 
b/packaging/legacy-setup/ovirt-engine-reports-setup.py
index ca14d48..afc06d3 100755
--- a/packaging/legacy-setup/ovirt-engine-reports-setup.py
+++ b/packaging/legacy-setup/ovirt-engine-reports-setup.py
@@ -51,7 +51,8 @@
 REPORTS_DB_USER = 'engine_reports'
 DWH_DB_USER = 'engine_history'
 
-DIR_DATABASE_REPORTS_CONFIG = 
"/etc/ovirt-engine-reports/ovirt-engine-reports.conf.d/"
+DIR_REPORTS_CONFIG = "/etc/ovirt-engine-reports"
+DIR_DATABASE_REPORTS_CONFIG = os.path.join(DIR_REPORTS_CONFIG, 
"ovirt-engine-reports.conf.d/")
 JRS_PACKAGE_PATH="/usr/share/jasperreports-server"
 REPORTS_SERVER_DIR = "/usr/share/%s"  % JRS_PACKAGE_NAME
 REPORTS_SERVER_BUILDOMATIC_DIR = "%s/buildomatic" % REPORTS_SERVER_DIR
@@ -948,6 +949,12 @@
     os.chdir(current_dir)
     shutil.rmtree(savedRepoDir)
 
+def configureSSO():
+    with open(os.path.join(DIR_REPORTS_CONFIG, 'authentication.properties'), 
'w') as f:
+        f.write(
+            'sslInsecure = true\n'
+            'getSessionUserGetSessionUserServletURL = 
https://localhost/ovirt-engine/services/get-session-user\n'
+        )
 
 def configureApache():
     utils.processTemplate(
@@ -1173,6 +1180,7 @@
                     if os.path.exists(path):
                         shutil.rmtree(path)
 
+                configureSSO()
                 configureApache()
 
                 if os.path.exists(LEGACY_WAR):


-- 
To view, visit http://gerrit.ovirt.org/23537
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib8503fd98fdba775c62e038b953e8100244ec8da
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-reports
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to