← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17967: UI for CORS whitelist, wip

 

------------------------------------------------------------
revno: 17967
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-14 10:56:35 +0700
message:
  UI for CORS whitelist, wip
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemRemoteAccessSettings.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/settingsMenu.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2014-12-21 17:57:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2015-01-14 03:56:35 +0000
@@ -104,7 +104,8 @@
     final String KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL = "keyAcceptanceRequiredForApproval";
     final String KEY_SYSTEM_NOTIFICATIONS_EMAIL = "keySystemNotificationsEmail";
     final String KEY_ANALYSIS_RELATIVE_PERIOD = "keyAnalysisRelativePeriod";
-    
+    final String KEY_CORS_WHITELIST = "keyCorsWhitelist";
+
     final String DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "lastMonth";
     final String DEFAULT_FLAG = "dhis2";
     final int DEFAULT_MAX_NUMBER_OF_ATTEMPTS = 20;
@@ -191,6 +192,8 @@
 
     Integer credentialsExpires();
 
+    List<String> getCorsWhitelist();
+
     Map<String, Serializable> getSystemSettingsAsMap();
     
     Map<String, Serializable> getSystemSettings( Set<String> names );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2014-12-21 17:57:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2015-01-14 03:56:35 +0000
@@ -72,7 +72,7 @@
 
     @Override
     public void saveSystemSetting( String name, Serializable value )
