This is an automated email from the ASF dual-hosted git repository.

nixon pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 4cd97b3  ATLAS-3472 :- Fix to port jsp's to Servlet.
4cd97b3 is described below

commit 4cd97b37ee2b8b795ddf0b1d66dd11d2d26bcb4a
Author: Mandar Ambawane <mandar.ambaw...@freestoneinfotech.com>
AuthorDate: Sat Oct 19 20:10:27 2019 +0530

    ATLAS-3472 :- Fix to port jsp's to Servlet.
    
    Signed-off-by: nixonrodrigues <ni...@apache.org>
    (cherry picked from commit e0afb12d49a65d38d340a283a20c0657729c8f48)
---
 .../atlas/web/servlets/AtlasErrorServlet.java      | 35 ++++++++++++++++
 .../atlas/web/servlets/AtlasHttpServlet.java       | 47 ++++++++++++++++++++++
 .../atlas/web/servlets/AtlasLoginServlet.java      | 35 ++++++++++++++++
 webapp/src/main/resources/spring-security.xml      |  1 +
 webapp/src/main/webapp/WEB-INF/web.xml             | 20 +++++++++
 .../main/webapp/{error.jsp => error.html.template} |  0
 .../main/webapp/{login.jsp => login.html.template} | 39 +++++++++---------
 7 files changed, 157 insertions(+), 20 deletions(-)

diff --git 
a/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasErrorServlet.java 
b/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasErrorServlet.java
new file mode 100644
index 0000000..3afbf32
--- /dev/null
+++ b/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasErrorServlet.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.web.servlets;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class AtlasErrorServlet  extends AtlasHttpServlet {
+    public static final Logger LOG = 
LoggerFactory.getLogger(AtlasErrorServlet.class);
+
+    public static final String ERROR_HTML_TEMPLATE = "/error.html.template";
+
+    @Override
+    protected void service(HttpServletRequest request, HttpServletResponse 
response) {
+        includeResponse( request,  response, ERROR_HTML_TEMPLATE);
+    }
+}
diff --git 
a/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasHttpServlet.java 
b/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasHttpServlet.java
new file mode 100644
index 0000000..f2ee894
--- /dev/null
+++ b/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasHttpServlet.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.web.servlets;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class AtlasHttpServlet extends HttpServlet {
+    public static final Logger LOG = 
LoggerFactory.getLogger(AtlasHttpServlet.class);
+
+    public static final String TEXT_HTML     = "text/html";
+    public static final String XFRAME_OPTION = "X-Frame-Options";
+    public static final String DENY          = "DENY";
+
+    protected void includeResponse(HttpServletRequest request, 
HttpServletResponse response, String template) {
+        try {
+            response.setContentType(TEXT_HTML);
+            response.setHeader(XFRAME_OPTION, DENY);
+            ServletContext context = getServletContext();
+            RequestDispatcher rd = context.getRequestDispatcher(template);
+            rd.include(request, response);
+        } catch (Exception e) {
+            LOG.error("Error in AtlasHttpServlet", template, e);
+        }
+    }
+}
\ No newline at end of file
diff --git 
a/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasLoginServlet.java 
b/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasLoginServlet.java
new file mode 100644
index 0000000..385f488
--- /dev/null
+++ b/webapp/src/main/java/org/apache/atlas/web/servlets/AtlasLoginServlet.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.web.servlets;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class AtlasLoginServlet extends AtlasHttpServlet {
+    public static final Logger LOG = 
LoggerFactory.getLogger(AtlasLoginServlet.class);
+
+    public static final String LOGIN_HTML_TEMPLATE = "/login.html.template";
+
+    @Override
+    protected void service(HttpServletRequest request, HttpServletResponse 
response) {
+        includeResponse(request, response, LOGIN_HTML_TEMPLATE);
+    }
+}
\ No newline at end of file
diff --git a/webapp/src/main/resources/spring-security.xml 
b/webapp/src/main/resources/spring-security.xml
index 1295244..3020690 100644
--- a/webapp/src/main/resources/spring-security.xml
+++ b/webapp/src/main/resources/spring-security.xml
@@ -20,6 +20,7 @@
     <!-- This XML is no longer being used, @see AtlasSecurityConfig for the 
equivalent java config -->
 
     <security:http pattern="/login.jsp" security="none" />
+    <security:http pattern="/error.jsp" security="none" />
     <security:http pattern="/css/**" security="none" />
     <security:http pattern="/img/**" security="none" />
     <security:http pattern="/libs/**" security="none" />
