]> source.dussan.org Git - archiva.git/commitdiff
reduce security informations returned by this public service
authorOlivier Lamy <olamy@apache.org>
Fri, 4 Jan 2013 15:16:22 +0000 (15:16 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 4 Jan 2013 15:16:22 +0000 (15:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1428920 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultRuntimeInfoService.java
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/ApplicationRuntimeInfo.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/archiva.js
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/user.js

index a40e698d24f05efb1388f078b080cfcdba055912..76424116509506f1af7ac0bf117bdd339208355d 100644 (file)
@@ -18,10 +18,14 @@ package org.apache.archiva.web.api;
  * under the License.
  */
 
+import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
+import org.apache.archiva.redback.configuration.UserConfigurationKeys;
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
+import org.apache.archiva.web.model.CookieInformation;
 import org.apache.archiva.web.runtime.ArchivaRuntimeInfo;
 import org.apache.archiva.web.model.ApplicationRuntimeInfo;
+import org.apache.commons.lang.BooleanUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,8 +75,24 @@ public class DefaultRuntimeInfoService
                                                      new Locale( StringUtils.isEmpty( locale ) ? "en" : locale ) );
         applicationRuntimeInfo.setTimestampStr( sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ) );
 
-        applicationRuntimeInfo.setRedbackRuntimeConfiguration(
-            redbackRuntimeConfigurationService.getRedbackRuntimeConfiguration() );
+        CookieInformation cookieInformation = new CookieInformation();
+
+        RedbackRuntimeConfiguration redbackRuntimeConfiguration =
+            redbackRuntimeConfigurationService.getRedbackRuntimeConfiguration();
+
+        cookieInformation.setDomain(
+            redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_DOMAIN ) );
+        cookieInformation.setPath(
+            redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_PATH ) );
+        cookieInformation.setSecure(
+            redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_SECURE ) );
+        cookieInformation.setTimeout(
+            redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_TIMEOUT ) );
+        cookieInformation.setRememberMeEnabled( BooleanUtils.toBoolean(
+            redbackRuntimeConfiguration.getConfigurationProperties().get(
+                UserConfigurationKeys.REMEMBER_ME_ENABLED ) ) );
+
+        applicationRuntimeInfo.setCookieInformation( cookieInformation );
 
         return applicationRuntimeInfo;
     }
index 85fdef76b02d2dc3d88046050935d11345633d12..ef0f5355255babfb1c55c4f4a3ed0114a4663fbf 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.archiva.web.model;
 import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
 
 import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
 import java.util.Calendar;
 
 /**
@@ -29,6 +30,7 @@ import java.util.Calendar;
  */
 @XmlRootElement(name = "applicationRuntimeInfo")
 public class ApplicationRuntimeInfo
+    implements Serializable
 {
     private boolean devMode = false;
 
@@ -48,7 +50,7 @@ public class ApplicationRuntimeInfo
 
     private String timestampStr;
 
-    private RedbackRuntimeConfiguration redbackRuntimeConfiguration;
+    private CookieInformation cookieInformation;
 
     public ApplicationRuntimeInfo()
     {
@@ -151,14 +153,14 @@ public class ApplicationRuntimeInfo
         this.timestampStr = timestampStr;
     }
 
-    public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
+    public CookieInformation getCookieInformation()
     {
-        return redbackRuntimeConfiguration;
+        return cookieInformation;
     }
 
-    public void setRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
+    public void setCookieInformation( CookieInformation cookieInformation )
     {
-        this.redbackRuntimeConfiguration = redbackRuntimeConfiguration;
+        this.cookieInformation = cookieInformation;
     }
 
     @Override
@@ -175,7 +177,7 @@ public class ApplicationRuntimeInfo
         sb.append( ", logMissingI18n=" ).append( logMissingI18n );
         sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' );
         sb.append( ", timestampStr='" ).append( timestampStr ).append( '\'' );
-        sb.append( ", redbackRuntimeConfiguration=" ).append( redbackRuntimeConfiguration );
+        sb.append( ", cookieInformation=" ).append( cookieInformation );
         sb.append( '}' );
         return sb.toString();
     }
index 4bfb95e5c9841c7389f585b1e1563a65692cdd9c..d9226f58540f300fa4263fed4048a5063fb52e8e 100644 (file)
@@ -110,9 +110,7 @@ $.ajax({
               window.archivaJavascriptLog=data.javascriptLog;
               window.archivaRuntimeInfo=data;
 
-              window.redbackRuntimeConfiguration=mapRedbackRuntimeConfiguration(data.redbackRuntimeConfiguration);
-
-              $.log("security.rememberme.enabled key value:"+ window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled'));
+              window.cookieInformation=mapCookieInformation(data.cookieInformation);
 
               require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () {
                   startArchivaApplication();
index c2e2247fa59e6c1f699e5430867640d62ddf9f51..8d4c2b997578bf7cb00eb3898643e6862bcab9a5 100644 (file)
@@ -1612,7 +1612,6 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          // TODO use window.redbackRuntimeConfiguration ?
           var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
           var redbackRuntimeConfigurationViewModel =
               new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
@@ -1653,4 +1652,28 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
     return new CacheConfiguration(data.timeToIdleSeconds,data.timeToLiveSeconds,data.maxElementsInMemory,data.maxElementsOnDisk);
   }
 
+  CookieInformation=function(path,domain,secure,timeout,rememberMeEnabled){
+    //private String path;
+    this.path=path;
+
+    //private String domain;
+    this.domain=domain;
+
+    //private String secure;
+    this.secure=secure;
+
+    //private String timeout;
+    this.timeout=timeout;
+
+    //private boolean rememberMeEnabled;
+    this.rememberMeEnabled=rememberMeEnabled;
+  }
+
+  mapCookieInformation=function(data){
+    if(!data){
+      return new CookieInformation();
+    }
+    return new CookieInformation(data.path,data.domain,data.secure,data.timeout,data.rememberMeEnabled);
+  }
+
 });
\ No newline at end of file
index 26699ae14e7afb7791b6efbd9b6297fef936fa1f..9c26fca72bb6ebba90fc5200cf9d1211df0a13a0 100644 (file)
@@ -29,13 +29,13 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
    */
   reccordLoginCookie=function(user) {
 
-    var path = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.path");
+    var path = window.cookieInformation.path;
     path = path ? path : "/";
 
-    var domain = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.domain");
-    var secure = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.secure");
+    var domain = window.cookieInformation.domain;
+    var secure = window.cookieInformation.secure;
 
-    var expires= Number(window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.timeout"));
+    var expires= Number(window.cookieInformation.timeout);
 
     var userJson=ko.toJSON(user);
 
index 630d9e9f0991961031caaae85aef793ddbbd7206..6c6a5438b1e32400f1104b280a8b3d58c6f47055 100644 (file)
@@ -366,9 +366,9 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
       $.log("user not in cookie");
     }
 
-    var rememberMe=window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled');
+    var rememberMe=window.cookieInformation.rememberMeEnabled;
     $.log("rememberMe:"+rememberMe);
-    if (rememberMe=='false'){
+    if (rememberMe=='true'){
       $("#user-login-form-rememberme-label" ).hide();
       $("#user-login-form-rememberme" ).attr("disabled","true");
       if($("#user-login-form-rememberme" ).get(0 ).checked){