-    {        
+    {
         SystemSetting setting = systemSettingStore.getByName( name );
 
         if ( setting == null )
@@ -167,13 +167,13 @@
     {
         return (Boolean) getSystemSetting( KEY_EMAIL_TLS, true );
     }
-    
+
     @Override
     public String getEmailSender()
     {
         return StringUtils.trimToNull( (String) getSystemSetting( KEY_EMAIL_SENDER ) );
     }
-    
+
     @Override
     public boolean accountRecoveryEnabled()
     {
@@ -202,7 +202,7 @@
     public boolean systemNotificationEmailValid()
     {
         String address = (String) getSystemSetting( KEY_SYSTEM_NOTIFICATIONS_EMAIL );
-        
+
         return address != null && ValidationUtils.emailIsValid( address );
     }
 
@@ -219,6 +219,13 @@
     }
 
     @Override
+    @SuppressWarnings( "unchecked" )
+    public List<String> getCorsWhitelist()
+    {
+        return (List<String>) (getSystemSetting( KEY_CORS_WHITELIST ) == null ? Collections.emptyList() : getSystemSetting( KEY_CORS_WHITELIST ));
+    }
+
+    @Override
     public Map<String, Serializable> getSystemSettingsAsMap()
     {
         Map<String, Serializable> settingsMap = new HashMap<>();
@@ -242,17 +249,17 @@
     public Map<String, Serializable> getSystemSettings( Set<String> names )
     {
         Map<String, Serializable> map = new HashMap<>();
-        
+
         for ( String name : names )
         {
             Serializable setting = getSystemSetting( name, DEFAULT_SETTINGS_VALUES.get( name ) );
-            
+
             if ( setting != null )
             {
                 map.put( name, setting );
             }
         }
-        
+
         return map;
-    }    
+    }
 }

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetRemoteAccessSettingsAction.java	2015-01-14 03:56:35 +0000
@@ -0,0 +1,52 @@
+package org.hisp.dhis.settings.action.system;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class GetRemoteAccessSettingsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+    {
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetRemoteAccessSettingsAction.java	2015-01-14 03:56:35 +0000
@@ -0,0 +1,69 @@
+package org.hisp.dhis.settings.action.system;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.i18n.I18n;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class SetRemoteAccessSettingsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private String message;
+
+    public String getMessage()
+    {
+        return message;
+    }
+
+    private I18n i18n;
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+    {
+        message = i18n.getString( "settings_updated" );
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml	2014-12-04 06:39:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml	2015-01-14 03:56:35 +0000
@@ -65,10 +65,18 @@
     class="org.hisp.dhis.settings.action.system.GetAccessSettingsAction"
     scope="prototype" />
 
+  <bean id="org.hisp.dhis.settings.action.system.GetRemoteAccessSettingsAction"
+    class="org.hisp.dhis.settings.action.system.GetRemoteAccessSettingsAction"
+    scope="prototype" />
+
   <bean id="org.hisp.dhis.settings.action.system.SetAccessSettingsAction"
     class="org.hisp.dhis.settings.action.system.SetAccessSettingsAction"
     scope="prototype" />
 
+  <bean id="org.hisp.dhis.settings.action.system.SetRemoteAccessSettingsAction"
+    class="org.hisp.dhis.settings.action.system.SetRemoteAccessSettingsAction"
+    scope="prototype" />
+
   <bean id="org.hisp.dhis.settings.action.system.GetApprovalSettingsAction"
     class="org.hisp.dhis.settings.action.system.GetApprovalSettingsAction"
     scope="prototype">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2014-11-26 12:22:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2015-01-14 03:56:35 +0000
@@ -81,11 +81,13 @@
 google_analytics_ua_key=Google Analytics (Universal Analytics) key
 application_introduction=Application introduction
 access_settings=Access settings
+remote_access_settings=Remote Access settings
 do_not_allow_self_registration=Do not allow self registration
 do_not_require_recaptcha_for_self_registration=Do not require recaptcha for self registration
 self_registration_account_user_role=Self registration account user role
 self_registration_account_organisation_unit=Self registration account organisation unit
 access=Access
+remote_access=Remote Access
 enable_user_account_recovery=Enable user account recovery
 enable_user_account_invite=Enable user account invite
 select_organisation_unit=Select organisation unit

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml	2014-11-14 11:34:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml	2015-01-14 03:56:35 +0000
@@ -104,6 +104,23 @@
       <param name="requiredAuthorities">F_SYSTEM_SETTING</param>
     </action>
 
+    <!-- Remote Access settings -->
+
+    <action name="systemRemoteAccessSettings" class="org.hisp.dhis.settings.action.system.GetRemoteAccessSettingsAction">
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-maintenance-settings/systemRemoteAccessSettings.vm</param>
+      <param name="menu">/dhis-web-maintenance-settings/settingsMenu.vm</param>
+      <param name="requiredAuthorities">F_SYSTEM_SETTING</param>
+    </action>
+
+    <action name="setSystemRemoteAccessSettings" class="org.hisp.dhis.settings.action.system.SetRemoteAccessSettingsAction">
+      <result name="success" type="velocity-json">
+        /dhis-web-commons/ajax/jsonResponseSuccess.vm
+      </result>
+      <param name="onExceptionReturn">plainTextError</param>
+      <param name="requiredAuthorities">F_SYSTEM_SETTING</param>
+    </action>
+
     <!-- Approval settings -->
 
     <action name="systemApprovalSettings" class="org.hisp.dhis.settings.action.system.GetApprovalSettingsAction">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm	2014-07-10 13:15:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/index.vm	2015-01-14 03:56:35 +0000
@@ -8,4 +8,5 @@
     #introListImgItem( "systemApprovalSettings.action" "approval_settings" "systemsettings" )
     #introListImgItem( "systemCalendarSettings.action" "calendar_settings" "systemsettings" )
     #introListImgItem( "systemSynchronizationSettings.action" "data_synchronization" "systemsettings" )
+    #introListImgItem( "systemAccessSettings.action" "remote_access_settings" "systemsettings" )
 </ul>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/settingsMenu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/settingsMenu.vm	2014-07-10 13:15:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/settingsMenu.vm	2015-01-14 03:56:35 +0000
@@ -1,10 +1,11 @@
 <h2>$i18n.getString( "system_settings" )&nbsp;</h2>
 <ul>
-	<li><a href="systemGeneralSettings.action">$i18n.getString( "general" )&nbsp;</a></li>
-	<li><a href="systemAppearanceSettings.action">$i18n.getString( "appearance" )&nbsp;</a></li>
-    <li><a href="systemEmailSettings.action">$i18n.getString( "email" )&nbsp;</a></li>
-    <li><a href="systemAccessSettings.action">$i18n.getString( "access" )&nbsp;</a></li>
-    <li><a href="systemApprovalSettings.action">$i18n.getString( "approval" )&nbsp;</a></li>
-    <li><a href="systemCalendarSettings.action">$i18n.getString( "calendar" )&nbsp;</a></li>
-    <li><a href="systemSynchronizationSettings.action">$i18n.getString( "synchronization" )&nbsp;</a></li>
+  <li><a href="systemGeneralSettings.action">$i18n.getString( "general" )&nbsp;</a></li>
+  <li><a href="systemAppearanceSettings.action">$i18n.getString( "appearance" )&nbsp;</a></li>
+  <li><a href="systemEmailSettings.action">$i18n.getString( "email" )&nbsp;</a></li>
+  <li><a href="systemAccessSettings.action">$i18n.getString( "access" )&nbsp;</a></li>
+  <li><a href="systemApprovalSettings.action">$i18n.getString( "approval" )&nbsp;</a></li>
+  <li><a href="systemCalendarSettings.action">$i18n.getString( "calendar" )&nbsp;</a></li>
+  <li><a href="systemSynchronizationSettings.action">$i18n.getString( "synchronization" )&nbsp;</a></li>
+  <li><a href="systemRemoteAccessSettings.action">$i18n.getString( "remote_access" )&nbsp;</a></li>
 </ul>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemRemoteAccessSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemRemoteAccessSettings.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemRemoteAccessSettings.vm	2015-01-14 03:56:35 +0000
@@ -0,0 +1,5 @@
+
+<h3>$i18n.getString( "remote_access_settings" )</h3>
+
+
+<div class="setting"><input type="button" value="$i18n.getString( 'save' )" style="width:10em"/></div>