diff --git a/webapp/src/main/webapp/WEB-INF/web.xml 
b/webapp/src/main/webapp/WEB-INF/web.xml
index 23dc063..8f3f175 100755
--- a/webapp/src/main/webapp/WEB-INF/web.xml
+++ b/webapp/src/main/webapp/WEB-INF/web.xml
@@ -36,6 +36,26 @@
         <load-on-startup>1</load-on-startup>
     </servlet>
 
+    <servlet>
+         <servlet-name>LoginServlet</servlet-name>
+         
<servlet-class>org.apache.atlas.web.servlets.AtlasLoginServlet</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+         <servlet-name>LoginServlet</servlet-name>
+         <url-pattern>/login.jsp</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+         <servlet-name>ErrorServlet</servlet-name>
+         
<servlet-class>org.apache.atlas.web.servlets.AtlasErrorServlet</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+         <servlet-name>ErrorServlet</servlet-name>
+         <url-pattern>/error.jsp</url-pattern>
+    </servlet-mapping>
+
     <servlet-mapping>
         <servlet-name>jersey-servlet</servlet-name>
         <url-pattern>/api/atlas/*</url-pattern>
diff --git a/webapp/src/main/webapp/error.jsp 
b/webapp/src/main/webapp/error.html.template
similarity index 100%
rename from webapp/src/main/webapp/error.jsp
rename to webapp/src/main/webapp/error.html.template
diff --git a/webapp/src/main/webapp/login.jsp 
b/webapp/src/main/webapp/login.html.template
similarity index 62%
rename from webapp/src/main/webapp/login.jsp
rename to webapp/src/main/webapp/login.html.template
index 70ec06d..03a803f 100644
--- a/webapp/src/main/webapp/login.jsp
+++ b/webapp/src/main/webapp/login.html.template
@@ -15,12 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
-<% response.setHeader("X-Frame-Options", "DENY"); %>
 <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
 <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
 <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
 <!--[if lt IE 9]>
-    <script type="text/javascript">
+<script type="text/javascript">
         function Redirect() {
             window.location.assign("ieerror.html");
         }
@@ -28,8 +27,8 @@
     </script>
 <![endif]-->
 <!--[if gt IE 7]>
-    <script src="js/external_lib/es5-shim.min.js"></script>
-    <script src="js/external_lib/respond.min.js"></script>
+<script src="js/external_lib/es5-shim.min.js"></script>
+<script src="js/external_lib/respond.min.js"></script>
 <![endif]-->
 <!--[if gt IE 8]><!-->
 <html class="no-js">
@@ -50,23 +49,23 @@
 </head>
 
 <body class="login-body">
-    <div class="login-form">
-        <div class="logo-container text-center">
-            <img src="img/atlas_logo.svg" />
-        </div>
-        <h4>Sign In to your account</h4>
-        <form action="" method="post" accept-charset="utf-8">
-            <div class="form-group icon-group user">
-                <input type="text" name="username" id="username" 
class="form-control" placeholder="Username" tabindex="1" required autofocus />
-            </div>
-            <div class="form-group icon-group password">
-                <input type="password" name="password" class="form-control" 
placeholder="Password" id="password" tabindex="2" autocomplete="off" required />
-                 <i class="fa fa-eye-slash show-password"></i>
-            </div>
-            <span id="errorBox" class="col-md-12 help-inline" 
style="color:#FF1A40;display:none;text-align:center;padding-bottom: 
10px;"><span class="errorMsg"></span></span>
-            <button class="btn btn-default btn-block btn-login" 
id="signIn">Log in</button>
-        </form>
+<div class="login-form">
+    <div class="logo-container text-center">
+        <img src="img/atlas_logo.svg" />
     </div>
+    <h4>Sign In to your account</h4>
+    <form action="" method="post" accept-charset="utf-8">
+        <div class="form-group icon-group user">
+            <input type="text" name="username" id="username" 
class="form-control" placeholder="Username" tabindex="1" required autofocus />
+        </div>
+        <div class="form-group icon-group password">
+            <input type="password" name="password" class="form-control" 
placeholder="Password" id="password" tabindex="2" autocomplete="off" required />
+            <i class="fa fa-eye-slash show-password"></i>
+        </div>
+        <span id="errorBox" class="col-md-12 help-inline" 
style="color:#FF1A40;display:none;text-align:center;padding-bottom: 
10px;"><span class="errorMsg"></span></span>
+        <button class="btn btn-default btn-block btn-login" id="signIn">Log 
in</button>
+    </form>
+</div>
 </body>
 
 </html>
\ No newline at end of file

Reply via email to