You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ap...@apache.org on 2017/05/23 22:07:06 UTC

[08/12] incubator-atlas git commit: ATLAS-1198: Spring Framework (v4 with Spring security) over Guice

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationEntryPoint.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationEntryPoint.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationEntryPoint.java
index 382b494..7767602 100644
--- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationEntryPoint.java
+++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationEntryPoint.java
@@ -16,23 +16,32 @@
  */
 package org.apache.atlas.web.filters;
 
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 @SuppressWarnings("deprecation")
-class AtlasAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
+@Component
+public class AtlasAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
 
     private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthenticationEntryPoint.class);
 
     private String loginPath = "/login.jsp";
 
+    @Inject
+    public AtlasAuthenticationEntryPoint(@Value("/login.jsp") String loginFormUrl) {
+        super(loginFormUrl);
+    }
+
     @Override
     public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
             throws IOException, ServletException {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java
index 473c78d..25aede3 100644
--- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java
@@ -51,6 +51,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.web.authentication.WebAuthenticationDetails;
+import org.springframework.stereotype.Component;
 
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
@@ -78,6 +79,7 @@ import java.util.regex.Pattern;
  * todo: Subclass of {@link org.apache.hadoop.security.authentication.server.AuthenticationFilter}.
  */
 
+@Component
 public class AtlasAuthenticationFilter extends AuthenticationFilter {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthenticationFilter.class);
     static final String PREFIX = "atlas.authentication.method";

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
index a1a168a..862e34f 100644
--- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
 import org.springframework.web.filter.GenericFilterBean;
 
 import javax.servlet.FilterChain;
@@ -44,6 +45,7 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
+@Component
 public class AtlasAuthorizationFilter extends GenericFilterBean {
 
     private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthorizationFilter.class);
@@ -95,7 +97,7 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
         responseWrapper.setHeader("X-Frame-Options", "DENY");
 
         String pathInfo = request.getServletPath();
-        if (!Strings.isNullOrEmpty(pathInfo) && pathInfo.startsWith(BASE_URL)) {
+        if (!Strings.isNullOrEmpty(pathInfo) && (pathInfo.startsWith(BASE_URL) || BASE_URL.startsWith(pathInfo))) {
             if (isDebugEnabled) {
                 LOG.debug("{} is a valid REST API request!!!", pathInfo);
             }
@@ -113,10 +115,11 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
                 }
             } else {
                 if (LOG.isErrorEnabled()) {
-                    LOG.error("Cannot obtain Security Context : {}", auth);
+                    LOG.error("Cannot obtain Security Context");
                 }
-                throw new ServletException("Cannot obtain Security Context : " + auth);
+                throw new ServletException("Cannot obtain Security Context");
             }
+
             AtlasAccessRequest atlasRequest = new AtlasAccessRequest(request, userName, groups);
             if (isDebugEnabled) {
                 LOG.debug("============================\nUserName :: {}\nGroups :: {}\nURL :: {}\nAction :: {}\nrequest.getServletPath() :: {}\n============================\n", atlasRequest.getUser(), atlasRequest.getUserGroups(), request.getRequestURL(), atlasRequest.getAction(), pathInfo);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java
index 5294c9b..277ac22 100644
--- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java
@@ -18,12 +18,13 @@
 
 package org.apache.atlas.web.filters;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.apache.atlas.ApplicationProperties;
+import org.apache.atlas.AtlasException;
+import org.apache.commons.configuration.Configuration;
+import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -33,15 +34,14 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.atlas.ApplicationProperties;
-import org.apache.atlas.AtlasException;
-import org.apache.commons.configuration.Configuration;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.json.simple.JSONObject;
-
+@Component
 public class AtlasCSRFPreventionFilter implements Filter {
 	private static final Logger LOG = LoggerFactory.getLogger(AtlasCSRFPreventionFilter.class);
 	private static Configuration configuration;
@@ -238,13 +238,11 @@ public class AtlasCSRFPreventionFilter implements Filter {
 		@Override
 		public void sendError(int code, String message) throws IOException {
 			JSONObject json = new JSONObject();
-            ObjectMapper mapper = new ObjectMapper();
             json.put("msgDesc", message);
-            String jsonAsStr = mapper.writeValueAsString(json);
             httpResponse.setContentType("application/json");
             httpResponse.setStatus(code);
             httpResponse.setCharacterEncoding("UTF-8");
-            httpResponse.getWriter().write(jsonAsStr);
+            httpResponse.getWriter().write(json.toJSONString());
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/AtlasKnoxSSOAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasKnoxSSOAuthenticationFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasKnoxSSOAuthenticationFilter.java
index d5fa003..665fa34 100644
--- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasKnoxSSOAuthenticationFilter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasKnoxSSOAuthenticationFilter.java
@@ -20,7 +20,6 @@
 
 package org.apache.atlas.web.filters;
 
-import com.google.inject.Inject;
 import com.nimbusds.jose.JOSEException;
 import com.nimbusds.jose.JWSObject;
 import com.nimbusds.jose.JWSVerifier;
@@ -42,6 +41,9 @@ import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.web.authentication.WebAuthenticationDetails;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
 import javax.servlet.*;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
@@ -61,6 +63,7 @@ import java.util.List;
 import org.apache.commons.lang.StringUtils;
 
 
+@Component("ssoAuthenticationFilter")
 public class AtlasKnoxSSOAuthenticationFilter implements Filter {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasKnoxSSOAuthenticationFilter.class);
 
@@ -73,6 +76,8 @@ public class AtlasKnoxSSOAuthenticationFilter implements Filter {
     public static final String JWT_ORIGINAL_URL_QUERY_PARAM_DEFAULT = "originalUrl";
     public static final String DEFAULT_BROWSER_USERAGENT = "Mozilla,Opera,Chrome";
 
+    private final AtlasAuthenticationProvider authenticationProvider;
+
     private SSOAuthenticationProperties jwtProperties;
 
     private String originalUrlQueryParam = "originalUrl";
@@ -84,7 +89,8 @@ public class AtlasKnoxSSOAuthenticationFilter implements Filter {
     private JWSVerifier verifier = null;
 
     @Inject
-    public AtlasKnoxSSOAuthenticationFilter() {
+    public AtlasKnoxSSOAuthenticationFilter(AtlasAuthenticationProvider authenticationProvider) {
+        this.authenticationProvider = authenticationProvider;
         try {
             configuration = ApplicationProperties.get();
         } catch (Exception e) {
@@ -97,8 +103,9 @@ public class AtlasKnoxSSOAuthenticationFilter implements Filter {
         setJwtProperties();
     }
 
-    public AtlasKnoxSSOAuthenticationFilter(
-            SSOAuthenticationProperties jwtProperties) {
+    public AtlasKnoxSSOAuthenticationFilter(AtlasAuthenticationProvider authenticationProvider,
+                                            SSOAuthenticationProperties jwtProperties) {
+        this.authenticationProvider = authenticationProvider;
         this.jwtProperties = jwtProperties;
         setJwtProperties();
     }
@@ -166,7 +173,6 @@ public class AtlasKnoxSSOAuthenticationFilter implements Filter {
                         final Authentication finalAuthentication = new UsernamePasswordAuthenticationToken(principal, "", grantedAuths);
                         WebAuthenticationDetails webDetails = new WebAuthenticationDetails(httpRequest);
                         ((AbstractAuthenticationToken) finalAuthentication).setDetails(webDetails);
-                        AtlasAuthenticationProvider authenticationProvider = new AtlasAuthenticationProvider();
                         authenticationProvider.setSsoEnabled(ssoEnabled);
                         Authentication authentication = authenticationProvider.authenticate(finalAuthentication);
                         SecurityContextHolder.getContext().setAuthentication(authentication);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/AuditFilter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AuditFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AuditFilter.java
index 525bbc0..191388a 100755
--- a/webapp/src/main/java/org/apache/atlas/web/filters/AuditFilter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/filters/AuditFilter.java
@@ -18,19 +18,18 @@
 
 package org.apache.atlas.web.filters;
 
-import com.google.inject.Singleton;
-
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.RequestContext;
 import org.apache.atlas.RequestContextV1;
 import org.apache.atlas.metrics.Metrics;
-import org.apache.commons.configuration.Configuration;
 import org.apache.atlas.util.AtlasRepositoryConfiguration;
 import org.apache.atlas.web.util.DateTimeHelper;
 import org.apache.atlas.web.util.Servlets;
+import org.apache.commons.configuration.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -40,7 +39,6 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
 import java.io.IOException;
 import java.util.Date;
 import java.util.UUID;
@@ -49,7 +47,7 @@ import java.util.UUID;
  * This records audit information as part of the filter after processing the request
  * and also introduces a UUID into request and response for tracing requests in logs.
  */
-@Singleton
+@Component
 public class AuditFilter implements Filter {
     private static final Logger AUDIT_LOG = LoggerFactory.getLogger("AUDIT");
     private static final Logger LOG = LoggerFactory.getLogger(AuditFilter.class);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/StaleTransactionCleanupFilter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/StaleTransactionCleanupFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/StaleTransactionCleanupFilter.java
index 5f62bc4..cdb9064 100644
--- a/webapp/src/main/java/org/apache/atlas/web/filters/StaleTransactionCleanupFilter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/filters/StaleTransactionCleanupFilter.java
@@ -18,7 +18,10 @@
 
 package org.apache.atlas.web.filters;
 
-import java.io.IOException;
+import org.apache.atlas.repository.graph.AtlasGraphProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -26,12 +29,7 @@ import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Singleton;
+import java.io.IOException;
 
 /**
  * Filter that rolls back the stale transaction associated with
@@ -39,7 +37,7 @@ import com.google.inject.Singleton;
  * see all of the committed changes.
  *
  */
-@Singleton
+@Component
 public class StaleTransactionCleanupFilter implements Filter {
 
     private static final Logger LOG = LoggerFactory.getLogger(StaleTransactionCleanupFilter.class);
@@ -52,6 +50,7 @@ public class StaleTransactionCleanupFilter implements Filter {
     @Override
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
     throws IOException, ServletException {
+        LOG.info("Cleaning stale transactions");
         AtlasGraphProvider.getGraphInstance().rollback();
         filterChain.doFilter(request, response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/listeners/GuiceServletConfig.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/listeners/GuiceServletConfig.java b/webapp/src/main/java/org/apache/atlas/web/listeners/GuiceServletConfig.java
deleted file mode 100755
index 95647e0..0000000
--- a/webapp/src/main/java/org/apache/atlas/web/listeners/GuiceServletConfig.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * 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
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.listeners;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletContextEvent;
-
-import org.apache.atlas.ApplicationProperties;
-import org.apache.atlas.AtlasClient;
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.RepositoryMetadataModule;
-import org.apache.atlas.ha.HAConfiguration;
-import org.apache.atlas.notification.NotificationModule;
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
-import org.apache.atlas.repository.graphdb.AtlasGraph;
-import org.apache.atlas.service.Services;
-import org.apache.atlas.web.filters.ActiveServerFilter;
-import org.apache.atlas.web.filters.AuditFilter;
-import org.apache.atlas.web.filters.StaleTransactionCleanupFilter;
-import org.apache.atlas.web.service.ActiveInstanceElectorModule;
-import org.apache.atlas.web.service.ServiceModule;
-import org.apache.commons.configuration.Configuration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.bridge.SLF4JBridgeHandler;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.google.inject.Stage;
-import com.google.inject.servlet.GuiceServletContextListener;
-import com.sun.jersey.api.core.PackagesResourceConfig;
-import com.sun.jersey.guice.JerseyServletModule;
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-
-public class GuiceServletConfig extends GuiceServletContextListener {
-
-    private static final Logger LOG = LoggerFactory.getLogger(GuiceServletConfig.class);
-
-    private static final String GUICE_CTX_PARAM = "guice.packages";
-    protected volatile Injector injector;
-
-    @Override
-    protected Injector getInjector() {
-        LOG.info("Loading Guice modules");
-        /*
-         * More information on this can be found here:
-		 * https://jersey.java.net/nonav/apidocs/1
-		 * .11/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary
-		 * .html
-		 */
-        if (injector == null) {
-
-            // perform login operations
-            LoginProcessor loginProcessor = new LoginProcessor();
-            loginProcessor.login();
-
-            injector = Guice.createInjector(Stage.PRODUCTION,  getRepositoryModule(), new ActiveInstanceElectorModule(),
-                    new NotificationModule(), new ServiceModule(), new JerseyServletModule() {
-
-                        private Configuration appConfiguration = null;
-
-                        private Configuration getConfiguration() {
-                            if (appConfiguration == null) {
-                                try {
-                                    appConfiguration = ApplicationProperties.get();
-                                } catch (AtlasException e) {
-                                    LOG.warn("Could not load application configuration", e);
-                                }
-                            }
-                            return appConfiguration;
-                        }
-
-                        @Override
-                        protected void configureServlets() {
-                            filter("/*").through(StaleTransactionCleanupFilter.class);
-                            filter("/*").through(AuditFilter.class);
-                            configureActiveServerFilterIfNecessary();
-
-                            Map<String, String> initParams     = new HashMap<>();
-                            Enumeration<String> initParamNames = getServletContext().getInitParameterNames();
-
-                            while (initParamNames.hasMoreElements()) {
-                                String initParamName  = initParamNames.nextElement();
-                                String initParamValue = getServletContext().getInitParameter(initParamName);
-
-                                if (GUICE_CTX_PARAM.equals(initParamName)) {
-                                    LOG.info("Jersey loading from packages: {}", initParamValue);
-
-                                    initParams.put(PackagesResourceConfig.PROPERTY_PACKAGES, initParamValue);
-                                } else {
-                                    initParams.put(initParamName, initParamValue);
-                                }
-                            }
-
-                            serve("/" + AtlasClient.BASE_URI + "*").with(GuiceContainer.class, initParams);
-                        }
-
-                        private void configureActiveServerFilterIfNecessary() {
-                            Configuration configuration = getConfiguration();
-                            if ((configuration == null) ||
-                                    !HAConfiguration.isHAEnabled(configuration)) {
-                                LOG.info("HA configuration is disabled, not activating ActiveServerFilter");
-                            } else {
-                                filter("/*").through(ActiveServerFilter.class);
-                            }
-                        }
-
-                    });
-
-            LOG.info("Guice modules loaded");
-        }
-
-        return injector;
-    }
-
-    protected Module getRepositoryModule() {
-        return new RepositoryMetadataModule();
-    }
-
-    @Override
-    public void contextInitialized(ServletContextEvent servletContextEvent) {
-        super.contextInitialized(servletContextEvent);
-
-        installLogBridge();
-
-        startServices();
-    }
-
-    protected void startServices() {
-        LOG.info("Starting services");
-        Services services = injector.getInstance(Services.class);
-        services.start();
-    }
-
-    /**
-     * Maps jersey's java.util.logging to slf4j
-     */
-    private void installLogBridge() {
-        // Optionally remove existing handlers attached to j.u.l root logger
-        SLF4JBridgeHandler.removeHandlersForRootLogger();  // (since SLF4J 1.6.5)
-
-        // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during
-        // the initialization phase of your application
-        SLF4JBridgeHandler.install();
-    }
-
-    @Override
-    public void contextDestroyed(ServletContextEvent servletContextEvent) {
-        LOG.info("Starting servlet context destroy");
-        if(injector != null) {
-            //stop services
-            stopServices();
-            
-            final AtlasGraph graph = AtlasGraphProvider.getGraphInstance();
-
-            try {
-                graph.shutdown();
-            } catch(Throwable t) {
-                LOG.warn("Error while shutting down graph", t);
-            }
-        }
-        super.contextDestroyed(servletContextEvent);
-    }
-
-    protected void stopServices() {
-        LOG.info("Stopping services");
-        Services services = injector.getInstance(Services.class);
-        services.stop();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/listeners/LoginProcessor.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/listeners/LoginProcessor.java b/webapp/src/main/java/org/apache/atlas/web/listeners/LoginProcessor.java
index cc2ef8a..e21656e 100644
--- a/webapp/src/main/java/org/apache/atlas/web/listeners/LoginProcessor.java
+++ b/webapp/src/main/java/org/apache/atlas/web/listeners/LoginProcessor.java
@@ -26,7 +26,9 @@ import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.Shell;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+import javax.annotation.PostConstruct;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -34,6 +36,7 @@ import java.net.UnknownHostException;
 /**
  * A class capable of performing a simple or kerberos login.
  */
+@Component
 public class LoginProcessor {
 
     private static final Logger LOG = LoggerFactory.getLogger(LoginProcessor.class);
@@ -46,6 +49,7 @@ public class LoginProcessor {
      * Perform a SIMPLE login based on established OS identity or a kerberos based login using the configured
      * principal and keytab (via atlas-application.properties).
      */
+    @PostConstruct
     public void login() {
         // first, let's see if we're running in a hadoop cluster and have the env configured
         boolean isHadoopCluster = isHadoopCluster();

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
index 9fe1624..01f9a86 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
@@ -18,7 +18,6 @@
 
 package org.apache.atlas.web.resources;
 
-import com.google.inject.Inject;
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasErrorCode;
@@ -50,10 +49,13 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Service;
 
+import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -80,6 +82,7 @@ import java.util.concurrent.locks.ReentrantLock;
  */
 @Path("admin")
 @Singleton
+@Service
 public class AdminResource {
     private static final Logger LOG = LoggerFactory.getLogger(AdminResource.class);
 
@@ -108,6 +111,10 @@ public class AdminResource {
     private final AtlasTypeDefStore typesDefStore;
     private final AtlasEntityStore  entityStore;
     private static Configuration atlasProperties;
+    private final ExportService exportService;
+
+    @Inject
+    ApplicationContext applicationContext;
 
     static {
         try {
@@ -120,12 +127,13 @@ public class AdminResource {
     @Inject
     public AdminResource(ServiceState serviceState, MetricsService metricsService,
                          AtlasTypeRegistry typeRegistry, AtlasTypeDefStore typeDefStore,
-                         AtlasEntityStore entityStore) {
+                         AtlasEntityStore entityStore, ExportService exportService) {
         this.serviceState               = serviceState;
         this.metricsService             = metricsService;
         this.typeRegistry               = typeRegistry;
         this.typesDefStore              = typeDefStore;
         this.entityStore                = entityStore;
+        this.exportService = exportService;
         this.importExportOperationLock  = new ReentrantLock();
     }
 
@@ -320,8 +328,6 @@ public class AdminResource {
         ZipSink exportSink = null;
         try {
             exportSink = new ZipSink(httpServletResponse.getOutputStream());
-            ExportService exportService = new ExportService(this.typeRegistry);
-
             AtlasExportResult result = exportService.run(exportSink, request, Servlets.getUserName(httpServletRequest),
                                                          Servlets.getHostName(httpServletRequest),
                                                          AtlasAuthorizationUtils.getRequestIpAddress(httpServletRequest));

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
index 2fe6898..435659e 100644
--- a/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
@@ -27,16 +27,12 @@ import org.apache.atlas.web.util.Servlets;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.*;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
 
@@ -45,6 +41,7 @@ import javax.ws.rs.core.Response;
  */
 @Path("lineage/hive")
 @Singleton
+@Service
 @Deprecated
 public class DataSetLineageResource {
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
index 19c5594..711cc04 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
@@ -22,17 +22,17 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.sun.jersey.api.core.ResourceContext;
 import org.apache.atlas.AtlasClient;
+import org.apache.atlas.model.legacy.EntityResult;
 import org.apache.atlas.AtlasConstants;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.CreateUpdateEntitiesResult;
 import org.apache.atlas.EntityAuditEvent;
-import org.apache.atlas.AtlasClient.EntityResult;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.instance.AtlasClassification;
 import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
 import org.apache.atlas.model.instance.EntityMutationResponse;
 import org.apache.atlas.model.instance.GuidMapping;
 import org.apache.atlas.repository.converters.AtlasInstanceConverter;
@@ -40,8 +40,8 @@ import org.apache.atlas.repository.store.graph.AtlasEntityStore;
 import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream;
 import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
 import org.apache.atlas.services.MetadataService;
-import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasEntityType;
+import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.IStruct;
 import org.apache.atlas.typesystem.ITypedReferenceableInstance;
@@ -62,6 +62,7 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -86,8 +87,9 @@ import java.util.Map;
  * An entity is an "instance" of a Type.  Entities conform to the definition
  * of the Type they correspond with.
  */
-@Path("entities")
 @Singleton
+@Path("entities")
+@Service
 @Deprecated
 public class EntityResource {
 
@@ -100,6 +102,7 @@ public class EntityResource {
     private final AtlasInstanceConverter restAdapters;
     private final AtlasEntityStore       entitiesStore;
     private final AtlasTypeRegistry      typeRegistry;
+    private final EntityREST entityREST;
 
     @Context
     UriInfo uriInfo;
@@ -114,11 +117,13 @@ public class EntityResource {
      * @param metadataService metadata service handle
      */
     @Inject
-    public EntityResource(MetadataService metadataService, AtlasInstanceConverter restAdapters, AtlasEntityStore entitiesStore, AtlasTypeRegistry typeRegistry) {
+    public EntityResource(MetadataService metadataService, AtlasInstanceConverter restAdapters,
+                          AtlasEntityStore entitiesStore, AtlasTypeRegistry typeRegistry, EntityREST entityREST) {
         this.metadataService = metadataService;
         this.restAdapters    = restAdapters;
         this.entitiesStore   = entitiesStore;
         this.typeRegistry    = typeRegistry;
+        this.entityREST    = entityREST;
     }
 
     /**
@@ -159,7 +164,6 @@ public class EntityResource {
                 LOG.debug("submitting entities {} ", entityJson);
             }
 
-            EntityREST               entityREST       = resourceContext.getResource(EntityREST.class);
             AtlasEntitiesWithExtInfo entitiesInfo     = restAdapters.toAtlasEntities(entities);
             EntityMutationResponse   mutationResponse = entityREST.createOrUpdate(entitiesInfo);
 
@@ -220,7 +224,7 @@ public class EntityResource {
         return locationURI;
     }
 
-    private JSONObject getResponse(AtlasClient.EntityResult entityResult) throws AtlasException, JSONException {
+    private JSONObject getResponse(EntityResult entityResult) throws AtlasException, JSONException {
         CreateUpdateEntitiesResult result = new CreateUpdateEntitiesResult();
         result.setEntityResult(entityResult);
         return getResponse(result);
@@ -273,7 +277,6 @@ public class EntityResource {
                 LOG.info("updating entities {} ", entityJson);
             }
 
-            EntityREST                 entityREST       = resourceContext.getResource(EntityREST.class);
             AtlasEntitiesWithExtInfo   entitiesInfo     = restAdapters.toAtlasEntities(entities);
             EntityMutationResponse     mutationResponse = entityREST.createOrUpdate(entitiesInfo);
             CreateUpdateEntitiesResult result           = restAdapters.toCreateUpdateEntitiesResult(mutationResponse);
@@ -311,7 +314,7 @@ public class EntityResource {
         }
     }
 
-    private String getSample(AtlasClient.EntityResult entityResult) {
+    private String getSample(EntityResult entityResult) {
         String sample = getSample(entityResult.getCreatedEntities());
         if (sample == null) {
             sample = getSample(entityResult.getUpdateEntities());
@@ -585,7 +588,6 @@ public class EntityResource {
             }
 
             EntityResult entityResult;
-            EntityREST entityREST = resourceContext.getResource(EntityREST.class);
 
             if (guids != null && !guids.isEmpty()) {
                 if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java b/webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
index 32c2cb8..77115d7 100644
--- a/webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
@@ -18,7 +18,6 @@
 
 package org.apache.atlas.web.resources;
 
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.catalog.BaseRequest;
 import org.apache.atlas.catalog.CollectionRequest;
 import org.apache.atlas.catalog.DefaultTypeSystem;
@@ -33,6 +32,7 @@ import org.apache.atlas.store.AtlasTypeDefStore;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
 import org.slf4j.Logger;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -58,6 +58,7 @@ import java.util.Map;
  */
 @Path("v1/entities")
 @Singleton
+@Service
 public class EntityService extends BaseService {
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.EntityService");
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
index 9f4a0bd..cba8ccf 100644
--- a/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
@@ -35,6 +35,7 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -48,6 +49,7 @@ import javax.ws.rs.core.Response;
 
 @Path("lineage")
 @Singleton
+@Service
 @Deprecated
 public class LineageResource {
     private static final Logger LOG = LoggerFactory.getLogger(DataSetLineageResource.class);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
index 32b4cae..d29c8da 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
@@ -33,6 +33,7 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -52,6 +53,7 @@ import java.util.Map;
  */
 @Path("discovery")
 @Singleton
+@Service
 @Deprecated
 public class MetadataDiscoveryResource {
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java b/webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
index b13810f..05b197f 100644
--- a/webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
@@ -18,7 +18,6 @@
 
 package org.apache.atlas.web.resources;
 
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.catalog.*;
 import org.apache.atlas.catalog.exception.CatalogException;
 import org.apache.atlas.catalog.exception.InvalidPayloadException;
@@ -28,9 +27,9 @@ import org.apache.atlas.store.AtlasTypeDefStore;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
 import org.slf4j.Logger;
+import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
-import javax.inject.Singleton;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -52,7 +51,7 @@ import java.util.Map;
  * Service which handles API requests for taxonomy and term resources.
  */
 @Path("v1/taxonomies")
-@Singleton
+@Component
 public class TaxonomyService extends BaseService {
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.TaxonomyService");
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
index 424ca58..08121d8 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
@@ -35,6 +35,7 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -63,15 +64,18 @@ import java.util.List;
  */
 @Path("types")
 @Singleton
+@Service
 @Deprecated
 public class TypesResource {
     private static final Logger LOG = LoggerFactory.getLogger(TypesResource.class);
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.TypesResource");
     private static AtlasTypeRegistry typeRegistry;
+    private final TypesREST typesREST;
 
     @Inject
-    public TypesResource(AtlasTypeRegistry typeRegistry) {
+    public TypesResource(AtlasTypeRegistry typeRegistry, TypesREST typesREST) {
         this.typeRegistry = typeRegistry;
+        this.typesREST = typesREST;
     }
 
     @Context
@@ -95,7 +99,6 @@ public class TypesResource {
             perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesResource.submit()");
         }
 
-        TypesREST typesRest = resourceContext.getResource(TypesREST.class);
         JSONArray typesResponse = new JSONArray();
 
         try {
@@ -106,7 +109,7 @@ public class TypesResource {
             }
 
             AtlasTypesDef createTypesDef  = TypeConverterUtil.toAtlasTypesDef(typeDefinition, typeRegistry);
-            AtlasTypesDef createdTypesDef = typesRest.createAtlasTypeDefs(createTypesDef);
+            AtlasTypesDef createdTypesDef = typesREST.createAtlasTypeDefs(createTypesDef);
             List<String>  typeNames       = TypeConverterUtil.getTypeNames(createdTypesDef);
 
             for (int i = 0; i < typeNames.size(); i++) {
@@ -164,7 +167,6 @@ public class TypesResource {
             perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesResource.update()");
         }
 
-        TypesREST typesRest = resourceContext.getResource(TypesREST.class);
         JSONArray typesResponse = new JSONArray();
         try {
             final String typeDefinition = Servlets.getRequestPayload(request);
@@ -174,7 +176,7 @@ public class TypesResource {
             }
 
             AtlasTypesDef updateTypesDef  = TypeConverterUtil.toAtlasTypesDef(typeDefinition, typeRegistry);
-            AtlasTypesDef updatedTypesDef = typesRest.updateAtlasTypeDefs(updateTypesDef);
+            AtlasTypesDef updatedTypesDef = typesREST.updateAtlasTypeDefs(updateTypesDef);
             List<String>  typeNames       = TypeConverterUtil.getTypeNames(updatedTypesDef);
 
             for (int i = 0; i < typeNames.size(); i++) {
@@ -287,10 +289,9 @@ public class TypesResource {
             perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesResource.getTypesByFilter(" + typeCategory + ", " + supertype + ", " + notsupertype + ")");
         }
 
-        TypesREST typesRest  = resourceContext.getResource(TypesREST.class);
         JSONObject response  = new JSONObject();
         try {
-            List<String> result = TypeConverterUtil.getTypeNames(typesRest.getTypeDefHeaders(request));
+            List<String> result = TypeConverterUtil.getTypeNames(typesREST.getTypeDefHeaders(request));
 
             response.put(AtlasClient.RESULTS, new JSONArray(result));
             response.put(AtlasClient.COUNT, result.size());

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
index edaf3ef..ea55021 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
@@ -23,6 +23,7 @@ import org.apache.atlas.discovery.AtlasDiscoveryService;
 import org.apache.atlas.model.discovery.AtlasSearchResult;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
+import org.springframework.stereotype.Service;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 
@@ -39,6 +40,7 @@ import javax.ws.rs.QueryParam;
  */
 @Path("v2/search")
 @Singleton
+@Service
 public class DiscoveryREST {
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.DiscoveryREST");
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
index 88222db..0f6eeb1 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
@@ -26,11 +26,9 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
 import org.apache.atlas.model.instance.ClassificationAssociateRequest;
 import org.apache.atlas.model.instance.EntityMutationResponse;
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
-import org.apache.atlas.repository.converters.AtlasInstanceConverter;
 import org.apache.atlas.repository.store.graph.AtlasEntityStore;
 import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream;
 import org.apache.atlas.repository.store.graph.v1.EntityStream;
-import org.apache.atlas.services.MetadataService;
 import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasTypeRegistry;
@@ -40,6 +38,7 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -66,22 +65,18 @@ import java.util.Map;
  */
 @Path("v2/entity")
 @Singleton
+@Service
 public class EntityREST {
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.EntityREST");
 
     public static final String PREFIX_ATTR = "attr:";
 
     private final AtlasTypeRegistry         typeRegistry;
-    private final AtlasInstanceConverter    instanceConverter;
-    private final MetadataService           metadataService;
     private final AtlasEntityStore          entitiesStore;
 
     @Inject
-    public EntityREST(AtlasTypeRegistry typeRegistry, AtlasInstanceConverter instanceConverter,
-                      MetadataService metadataService, AtlasEntityStore entitiesStore) {
+    public EntityREST(AtlasTypeRegistry typeRegistry, AtlasEntityStore entitiesStore) {
         this.typeRegistry    = typeRegistry;
-        this.instanceConverter = instanceConverter;
-        this.metadataService = metadataService;
         this.entitiesStore   = entitiesStore;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
index 2b19e73..8638ea6 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
@@ -26,6 +26,7 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
 import org.slf4j.Logger;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -44,6 +45,7 @@ import javax.ws.rs.core.Context;
  */
 @Path("v2/lineage")
 @Singleton
+@Service
 public class LineageREST {
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.LineageREST");
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
index 5d846cf..c32f36e 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
@@ -17,7 +17,6 @@
  */
 package org.apache.atlas.web.rest;
 
-import com.google.inject.Inject;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
 import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
@@ -33,7 +32,9 @@ import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
 import org.apache.http.annotation.Experimental;
 import org.slf4j.Logger;
+import org.springframework.stereotype.Service;
 
+import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
@@ -53,6 +54,7 @@ import java.util.Set;
  */
 @Path("v2/types")
 @Singleton
+@Service
 public class TypesREST {
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.TypesREST");
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/security/AtlasADAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasADAuthenticationProvider.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasADAuthenticationProvider.java
index d78990b..b123c52 100644
--- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasADAuthenticationProvider.java
+++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasADAuthenticationProvider.java
@@ -18,11 +18,6 @@
 
 package org.apache.atlas.web.security;
 
-import java.util.List;
-import java.util.Properties;
-
-import javax.annotation.PostConstruct;
-
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.web.model.User;
 import org.apache.commons.configuration.Configuration;
@@ -32,7 +27,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.ldap.core.support.LdapContextSource;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
-import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.ldap.DefaultSpringSecurityContextSource;
@@ -42,9 +36,12 @@ import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAu
 import org.springframework.security.ldap.search.FilterBasedLdapUserSearch;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.PostConstruct;
+import java.util.List;
+import java.util.Properties;
+
 @Component
-public class AtlasADAuthenticationProvider extends
-        AtlasAbstractAuthenticationProvider {
+public class AtlasADAuthenticationProvider extends AtlasAbstractAuthenticationProvider {
     private static Logger LOG = LoggerFactory.getLogger(AtlasADAuthenticationProvider.class);
 
     private String adURL;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java
index e55d2cf..f77cb01 100644
--- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java
+++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java
@@ -19,12 +19,9 @@
 
 package org.apache.atlas.web.security;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.Groups;
 import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.security.authentication.AuthenticationProvider;
@@ -35,14 +32,15 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.UserDetails;
 
-public abstract class AtlasAbstractAuthenticationProvider implements
-        AuthenticationProvider {
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AtlasAbstractAuthenticationProvider implements AuthenticationProvider {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasAbstractAuthenticationProvider.class);
 
     @Override
     public boolean supports(Class<?> authentication) {
-        return UsernamePasswordAuthenticationToken.class
-                .isAssignableFrom(authentication);
+        return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationFailureHandler.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationFailureHandler.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationFailureHandler.java
index 49a7e86..a117df6 100644
--- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationFailureHandler.java
+++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationFailureHandler.java
@@ -18,12 +18,12 @@
 
 package org.apache.atlas.web.security;
 
+import org.json.simple.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.json.simple.JSONObject;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.AuthenticationFailureHandler;
+import org.springframework.stereotype.Component;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 
+@Component
 public class AtlasAuthenticationFailureHandler implements AuthenticationFailureHandler {
 
     private static Logger LOG = LoggerFactory.getLogger(AtlasAuthenticationFailureHandler.class);
@@ -43,14 +44,12 @@ public class AtlasAuthenticationFailureHandler implements AuthenticationFailureH
         LOG.debug("Login Failure ", e);
 
         JSONObject json = new JSONObject();
-        ObjectMapper mapper = new ObjectMapper();
         json.put("msgDesc", e.getMessage());
 
-        String jsonAsStr = mapper.writeValueAsString(json);
         response.setContentType("application/json");
         response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
         response.setCharacterEncoding("UTF-8");
-        response.getWriter().write(jsonAsStr);
+        response.getWriter().write(json.toJSONString());
 
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationProvider.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationProvider.java
index 953d737..80d6604 100644
--- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationProvider.java
+++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationProvider.java
@@ -17,20 +17,19 @@
  */
 package org.apache.atlas.web.security;
 
-import javax.annotation.PostConstruct;
-
+import org.apache.atlas.ApplicationProperties;
+import org.apache.commons.configuration.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.stereotype.Component;
-import org.apache.atlas.ApplicationProperties;
-import org.apache.commons.configuration.Configuration;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
 
 @Component
-public class AtlasAuthenticationProvider extends
-        AtlasAbstractAuthenticationProvider {
+public class AtlasAuthenticationProvider extends AtlasAbstractAuthenticationProvider {
     private static final Logger LOG = LoggerFactory
             .getLogger(AtlasAuthenticationProvider.class);
 
@@ -44,22 +43,27 @@ public class AtlasAuthenticationProvider extends
 
     private boolean ssoEnabled = false;
 
-    @Autowired
-    AtlasLdapAuthenticationProvider ldapAuthenticationProvider;
+    final AtlasLdapAuthenticationProvider ldapAuthenticationProvider;
 
-    @Autowired
-    AtlasFileAuthenticationProvider fileAuthenticationProvider;
+    final AtlasFileAuthenticationProvider fileAuthenticationProvider;
 
-    @Autowired
-    AtlasADAuthenticationProvider adAuthenticationProvider;
+    final AtlasADAuthenticationProvider adAuthenticationProvider;
+
+    @Inject
+    public AtlasAuthenticationProvider(AtlasLdapAuthenticationProvider ldapAuthenticationProvider,
+                                       AtlasFileAuthenticationProvider fileAuthenticationProvider,
+                                       AtlasADAuthenticationProvider adAuthenticationProvider) {
+        this.ldapAuthenticationProvider = ldapAuthenticationProvider;
+        this.fileAuthenticationProvider = fileAuthenticationProvider;
+        this.adAuthenticationProvider = adAuthenticationProvider;
+    }
 
     @PostConstruct
     void setAuthenticationMethod() {
         try {
             Configuration configuration = ApplicationProperties.get();
 
-            this.fileAuthenticationMethodEnabled = configuration.getBoolean(
-                    FILE_AUTH_METHOD, true);
+            this.fileAuthenticationMethodEnabled = configuration.getBoolean(FILE_AUTH_METHOD, true);
 
             boolean ldapAuthenticationEnabled = configuration.getBoolean(LDAP_AUTH_METHOD, false);
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationSuccessHandler.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationSuccessHandler.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationSuccessHandler.java
index 2942e8e..e7a5d66 100644
--- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationSuccessHandler.java
+++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationSuccessHandler.java
@@ -18,12 +18,12 @@
 
 package org.apache.atlas.web.security;
 
+import org.json.simple.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.json.simple.JSONObject;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
+import org.springframework.stereotype.Component;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 
+@Component
 public class AtlasAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
 
     private static Logger LOG = LoggerFactory.getLogger(AuthenticationSuccessHandler.class);
@@ -41,7 +42,6 @@ public class AtlasAuthenticationSuccessHandler implements AuthenticationSuccessH
         LOG.debug("Login Success " + authentication.getPrincipal());
 
         JSONObject json = new JSONObject();
-        ObjectMapper mapper = new ObjectMapper();
         json.put("msgDesc", "Success");
 
         if (request.getSession() != null) { // incase of form based login mark it as local login in session
@@ -49,10 +49,9 @@ public class AtlasAuthenticationSuccessHandler implements AuthenticationSuccessH
             request.getServletContext().setAttribute(request.getSession().getId(), "locallogin");
         }
 
-        String jsonAsStr = mapper.writeValueAsString(json);
         response.setContentType("application/json");
         response.setStatus(HttpServletResponse.SC_OK);
         response.setCharacterEncoding("UTF-8");
-        response.getWriter().write(jsonAsStr);
+        response.getWriter().write(json.toJSONString());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/security/AtlasFileAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasFileAuthenticationProvider.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasFileAuthenticationProvider.java
index 1032b1c..f177fd4 100644
--- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasFileAuthenticationProvider.java
+++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasFileAuthenticationProvider.java
@@ -16,12 +16,9 @@
  */
 package org.apache.atlas.web.security;
 
-import java.util.Collection;
-
 import org.apache.atlas.web.dao.UserDao;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
@@ -30,6 +27,9 @@ import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.util.Collection;
  
 
 @Component
@@ -37,8 +37,12 @@ public class AtlasFileAuthenticationProvider extends AtlasAbstractAuthentication
 
     private static Logger logger = LoggerFactory.getLogger(AtlasFileAuthenticationProvider.class);
 
-    @Autowired
-    private UserDetailsService userDetailsService;
+    private final UserDetailsService userDetailsService;
+
+    @Inject
+    public AtlasFileAuthenticationProvider(UserDetailsService userDetailsService) {
+        this.userDetailsService = userDetailsService;
+    }
 
     @Override
     public Authentication authenticate(Authentication authentication) throws AuthenticationException {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/security/AtlasSecurityConfig.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasSecurityConfig.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasSecurityConfig.java
new file mode 100644
index 0000000..6b512af
--- /dev/null
+++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasSecurityConfig.java
@@ -0,0 +1,169 @@
+/**
+ * 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.security;
+
+import org.apache.atlas.web.filters.ActiveServerFilter;
+import org.apache.atlas.web.filters.AtlasAuthenticationEntryPoint;
+import org.apache.atlas.web.filters.AtlasAuthenticationFilter;
+import org.apache.atlas.web.filters.AtlasAuthorizationFilter;
+import org.apache.atlas.web.filters.AtlasCSRFPreventionFilter;
+import org.apache.atlas.web.filters.AtlasKnoxSSOAuthenticationFilter;
+import org.apache.atlas.web.filters.StaleTransactionCleanupFilter;
+import org.apache.commons.configuration.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
+import org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint;
+import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
+import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
+import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter;
+import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher;
+import org.springframework.security.web.util.matcher.RequestMatcher;
+
+import javax.inject.Inject;
+import java.util.LinkedHashMap;
+
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true)
+public class AtlasSecurityConfig extends WebSecurityConfigurerAdapter {
+    private static final Logger LOG = LoggerFactory.getLogger(AtlasSecurityConfig.class);
+
+    private final AtlasAuthenticationProvider authenticationProvider;
+    private final AtlasAuthenticationSuccessHandler successHandler;
+    private final AtlasAuthenticationFailureHandler failureHandler;
+    private final AtlasAuthorizationFilter atlasAuthorizationFilter;
+    private final AtlasKnoxSSOAuthenticationFilter ssoAuthenticationFilter;
+    private final AtlasAuthenticationFilter atlasAuthenticationFilter;
+    private final AtlasCSRFPreventionFilter csrfPreventionFilter;
+    private final AtlasAuthenticationEntryPoint atlasAuthenticationEntryPoint;
+
+    // Our own Atlas filters need to be registered as well
+    private final Configuration configuration;
+    private final StaleTransactionCleanupFilter staleTransactionCleanupFilter;
+    private final ActiveServerFilter activeServerFilter;
+
+    @Inject
+    public AtlasSecurityConfig(AtlasKnoxSSOAuthenticationFilter ssoAuthenticationFilter,
+                               AtlasCSRFPreventionFilter atlasCSRFPreventionFilter,
+                               AtlasAuthenticationFilter atlasAuthenticationFilter,
+                               AtlasAuthenticationProvider authenticationProvider,
+                               AtlasAuthenticationSuccessHandler successHandler,
+                               AtlasAuthenticationFailureHandler failureHandler,
+                               AtlasAuthorizationFilter atlasAuthorizationFilter,
+                               AtlasAuthenticationEntryPoint atlasAuthenticationEntryPoint,
+                               Configuration configuration,
+                               StaleTransactionCleanupFilter staleTransactionCleanupFilter,
+                               ActiveServerFilter activeServerFilter) {
+        this.ssoAuthenticationFilter = ssoAuthenticationFilter;
+        this.csrfPreventionFilter = atlasCSRFPreventionFilter;
+        this.atlasAuthenticationFilter = atlasAuthenticationFilter;
+        this.authenticationProvider = authenticationProvider;
+        this.successHandler = successHandler;
+        this.failureHandler = failureHandler;
+        this.atlasAuthorizationFilter = atlasAuthorizationFilter;
+        this.atlasAuthenticationEntryPoint = atlasAuthenticationEntryPoint;
+        this.configuration = configuration;
+        this.staleTransactionCleanupFilter = staleTransactionCleanupFilter;
+        this.activeServerFilter = activeServerFilter;
+    }
+
+    public BasicAuthenticationEntryPoint getAuthenticationEntryPoint() {
+        BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint();
+        basicAuthenticationEntryPoint.setRealmName("atlas.com");
+        return basicAuthenticationEntryPoint;
+    }
+
+    public DelegatingAuthenticationEntryPoint getDelegatingAuthenticationEntryPoint() {
+        LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPointMap = new LinkedHashMap<>();
+        entryPointMap.put(new RequestHeaderRequestMatcher("User-Agent", "Mozilla"), atlasAuthenticationEntryPoint);
+        DelegatingAuthenticationEntryPoint entryPoint = new DelegatingAuthenticationEntryPoint(entryPointMap);
+        entryPoint.setDefaultEntryPoint(getAuthenticationEntryPoint());
+        return entryPoint;
+    }
+
+    @Inject
+    protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) {
+        authenticationManagerBuilder.authenticationProvider(authenticationProvider);
+    }
+
+    @Override
+    public void configure(WebSecurity web) throws Exception {
+        web.ignoring()
+                .antMatchers("/login.jsp",
+                        "/css/**",
+                        "/img/**",
+                        "/libs/**",
+                        "/js/**",
+                        "/ieerror.html",
+                        "/api/atlas/admin/status",
+                        "/api/atlas/admin/metrics");
+    }
+
+    protected void configure(HttpSecurity httpSecurity) throws Exception {
+
+        //@formatter:off
+        httpSecurity
+                .authorizeRequests().anyRequest().authenticated()
+                .and()
+                    .headers().disable()
+                    .servletApi()
+                .and()
+                    .csrf().disable()
+                    .sessionManagement()
+                    .enableSessionUrlRewriting(false)
+                    .sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
+                    .sessionFixation()
+                    .newSession()
+                .and()
+                    .formLogin()
+                        .loginPage("/login.jsp")
+                        .loginProcessingUrl("/j_spring_security_check")
+                        .successHandler(successHandler)
+                        .failureHandler(failureHandler)
+                        .usernameParameter("j_username")
+                        .passwordParameter("j_password")
+                .and()
+                    .logout()
+                        .logoutSuccessUrl("/login.jsp")
+                        .deleteCookies("ATLASSESSIONID")
+                        .logoutUrl("/logout.html")
+                .and()
+                    .httpBasic()
+                    .authenticationEntryPoint(getDelegatingAuthenticationEntryPoint());
+        //@formatter:on
+
+        if (configuration.getBoolean("atlas.server.ha.enabled", false)) {
+            LOG.info("Atlas is in HA Mode, enabling ActiveServerFilter");
+            httpSecurity.addFilterAfter(activeServerFilter, BasicAuthenticationFilter.class);
+        }
+        httpSecurity
+                .addFilterAfter(staleTransactionCleanupFilter, BasicAuthenticationFilter.class)
+                .addFilterAfter(ssoAuthenticationFilter, BasicAuthenticationFilter.class)
+                .addFilterAfter(atlasAuthenticationFilter, SecurityContextHolderAwareRequestFilter.class)
+                .addFilterAfter(csrfPreventionFilter, AtlasAuthenticationFilter.class)
+                .addFilterAfter(atlasAuthorizationFilter, FilterSecurityInterceptor.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorModule.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorModule.java b/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorModule.java
deleted file mode 100644
index 1f67f9f..0000000
--- a/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorModule.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.service;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.multibindings.Multibinder;
-import org.apache.atlas.listener.ActiveStateChangeHandler;
-import org.apache.atlas.notification.NotificationHookConsumer;
-import org.apache.atlas.repository.audit.HBaseBasedAuditRepository;
-import org.apache.atlas.repository.graph.GraphBackedSearchIndexer;
-import org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1;
-import org.apache.atlas.service.Service;
-import org.apache.atlas.services.DefaultMetadataService;
-
-/**
- * A Guice module that registers the handlers of High Availability state change handlers and other services.
- *
- * Any new handler that should react to HA state change should be registered here.
- */
-public class ActiveInstanceElectorModule extends AbstractModule {
-    @Override
-    protected void configure() {
-        Multibinder<ActiveStateChangeHandler> activeStateChangeHandlerBinder =
-                Multibinder.newSetBinder(binder(), ActiveStateChangeHandler.class);
-        activeStateChangeHandlerBinder.addBinding().to(GraphBackedSearchIndexer.class);
-        activeStateChangeHandlerBinder.addBinding().to(DefaultMetadataService.class);
-        activeStateChangeHandlerBinder.addBinding().to(NotificationHookConsumer.class);
-        activeStateChangeHandlerBinder.addBinding().to(HBaseBasedAuditRepository.class);
-        activeStateChangeHandlerBinder.addBinding().to(AtlasTypeDefGraphStoreV1.class);
-
-        Multibinder<Service> serviceBinder = Multibinder.newSetBinder(binder(), Service.class);
-        serviceBinder.addBinding().to(ActiveInstanceElectorService.class);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorService.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorService.java b/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorService.java
index 8e649f7..5071204 100644
--- a/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorService.java
+++ b/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorService.java
@@ -18,10 +18,6 @@
 
 package org.apache.atlas.web.service;
 
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.ha.AtlasServerIdSelector;
 import org.apache.atlas.ha.HAConfiguration;
@@ -32,10 +28,14 @@ import org.apache.curator.framework.recipes.leader.LeaderLatch;
 import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Inject;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Set;
 
 /**
  * A service that implements leader election to determine whether this Atlas server is Active.
@@ -47,7 +47,9 @@ import java.util.Collection;
  * on being removed from leadership, this instance is treated as a passive instance and calls
  * {@link ActiveStateChangeHandler}s to deactivate them.
  */
-@Singleton
+
+@Component
+@Order(1)
 public class ActiveInstanceElectorService implements Service, LeaderLatchListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(ActiveInstanceElectorService.class);
@@ -55,7 +57,7 @@ public class ActiveInstanceElectorService implements Service, LeaderLatchListene
     private final Configuration configuration;
     private final ServiceState serviceState;
     private final ActiveInstanceState activeInstanceState;
-    private Collection<Provider<ActiveStateChangeHandler>> activeStateChangeHandlerProviders;
+    private Set<ActiveStateChangeHandler> activeStateChangeHandlerProviders;
     private Collection<ActiveStateChangeHandler> activeStateChangeHandlers;
     private CuratorFactory curatorFactory;
     private LeaderLatch leaderLatch;
@@ -68,17 +70,8 @@ public class ActiveInstanceElectorService implements Service, LeaderLatchListene
      * @throws AtlasException
      */
     @Inject
-    public ActiveInstanceElectorService(
-            Collection<Provider<ActiveStateChangeHandler>> activeStateChangeHandlerProviders,
-            CuratorFactory curatorFactory, ActiveInstanceState activeInstanceState,
-            ServiceState serviceState)
-            throws AtlasException {
-        this(ApplicationProperties.get(), activeStateChangeHandlerProviders,
-                curatorFactory, activeInstanceState, serviceState);
-    }
-
     ActiveInstanceElectorService(Configuration configuration,
-                                 Collection<Provider<ActiveStateChangeHandler>> activeStateChangeHandlerProviders,
+                                 Set<ActiveStateChangeHandler> activeStateChangeHandlerProviders,
                                  CuratorFactory curatorFactory, ActiveInstanceState activeInstanceState,
                                  ServiceState serviceState) {
         this.configuration = configuration;
@@ -164,10 +157,7 @@ public class ActiveInstanceElectorService implements Service, LeaderLatchListene
 
     private void cacheActiveStateChangeHandlers() {
         if (activeStateChangeHandlers.size()==0) {
-            for (Provider<ActiveStateChangeHandler> provider : activeStateChangeHandlerProviders) {
-                ActiveStateChangeHandler handler = provider.get();
-                activeStateChangeHandlers.add(handler);
-            }
+            activeStateChangeHandlers.addAll(activeStateChangeHandlerProviders);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceState.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceState.java b/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceState.java
index ee3b829..c6b4a6f 100644
--- a/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceState.java
+++ b/webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceState.java
@@ -18,7 +18,6 @@
 
 package org.apache.atlas.web.service;
 
-import com.google.inject.Inject;
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.AtlasException;
@@ -33,8 +32,10 @@ import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 import scala.actors.threadpool.Arrays;
 
+import javax.inject.Inject;
 import java.nio.charset.Charset;
 import java.util.List;
 
@@ -45,6 +46,7 @@ import java.util.List;
  * under a read-write lock implemented using Curator's {@link InterProcessReadWriteLock} to
  * provide for safety across multiple processes.
  */
+@Component
 public class ActiveInstanceState {
 
     private final Configuration configuration;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java b/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java
index 50351f0..7c89055 100644
--- a/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java
+++ b/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java
@@ -20,7 +20,6 @@ package org.apache.atlas.web.service;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Charsets;
-import com.google.inject.Singleton;
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.ha.HAConfiguration;
@@ -36,7 +35,9 @@ import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.zookeeper.data.ACL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Singleton;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
@@ -47,6 +48,7 @@ import java.util.List;
  * Allows for stubbing in tests.
  */
 @Singleton
+@Component
 public class CuratorFactory {
 
     private static final Logger LOG = LoggerFactory.getLogger(CuratorFactory.class);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/service/ServiceModule.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/service/ServiceModule.java b/webapp/src/main/java/org/apache/atlas/web/service/ServiceModule.java
deleted file mode 100644
index 2128b7c..0000000
--- a/webapp/src/main/java/org/apache/atlas/web/service/ServiceModule.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.service;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.multibindings.Multibinder;
-import org.apache.atlas.kafka.KafkaNotification;
-import org.apache.atlas.listener.EntityChangeListener;
-import org.apache.atlas.notification.NotificationHookConsumer;
-import org.apache.atlas.notification.NotificationEntityChangeListener;
-import org.apache.atlas.service.Service;
-
-public class ServiceModule extends AbstractModule {
-    @Override
-    protected void configure() {
-        Multibinder<Service> serviceBinder = Multibinder.newSetBinder(binder(), Service.class);
-        serviceBinder.addBinding().to(KafkaNotification.class);
-        serviceBinder.addBinding().to(NotificationHookConsumer.class);
-
-        //Add NotificationEntityChangeListener as EntityChangeListener
-        Multibinder<EntityChangeListener> entityChangeListenerBinder =
-                Multibinder.newSetBinder(binder(), EntityChangeListener.class);
-        entityChangeListenerBinder.addBinding().to(NotificationEntityChangeListener.class);
-    }
-}