Repository: incubator-ranger
Updated Branches:
  refs/heads/ranger-0.5 0d38f0f2c -> 89002025e


RANGER-545 : Fix js error for lower versions of FF (<30)

Signed-off-by: Velmurugan Periasamy <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/89002025
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/89002025
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/89002025

Branch: refs/heads/ranger-0.5
Commit: 89002025e57cf235cbf4c248eb7e468dad9378fb
Parents: 0d38f0f
Author: Gautam Borad <[email protected]>
Authored: Thu Jun 11 00:54:26 2015 +0530
Committer: Velmurugan Periasamy <[email protected]>
Committed: Wed Jun 10 14:42:35 2015 -0700

----------------------------------------------------------------------
 .../RangerAuthenticationEntryPoint.java         | 54 +++++++++++---------
 .../webapp/scripts/views/service/ServiceForm.js |  6 ++-
 2 files changed, 33 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/89002025/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthenticationEntryPoint.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthenticationEntryPoint.java
 
b/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthenticationEntryPoint.java
index 941db5b..a3f3ed5 100644
--- 
a/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthenticationEntryPoint.java
+++ 
b/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthenticationEntryPoint.java
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
 import org.apache.log4j.Logger;
+import org.apache.ranger.biz.SessionMgr;
 import org.apache.ranger.common.JSONUtil;
 import org.apache.ranger.common.PropertiesUtil;
 import org.apache.ranger.common.RangerConfigUtil;
@@ -47,7 +48,8 @@ public class RangerAuthenticationEntryPoint extends
                LoginUrlAuthenticationEntryPoint {
        public static final int SC_AUTHENTICATION_TIMEOUT = 419;
 
-       static Logger logger = 
Logger.getLogger(RangerAuthenticationEntryPoint.class);
+       static Logger logger = Logger
+                       .getLogger(RangerAuthenticationEntryPoint.class);
        static int ajaxReturnCode = -1;
 
        @Autowired
@@ -55,6 +57,9 @@ public class RangerAuthenticationEntryPoint extends
 
        @Autowired
        JSONUtil jsonUtil;
+       
+       @Autowired
+       SessionMgr sessionMgr;
 
        public RangerAuthenticationEntryPoint() {
                super();
@@ -63,7 +68,8 @@ public class RangerAuthenticationEntryPoint extends
                }
 
                if (ajaxReturnCode < 0) {
-               ajaxReturnCode = 
PropertiesUtil.getIntProperty("ranger.ajax.auth.required.code", 401);
+                       ajaxReturnCode = PropertiesUtil.getIntProperty(
+                                       "ranger.ajax.auth.required.code", 401);
                }
        }
 
@@ -71,35 +77,33 @@ public class RangerAuthenticationEntryPoint extends
        public void commence(HttpServletRequest request,
                        HttpServletResponse response, AuthenticationException 
authException)
                        throws IOException, ServletException {
-               HttpSession httpSession = request.getSession();
                String ajaxRequestHeader = 
request.getHeader("X-Requested-With");
                if (logger.isDebugEnabled()) {
                        logger.debug("commence() X-Requested-With=" + 
ajaxRequestHeader);
                }
 
-               String requestURL = (request.getRequestURL() != null) ? 
request.getRequestURL().toString() : "";
-               String servletPath = 
PropertiesUtil.getProperty("ranger.servlet.mapping.url.pattern", "service");
-               String reqServletPath = configUtil.getWebAppRootURL() + "/" + 
servletPath;
-
-               response.setContentType("application/json;charset=UTF-8");
-               response.setHeader("Cache-Control", "no-cache");
-               // getting the current date in milliseconds
-               Date curentDate = new Date();
-               Long currentDateInMillis = (long) (((((curentDate.getHours() * 
60) + curentDate
-                               .getMinutes()) * 60) + curentDate.getSeconds()) 
* 1000);
-               // checking session timeout occurence
-               if (httpSession.getMaxInactiveInterval() * 60000 >= 
(currentDateInMillis - httpSession
-                               .getLastAccessedTime())) {
-                       ajaxRequestHeader = null;
-                       VXResponse vXResponse = new VXResponse();
-
-                       vXResponse.setStatusCode(SC_AUTHENTICATION_TIMEOUT);
-                       vXResponse.setMsgDesc("Session Timeout");
-
-                       response.setStatus(SC_AUTHENTICATION_TIMEOUT);
-                       response.getWriter()
-                                       
.write(jsonUtil.writeObjectAsString(vXResponse));
+               String requestURL = (request.getRequestURL() != null) ? request
+                               .getRequestURL().toString() : "";
+               String servletPath = PropertiesUtil.getProperty(
+                               "ranger.servlet.mapping.url.pattern", 
"service");
+               String reqServletPath = configUtil.getWebAppRootURL() + "/"
+                               + servletPath;
+
+               if ("XMLHttpRequest".equals(ajaxRequestHeader)) {
+                       try {
+
+                               VXResponse vXResponse = new VXResponse();
+
+                               
vXResponse.setStatusCode(SC_AUTHENTICATION_TIMEOUT);
+                               vXResponse.setMsgDesc("Session Timeout");
 
+                               response.setStatus(SC_AUTHENTICATION_TIMEOUT);
+                               response.getWriter().write(
+                                               
jsonUtil.writeObjectAsString(vXResponse));
+                       } catch (IOException e) {
+                               logger.info("Error while writing JSON in 
HttpServletResponse");
+                       }
+                       return;
                } else {
                        try {
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/89002025/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js 
b/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
index a3ac650..f073036 100644
--- a/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
@@ -155,9 +155,11 @@ define(function(require){
                                        if(obj.type == 'bool'){
                                                config[obj.name] = 
that.getBooleanForConfig(obj, that.model);
                                        }else{
-                                               config[obj.name] = 
that.model.get(obj.name).toString();
+                                               config[obj.name] = 
_.isNull(that.model.get(obj.name)) ? "" : that.model.get(obj.name).toString();
+                                       }
+                                       if(!_.isNull(obj.name)) {
+                                               that.model.unset(obj.name);
                                        }
-                                       that.model.unset(obj.name);
                                }
                        });
                        this.extraConfigColl.each(function(obj){ 
config[obj.get('name')] = obj.get('value');})

Reply via email to