ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stoa...@apache.org
Subject [2/3] ambari git commit: AMBARI-15646. Audit Log Code Cleanup & Safety. (Daniel Gergely via stoader)
Date Thu, 07 Apr 2016 18:11:47 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
index 3f5e2d0..30fd377 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
@@ -31,9 +31,10 @@ import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.AddRepositoryVersionRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.ChangeRepositoryVersionRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.DeleteRepositoryVersionRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
+import org.apache.ambari.server.controller.internal.OperatingSystemResourceProvider;
+import org.apache.ambari.server.controller.internal.RepositoryResourceProvider;
+import org.apache.ambari.server.controller.internal.RepositoryVersionResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -92,10 +93,10 @@ public class RepositoryVersionEventCreator implements RequestAuditEventCreator {
           .withResultStatus(result.getStatus())
           .withUrl(request.getURI())
           .withRemoteIp(request.getRemoteAddress())
-          .withStackName(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "stack_name")))
-          .withStackVersion(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "stack_version")))
-          .withDisplayName(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "display_name")))
-          .withRepoVersion(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "repository_version")))
+          .withStackName(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID))
+          .withStackVersion(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID))
+          .withDisplayName(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID))
+          .withRepoVersion(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID))
           .withRepos(getRepos(request))
           .build();
       case PUT:
@@ -105,10 +106,10 @@ public class RepositoryVersionEventCreator implements RequestAuditEventCreator {
           .withResultStatus(result.getStatus())
           .withUrl(request.getURI())
           .withRemoteIp(request.getRemoteAddress())
-          .withStackName(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "stack_name")))
-          .withStackVersion(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "stack_version")))
-          .withDisplayName(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "display_name")))
-          .withRepoVersion(getProperty(request, PropertyHelper.getPropertyId("RepositoryVersions", "repository_version")))
+          .withStackName(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID))
+          .withStackVersion(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID))
+          .withDisplayName(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID))
+          .withRepoVersion(RequestAuditEventCreatorHelper.getProperty(request, RepositoryVersionResourceProvider.REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID))
           .withRepos(getRepos(request))
           .build();
       case DELETE:
@@ -157,7 +158,7 @@ public class RepositoryVersionEventCreator implements RequestAuditEventCreator {
     for (Object entry : set) {
       if (entry instanceof Map) {
         Map<String, Object> map = (Map<String, Object>) entry;
-        String osType = (String) map.get(PropertyHelper.getPropertyId("OperatingSystems", "os_type"));
+        String osType = (String) map.get(OperatingSystemResourceProvider.OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID);
         if (!result.containsKey(osType)) {
           result.put(osType, new LinkedList<Map<String, String>>());
         }
@@ -182,28 +183,13 @@ public class RepositoryVersionEventCreator implements RequestAuditEventCreator {
    */
   private Map<String, String> buildResultRepo(Map<String, String> repo) {
     Map<String, String> m = repo;
-    String repoId = m.get(PropertyHelper.getPropertyId("Repositories", "repo_id"));
-    String repo_name = m.get(PropertyHelper.getPropertyId("Repositories", "repo_name"));
-    String baseUrl = m.get(PropertyHelper.getPropertyId("Repositories", "base_url"));
+    String repoId = m.get(RepositoryResourceProvider.REPOSITORY_REPO_ID_PROPERTY_ID);
+    String repo_name = m.get(RepositoryResourceProvider.REPOSITORY_REPO_NAME_PROPERTY_ID);
+    String baseUrl = m.get(RepositoryResourceProvider.REPOSITORY_BASE_URL_PROPERTY_ID);
     Map<String, String> resultMap = new HashMap<>();
     resultMap.put("repo_id", repoId);
     resultMap.put("repo_name", repo_name);
     resultMap.put("base_url", baseUrl);
     return resultMap;
   }
-
-  /**
-   * Returns property from the request based on the propertyId parameter
-   * @param request
-   * @param properyId
-   * @return
-   */
-  private String getProperty(Request request, String properyId) {
-    if (!request.getBody().getPropertySets().isEmpty()) {
-      return String.valueOf(request.getBody().getPropertySets().iterator().next().get(properyId));
-    }
-    return null;
-  }
-
-
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreator.java
new file mode 100644
index 0000000..5c3ea65
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreator.java
@@ -0,0 +1,59 @@
+/*
+ * 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.ambari.server.audit.request.eventcreator;
+
+import java.util.Set;
+
+import org.apache.ambari.server.api.services.Request;
+import org.apache.ambari.server.api.services.Result;
+import org.apache.ambari.server.api.services.ResultStatus;
+import org.apache.ambari.server.audit.event.AuditEvent;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * This interface must be implemented by the plugins for the request audit logger
+ * in order to make custom {@link AuditEvent}s based on {@link org.apache.ambari.server.api.services.Request.Type}s
+ * and {@link org.apache.ambari.server.controller.spi.Resource.Type}
+ */
+public interface RequestAuditEventCreator {
+
+  /**
+   * @return the set of {@link org.apache.ambari.server.api.services.Request.Type}s that are handled by this creator
+   */
+  Set<Request.Type> getRequestTypes();
+
+  /**
+   * @return the {@link org.apache.ambari.server.controller.spi.Resource.Type}s that is handled by this creator
+   */
+  Set<Resource.Type> getResourceTypes();
+
+  /**
+   * @return the {@link ResultStatus}es that is handled by this creator
+   */
+  Set<ResultStatus.STATUS> getResultStatuses();
+
+  /**
+   * Creates and {@link AuditEvent}
+   * @param request HTTP request object
+   * @param result HTTP result object
+   * @return an {@link AuditEvent}
+   */
+  AuditEvent createAuditEvent(Request request, Result result);
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
new file mode 100644
index 0000000..a02428f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
@@ -0,0 +1,112 @@
+/*
+ * 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.ambari.server.audit.request.eventcreator;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ambari.server.api.services.Request;
+
+/**
+ * The purpose of this class is to retrieve information from {@link Request} objects.
+ * This information can be a single value or a list of values.
+ */
+public class RequestAuditEventCreatorHelper {
+
+  /**
+   * Returns a named property from a request
+   * @param request
+   * @param propertyName
+   * @return
+   */
+  public static String getNamedProperty(Request request, String propertyName) {
+    if (isValid(request, propertyName)) {
+      return String.valueOf(request.getBody().getNamedPropertySets().iterator().next().getProperties().get(propertyName));
+    }
+    return null;
+  }
+
+  /**
+   * Returns a list of named properties from a request
+   * @param request
+   * @param propertyName
+   * @return
+   */
+  public static List<String> getNamedPropertyList(Request request, String propertyName) {
+    if (isValidList(request, propertyName)) {
+      List<String> list = (List<String>) request.getBody().getNamedPropertySets().iterator().next().getProperties().get(propertyName);
+      if (list != null) {
+        return list;
+      }
+    }
+    return Collections.emptyList();
+  }
+
+  /**
+   * Checks if the property is valid: can be found and has correct type
+   * @param request
+   * @param propertyName
+   * @return
+   */
+  private static boolean isValid(Request request, String propertyName) {
+    return !request.getBody().getNamedPropertySets().isEmpty() &&
+      request.getBody().getNamedPropertySets().iterator().next().getProperties() != null &&
+      request.getBody().getNamedPropertySets().iterator().next().getProperties().get(propertyName) instanceof String;
+  }
+
+  /**
+   * Checks if the property is a valid list: can be found and has correct type
+   * @param request
+   * @param propertyName
+   * @return
+   */
+  private static boolean isValidList(Request request, String propertyName) {
+    return !request.getBody().getNamedPropertySets().isEmpty() &&
+      request.getBody().getNamedPropertySets().iterator().next().getProperties() != null &&
+      request.getBody().getNamedPropertySets().iterator().next().getProperties().get(propertyName) instanceof List;
+  }
+
+  /**
+   * Returns a property from a request
+   * @param request
+   * @param propertyName
+   * @return
+   */
+  public static String getProperty(Request request, String propertyName) {
+    List<String> list = getPropertyList(request, propertyName);
+    return list.isEmpty() ? null : list.get(0);
+  }
+
+  /**
+   * Returns a list of properties from a request
+   * @param request
+   * @param propertyName
+   * @return
+   */
+  public static List<String> getPropertyList(Request request, String propertyName) {
+    List<String> list = new LinkedList<String>();
+    for (Map<String, Object> propertyMap : request.getBody().getPropertySets()) {
+      String userName = String.valueOf(propertyMap.get(propertyName));
+      list.add(userName);
+    }
+    return list;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestEventCreator.java
index 3a33114..075e328 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestEventCreator.java
@@ -25,7 +25,6 @@ import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.AddRequestRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
 import org.apache.ambari.server.controller.internal.RequestOperationLevel;
 import org.apache.ambari.server.controller.spi.Resource;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceConfigDownloadEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceConfigDownloadEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceConfigDownloadEventCreator.java
index 0999010..7da45c2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceConfigDownloadEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceConfigDownloadEventCreator.java
@@ -25,7 +25,6 @@ import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.ClientConfigDownloadRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
 import org.apache.ambari.server.controller.spi.Resource;
 
 import com.google.common.collect.ImmutableSet;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceEventCreator.java
index 65d94f9..0a49e6f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ServiceEventCreator.java
@@ -27,10 +27,9 @@ import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.DeleteServiceRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.StartOperationRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
 import org.apache.ambari.server.controller.internal.RequestOperationLevel;
+import org.apache.ambari.server.controller.internal.ServiceResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -120,12 +119,12 @@ public class ServiceEventCreator implements RequestAuditEventCreator {
    * @return
    */
   private String getOperation(Request request) {
-    if (request.getBody().getRequestInfoProperties().containsKey(RequestOperationLevel.OPERATION_LEVEL_ID)) {
+    if (request.getBody().getRequestInfoProperties() != null && request.getBody().getRequestInfoProperties().containsKey(RequestOperationLevel.OPERATION_LEVEL_ID)) {
       String operation = "";
       if ("CLUSTER".equals(request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_LEVEL_ID))) {
         for (Map<String, Object> map : request.getBody().getPropertySets()) {
-          if (map.containsKey(PropertyHelper.getPropertyId("ServiceInfo", "state"))) {
-            operation = String.valueOf(map.get(PropertyHelper.getPropertyId("ServiceInfo", "state"))) + ": all services"
+          if (map.containsKey(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID)) {
+            operation = String.valueOf(map.get(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID)) + ": all services"
               + " (" + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_CLUSTER_ID) + ")";
             break;
           }
@@ -133,8 +132,8 @@ public class ServiceEventCreator implements RequestAuditEventCreator {
       }
       if ("SERVICE".equals(request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_LEVEL_ID))) {
         for (Map<String, Object> map : request.getBody().getPropertySets()) {
-          if (map.containsKey(PropertyHelper.getPropertyId("ServiceInfo", "state"))) {
-            operation = String.valueOf(map.get(PropertyHelper.getPropertyId("ServiceInfo", "state"))) + ": " + map.get(PropertyHelper.getPropertyId("ServiceInfo", "service_name"))
+          if (map.containsKey(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID)) {
+            operation = String.valueOf(map.get(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID)) + ": " + map.get(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID)
               + " (" + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_CLUSTER_ID) + ")";
             break;
           }
@@ -144,8 +143,8 @@ public class ServiceEventCreator implements RequestAuditEventCreator {
     }
 
     for (Map<String, Object> map : request.getBody().getPropertySets()) {
-      if (map.containsKey(PropertyHelper.getPropertyId("ServiceInfo", "maintenance_state"))) {
-        return "Turn " + map.get(PropertyHelper.getPropertyId("ServiceInfo", "maintenance_state")) + " Maintenance Mode for " + map.get(PropertyHelper.getPropertyId("ServiceInfo", "service_name"));
+      if (map.containsKey(ServiceResourceProvider.SERVICE_MAINTENANCE_STATE_PROPERTY_ID)) {
+        return "Turn " + map.get(ServiceResourceProvider.SERVICE_MAINTENANCE_STATE_PROPERTY_ID) + " Maintenance Mode for " + map.get(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID);
       }
     }
     return null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UnauthorizedEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UnauthorizedEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UnauthorizedEventCreator.java
index db3c934..64644fb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UnauthorizedEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UnauthorizedEventCreator.java
@@ -25,7 +25,6 @@ import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AccessUnauthorizedAuditEvent;
 import org.apache.ambari.server.audit.event.AuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
 import org.apache.ambari.server.controller.spi.Resource;
 
 import com.google.common.collect.ImmutableSet;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeEventCreator.java
index f9f4152..456aa00 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeEventCreator.java
@@ -25,9 +25,8 @@ import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.AddUpgradeRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
+import org.apache.ambari.server.controller.internal.UpgradeResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -84,23 +83,10 @@ public class UpgradeEventCreator implements RequestAuditEventCreator {
       .withResultStatus(result.getStatus())
       .withUrl(request.getURI())
       .withRemoteIp(request.getRemoteAddress())
-      .withRepositoryVersion(getProperty(request, "repository_version"))
-      .withUpgradeType(getProperty(request, "upgrade_type"))
-      .withClusterName(getProperty(request, "cluster_name"))
+      .withRepositoryVersion(RequestAuditEventCreatorHelper.getProperty(request, UpgradeResourceProvider.UPGRADE_VERSION))
+      .withUpgradeType(RequestAuditEventCreatorHelper.getProperty(request, UpgradeResourceProvider.UPGRADE_TYPE))
+      .withClusterName(RequestAuditEventCreatorHelper.getProperty(request, UpgradeResourceProvider.UPGRADE_CLUSTER_NAME))
       .build();
 
   }
-
-  /**
-   * Returns property from the request based on the propertyName parameter
-   * @param request
-   * @param propertyName
-   * @return
-   */
-  private String getProperty(Request request, String propertyName) {
-    if (!request.getBody().getPropertySets().isEmpty()) {
-      return String.valueOf(request.getBody().getPropertySets().iterator().next().get(PropertyHelper.getPropertyId("Upgrade", propertyName)));
-    }
-    return null;
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeItemEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeItemEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeItemEventCreator.java
index 1869909..2919388 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeItemEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UpgradeItemEventCreator.java
@@ -25,7 +25,7 @@ import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.UpdateUpgradeItemRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
+import org.apache.ambari.server.controller.internal.UpgradeItemResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
@@ -84,23 +84,9 @@ public class UpgradeItemEventCreator implements RequestAuditEventCreator {
       .withResultStatus(result.getStatus())
       .withUrl(request.getURI())
       .withRemoteIp(request.getRemoteAddress())
-      .withStatus(getProperty(request, "status"))
-      .withStageId(getProperty(request, "stage_id"))
-      .withRequestId(getProperty(request, "request_id"))
+      .withStatus(RequestAuditEventCreatorHelper.getProperty(request, PropertyHelper.getPropertyId("UpgradeItem", "status")))
+      .withStageId(RequestAuditEventCreatorHelper.getProperty(request, UpgradeItemResourceProvider.UPGRADE_ITEM_STAGE_ID))
+      .withRequestId(RequestAuditEventCreatorHelper.getProperty(request, UpgradeItemResourceProvider.UPGRADE_REQUEST_ID))
       .build();
-
-  }
-
-  /**
-   * Returns property from the request based on the propertyName parameter
-   * @param request
-   * @param propertyName
-   * @return
-   */
-  private String getProperty(Request request, String propertyName) {
-    if (!request.getBody().getPropertySets().isEmpty()) {
-      return String.valueOf(request.getBody().getPropertySets().iterator().next().get(PropertyHelper.getPropertyId("UpgradeItem", propertyName)));
-    }
-    return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UserEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UserEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UserEventCreator.java
index 89f0755..54d02a7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UserEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/UserEventCreator.java
@@ -29,9 +29,8 @@ import org.apache.ambari.server.audit.event.request.AdminUserRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.CreateUserRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.DeleteUserRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.UserPasswordChangeRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
+import org.apache.ambari.server.controller.internal.UserResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -149,7 +148,7 @@ public class UserEventCreator implements RequestAuditEventCreator {
    * @return
    */
   private boolean isAdmin(Request request) {
-    return hasAdmin(request) && "true".equals(request.getBody().getPropertySets().iterator().next().get(PropertyHelper.getPropertyId("Users", "admin")));
+    return hasAdmin(request) && "true".equals(RequestAuditEventCreatorHelper.getProperty(request, UserResourceProvider.USER_ADMIN_PROPERTY_ID));
   }
 
   /**
@@ -158,7 +157,7 @@ public class UserEventCreator implements RequestAuditEventCreator {
    * @return
    */
   private boolean isActive(Request request) {
-    return hasActive(request) && "true".equals(request.getBody().getPropertySets().iterator().next().get(PropertyHelper.getPropertyId("Users", "active")));
+    return hasActive(request) && "true".equals(RequestAuditEventCreatorHelper.getProperty(request, UserResourceProvider.USER_ACTIVE_PROPERTY_ID));
   }
 
   /**
@@ -167,7 +166,7 @@ public class UserEventCreator implements RequestAuditEventCreator {
    * @return
    */
   private boolean hasAdmin(Request request) {
-    return !request.getBody().getPropertySets().isEmpty() && request.getBody().getPropertySets().iterator().next().containsKey(PropertyHelper.getPropertyId("Users", "admin"));
+    return !request.getBody().getPropertySets().isEmpty() && request.getBody().getPropertySets().iterator().next().containsKey(UserResourceProvider.USER_ADMIN_PROPERTY_ID);
   }
 
   /**
@@ -176,7 +175,7 @@ public class UserEventCreator implements RequestAuditEventCreator {
    * @return
    */
   private boolean hasActive(Request request) {
-    return !request.getBody().getPropertySets().isEmpty() && request.getBody().getPropertySets().iterator().next().containsKey(PropertyHelper.getPropertyId("Users", "active"));
+    return !request.getBody().getPropertySets().isEmpty() && request.getBody().getPropertySets().iterator().next().containsKey(UserResourceProvider.USER_ACTIVE_PROPERTY_ID);
   }
 
   /**
@@ -185,7 +184,7 @@ public class UserEventCreator implements RequestAuditEventCreator {
    * @return
    */
   private boolean hasOldPassword(Request request) {
-    return !request.getBody().getPropertySets().isEmpty() && request.getBody().getPropertySets().iterator().next().containsKey(PropertyHelper.getPropertyId("Users", "old_password"));
+    return !request.getBody().getPropertySets().isEmpty() && request.getBody().getPropertySets().iterator().next().containsKey(UserResourceProvider.USER_OLD_PASSWORD_PROPERTY_ID);
   }
 
   /**
@@ -195,7 +194,7 @@ public class UserEventCreator implements RequestAuditEventCreator {
    */
   private String getUsername(Request request) {
     if (!request.getBody().getPropertySets().isEmpty()) {
-      return String.valueOf(request.getBody().getPropertySets().iterator().next().get(PropertyHelper.getPropertyId("Users", "user_name")));
+      return String.valueOf(request.getBody().getPropertySets().iterator().next().get(UserResourceProvider.USER_USERNAME_PROPERTY_ID));
     }
     return null;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java
index 081f3d3..73277cd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java
@@ -24,7 +24,6 @@ import org.apache.ambari.server.api.services.Request;
 import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
 import org.apache.ambari.server.controller.spi.Resource;
 
 import com.google.common.collect.ImmutableSet;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewInstanceEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewInstanceEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewInstanceEventCreator.java
index a9a3fcd..2197380 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewInstanceEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewInstanceEventCreator.java
@@ -27,9 +27,8 @@ import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.AddViewInstanceRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.ChangeViewInstanceRequestAuditEvent;
 import org.apache.ambari.server.audit.event.request.DeleteViewInstanceRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
+import org.apache.ambari.server.controller.internal.ViewInstanceResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -89,11 +88,11 @@ public class ViewInstanceEventCreator implements RequestAuditEventCreator {
           .withResultStatus(result.getStatus())
           .withUrl(request.getURI())
           .withRemoteIp(request.getRemoteAddress())
-          .withType(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "view_name")))
-          .withVersion(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "version")))
-          .withName(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "instance_name")))
-          .withDisplayName(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "label")))
-          .withDescription(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "description")))
+          .withType(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.VIEW_NAME_PROPERTY_ID))
+          .withVersion(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.VIEW_VERSION_PROPERTY_ID))
+          .withName(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.INSTANCE_NAME_PROPERTY_ID))
+          .withDisplayName(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.LABEL_PROPERTY_ID))
+          .withDescription(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.DESCRIPTION_PROPERTY_ID))
           .build();
 
       case PUT:
@@ -103,11 +102,11 @@ public class ViewInstanceEventCreator implements RequestAuditEventCreator {
           .withResultStatus(result.getStatus())
           .withUrl(request.getURI())
           .withRemoteIp(request.getRemoteAddress())
-          .withType(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "view_name")))
-          .withVersion(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "version")))
-          .withName(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "instance_name")))
-          .withDisplayName(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "label")))
-          .withDescription(getProperty(request, PropertyHelper.getPropertyId("ViewInstanceInfo", "description")))
+          .withType(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.VIEW_NAME_PROPERTY_ID))
+          .withVersion(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.VIEW_VERSION_PROPERTY_ID))
+          .withName(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.INSTANCE_NAME_PROPERTY_ID))
+          .withDisplayName(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.LABEL_PROPERTY_ID))
+          .withDescription(RequestAuditEventCreatorHelper.getProperty(request, ViewInstanceResourceProvider.DESCRIPTION_PROPERTY_ID))
           .build();
 
       case DELETE:
@@ -126,18 +125,4 @@ public class ViewInstanceEventCreator implements RequestAuditEventCreator {
         return null;
     }
   }
-
-  /**
-   * Returns property from the requet based on the propertyId parameter
-   * @param request
-   * @param properyId
-   * @return
-   */
-  private String getProperty(Request request, String properyId) {
-    if (!request.getBody().getPropertySets().isEmpty()) {
-      return String.valueOf(request.getBody().getPropertySets().iterator().next().get(properyId));
-    }
-    return null;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewPrivilegeEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewPrivilegeEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewPrivilegeEventCreator.java
index d2d7bd9..56d35c0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewPrivilegeEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ViewPrivilegeEventCreator.java
@@ -29,9 +29,11 @@ import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultStatus;
 import org.apache.ambari.server.audit.event.AuditEvent;
 import org.apache.ambari.server.audit.event.request.ViewPrivilegeChangeRequestAuditEvent;
-import org.apache.ambari.server.audit.request.RequestAuditEventCreator;
+import org.apache.ambari.server.controller.internal.ViewPrivilegeResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.entities.PrincipalTypeEntity;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.User;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -83,8 +85,8 @@ public class ViewPrivilegeEventCreator implements RequestAuditEventCreator {
   public AuditEvent createAuditEvent(Request request, Result result) {
 
 
-    Map<String, List<String>> users = getEntities(request, "USER");
-    Map<String, List<String>> groups = getEntities(request, "GROUP");
+    Map<String, List<String>> users = getEntities(request, PrincipalTypeEntity.USER_PRINCIPAL_TYPE_NAME);
+    Map<String, List<String>> groups = getEntities(request, PrincipalTypeEntity.GROUP_PRINCIPAL_TYPE_NAME);
 
     return ViewPrivilegeChangeRequestAuditEvent.builder()
       .withTimestamp(System.currentTimeMillis())
@@ -92,9 +94,9 @@ public class ViewPrivilegeEventCreator implements RequestAuditEventCreator {
       .withResultStatus(result.getStatus())
       .withUrl(request.getURI())
       .withRemoteIp(request.getRemoteAddress())
-      .withType(getProperty(request, PropertyHelper.getPropertyId("PrivilegeInfo", "view_name")))
-      .withVersion(getProperty(request, PropertyHelper.getPropertyId("PrivilegeInfo", "version")))
-      .withName(getProperty(request, PropertyHelper.getPropertyId("PrivilegeInfo", "instance_name")))
+      .withType(RequestAuditEventCreatorHelper.getProperty(request, ViewPrivilegeResourceProvider.PRIVILEGE_VIEW_NAME_PROPERTY_ID))
+      .withVersion(RequestAuditEventCreatorHelper.getProperty(request, ViewPrivilegeResourceProvider.PRIVILEGE_VIEW_VERSION_PROPERTY_ID))
+      .withName(RequestAuditEventCreatorHelper.getProperty(request, ViewPrivilegeResourceProvider.PRIVILEGE_INSTANCE_NAME_PROPERTY_ID))
       .withUsers(users)
       .withGroups(groups)
       .build();
@@ -102,19 +104,6 @@ public class ViewPrivilegeEventCreator implements RequestAuditEventCreator {
   }
 
   /**
-   * Returns property from the request based on the propertyId parameter
-   * @param request
-   * @param properyId
-   * @return
-   */
-  private String getProperty(Request request, String properyId) {
-    if (!request.getBody().getPropertySets().isEmpty()) {
-      return String.valueOf(request.getBody().getPropertySets().iterator().next().get(properyId));
-    }
-    return null;
-  }
-
-  /**
    * Assembles entities from the request. The result can contain users or groups based on the value of type parameter
    * @param request
    * @param type
@@ -124,10 +113,10 @@ public class ViewPrivilegeEventCreator implements RequestAuditEventCreator {
     Map<String, List<String>> entities = new HashMap<String, List<String>>();
 
     for (Map<String, Object> propertyMap : request.getBody().getPropertySets()) {
-      String ptype = String.valueOf(propertyMap.get(PropertyHelper.getPropertyId("PrivilegeInfo", "principal_type")));
+      String ptype = String.valueOf(propertyMap.get(ViewPrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID));
       if (type.equals(ptype)) {
-        String role = String.valueOf(propertyMap.get(PropertyHelper.getPropertyId("PrivilegeInfo", "permission_name")));
-        String name = String.valueOf(propertyMap.get(PropertyHelper.getPropertyId("PrivilegeInfo", "principal_name")));
+        String role = String.valueOf(propertyMap.get(ViewPrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID));
+        String name = String.valueOf(propertyMap.get(ViewPrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID));
         if (!entities.containsKey(role)) {
           entities.put(role, new LinkedList<String>());
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/cleanup/ClasspathScannerUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/cleanup/ClasspathScannerUtils.java b/ambari-server/src/main/java/org/apache/ambari/server/cleanup/ClasspathScannerUtils.java
index 4c12a62..01487f0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/cleanup/ClasspathScannerUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/cleanup/ClasspathScannerUtils.java
@@ -20,11 +20,11 @@ package org.apache.ambari.server.cleanup;
 
 import java.io.IOException;
 import java.lang.annotation.Annotation;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.lang.ClassUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -113,7 +113,7 @@ public class ClasspathScannerUtils {
   private static boolean checkSubClasses(Class candidate, List<Class> selectors) {
     boolean ret = false;
     LOGGER.debug("Checking interfaces for: [{}]", candidate);
-    List<Class> interfaces = Arrays.asList(candidate.getInterfaces());
+    List interfaces = ClassUtils.getAllInterfaces(candidate);
 
     for (Class selectorItf : selectors) {
       if (interfaces.contains(selectorItf)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java
index 36469c1..dafd194 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java
@@ -61,13 +61,13 @@ import com.google.inject.Inject;
 public class AlertGroupResourceProvider extends
     AbstractControllerResourceProvider {
 
-  protected static final String ALERT_GROUP = "AlertGroup";
-  protected static final String ALERT_GROUP_ID = "AlertGroup/id";
-  protected static final String ALERT_GROUP_CLUSTER_NAME = "AlertGroup/cluster_name";
-  protected static final String ALERT_GROUP_NAME = "AlertGroup/name";
-  protected static final String ALERT_GROUP_DEFAULT = "AlertGroup/default";
-  protected static final String ALERT_GROUP_DEFINITIONS = "AlertGroup/definitions";
-  protected static final String ALERT_GROUP_TARGETS = "AlertGroup/targets";
+  public static final String ALERT_GROUP = "AlertGroup";
+  public static final String ALERT_GROUP_ID = "AlertGroup/id";
+  public static final String ALERT_GROUP_CLUSTER_NAME = "AlertGroup/cluster_name";
+  public static final String ALERT_GROUP_NAME = "AlertGroup/name";
+  public static final String ALERT_GROUP_DEFAULT = "AlertGroup/default";
+  public static final String ALERT_GROUP_DEFINITIONS = "AlertGroup/definitions";
+  public static final String ALERT_GROUP_TARGETS = "AlertGroup/targets";
 
   private static final Set<String> PK_PROPERTY_IDS = new HashSet<String>(
       Arrays.asList(ALERT_GROUP_ID, ALERT_GROUP_CLUSTER_NAME));

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java
index 992d33f..3b749d9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java
@@ -67,15 +67,15 @@ import com.google.inject.Inject;
 public class AlertTargetResourceProvider extends
  AbstractAuthorizedResourceProvider {
 
-  protected static final String ALERT_TARGET = "AlertTarget";
-  protected static final String ALERT_TARGET_ID = "AlertTarget/id";
-  protected static final String ALERT_TARGET_NAME = "AlertTarget/name";
-  protected static final String ALERT_TARGET_DESCRIPTION = "AlertTarget/description";
-  protected static final String ALERT_TARGET_NOTIFICATION_TYPE = "AlertTarget/notification_type";
-  protected static final String ALERT_TARGET_PROPERTIES = "AlertTarget/properties";
-  protected static final String ALERT_TARGET_GROUPS = "AlertTarget/groups";
-  protected static final String ALERT_TARGET_STATES = "AlertTarget/alert_states";
-  protected static final String ALERT_TARGET_GLOBAL = "AlertTarget/global";
+  public static final String ALERT_TARGET = "AlertTarget";
+  public static final String ALERT_TARGET_ID = "AlertTarget/id";
+  public static final String ALERT_TARGET_NAME = "AlertTarget/name";
+  public static final String ALERT_TARGET_DESCRIPTION = "AlertTarget/description";
+  public static final String ALERT_TARGET_NOTIFICATION_TYPE = "AlertTarget/notification_type";
+  public static final String ALERT_TARGET_PROPERTIES = "AlertTarget/properties";
+  public static final String ALERT_TARGET_GROUPS = "AlertTarget/groups";
+  public static final String ALERT_TARGET_STATES = "AlertTarget/alert_states";
+  public static final String ALERT_TARGET_GLOBAL = "AlertTarget/global";
 
   private static final Set<String> PK_PROPERTY_IDS = new HashSet<String>(
       Arrays.asList(ALERT_TARGET_ID, ALERT_TARGET_NAME));

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/GroupResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/GroupResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/GroupResourceProvider.java
index 1678931..0d215ae 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/GroupResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/GroupResourceProvider.java
@@ -42,13 +42,13 @@ import org.apache.ambari.server.security.authorization.RoleAuthorization;
 /**
  * Resource provider for group resources.
  */
-class GroupResourceProvider extends AbstractControllerResourceProvider {
+public class GroupResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 
   // Groups
-  protected static final String GROUP_GROUPNAME_PROPERTY_ID  = PropertyHelper.getPropertyId("Groups", "group_name");
-  protected static final String GROUP_LDAP_GROUP_PROPERTY_ID = PropertyHelper.getPropertyId("Groups", "ldap_group");
+  public static final String GROUP_GROUPNAME_PROPERTY_ID  = PropertyHelper.getPropertyId("Groups", "group_name");
+  public static final String GROUP_LDAP_GROUP_PROPERTY_ID = PropertyHelper.getPropertyId("Groups", "ldap_group");
 
   private static Set<String> pkPropertyIds =
       new HashSet<String>(Arrays.asList(new String[]{

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
index 3c33a23..11db913 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
@@ -81,35 +81,35 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
   // ----- Property ID constants ---------------------------------------------
 
   // Host Components
-  protected static final String HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID
+  public static final String HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "cluster_name");
-  protected static final String HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID
+  public static final String HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "service_name");
-  protected static final String HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID
+  public static final String HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "component_name");
-  protected static final String HOST_COMPONENT_DISPLAY_NAME_PROPERTY_ID
+  public static final String HOST_COMPONENT_DISPLAY_NAME_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "display_name");
-  protected static final String HOST_COMPONENT_HOST_NAME_PROPERTY_ID
+  public static final String HOST_COMPONENT_HOST_NAME_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "host_name");
-  protected static final String HOST_COMPONENT_STATE_PROPERTY_ID
+  public static final String HOST_COMPONENT_STATE_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "state");
-  protected static final String HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID
+  public static final String HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "desired_state");
-  protected static final String HOST_COMPONENT_STACK_ID_PROPERTY_ID
+  public static final String HOST_COMPONENT_STACK_ID_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "stack_id");
-  protected static final String HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID
+  public static final String HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "desired_stack_id");
-  protected static final String HOST_COMPONENT_ACTUAL_CONFIGS_PROPERTY_ID
+  public static final String HOST_COMPONENT_ACTUAL_CONFIGS_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "actual_configs");
-  protected static final String HOST_COMPONENT_STALE_CONFIGS_PROPERTY_ID
+  public static final String HOST_COMPONENT_STALE_CONFIGS_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "stale_configs");
-  protected static final String HOST_COMPONENT_DESIRED_ADMIN_STATE_PROPERTY_ID
+  public static final String HOST_COMPONENT_DESIRED_ADMIN_STATE_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "desired_admin_state");
-  protected static final String HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID
+  public static final String HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID
       = "HostRoles/maintenance_state";
-  protected static final String HOST_COMPONENT_HDP_VERSION_PROPERTY_ID
+  public static final String HOST_COMPONENT_HDP_VERSION_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "hdp_version");
-  protected static final String HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID = "HostRoles/upgrade_state";
+  public static final String HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID = "HostRoles/upgrade_state";
 
   //Component name mappings
   private final Map<String, PropertyProvider> HOST_COMPONENT_PROPERTIES_PROVIDER = new HashMap<String, PropertyProvider>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MemberResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MemberResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MemberResourceProvider.java
index 04e5f67..307ed3f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MemberResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MemberResourceProvider.java
@@ -52,8 +52,8 @@ public class MemberResourceProvider extends AbstractControllerResourceProvider {
   // ----- Property ID constants ---------------------------------------------
 
   // Members
-  protected static final String MEMBER_GROUP_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("MemberInfo", "group_name");
-  protected static final String MEMBER_USER_NAME_PROPERTY_ID  = PropertyHelper.getPropertyId("MemberInfo", "user_name");
+  public static final String MEMBER_GROUP_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("MemberInfo", "group_name");
+  public static final String MEMBER_USER_NAME_PROPERTY_ID  = PropertyHelper.getPropertyId("MemberInfo", "user_name");
 
   private static Set<String> pkPropertyIds =
       new HashSet<String>(Arrays.asList(new String[]{

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeItemResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeItemResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeItemResourceProvider.java
index a45b1ac..8518593 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeItemResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeItemResourceProvider.java
@@ -56,11 +56,11 @@ import com.google.inject.Inject;
 @StaticallyInject
 public class UpgradeItemResourceProvider extends ReadOnlyResourceProvider {
 
-  protected static final String UPGRADE_CLUSTER_NAME = "UpgradeItem/cluster_name";
-  protected static final String UPGRADE_REQUEST_ID = "UpgradeItem/request_id";
-  protected static final String UPGRADE_GROUP_ID = "UpgradeItem/group_id";
-  protected static final String UPGRADE_ITEM_STAGE_ID = "UpgradeItem/stage_id";
-  protected static final String UPGRADE_ITEM_TEXT = "UpgradeItem/text";
+  public static final String UPGRADE_CLUSTER_NAME = "UpgradeItem/cluster_name";
+  public static final String UPGRADE_REQUEST_ID = "UpgradeItem/request_id";
+  public static final String UPGRADE_GROUP_ID = "UpgradeItem/group_id";
+  public static final String UPGRADE_ITEM_STAGE_ID = "UpgradeItem/stage_id";
+  public static final String UPGRADE_ITEM_TEXT = "UpgradeItem/text";
 
   private static final Set<String> PK_PROPERTY_IDS = new HashSet<String>(
       Arrays.asList(UPGRADE_REQUEST_ID, UPGRADE_ITEM_STAGE_ID));

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index 0384f6c..4cd0419 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -128,20 +128,20 @@ import com.google.inject.persist.Transactional;
 @StaticallyInject
 public class UpgradeResourceProvider extends AbstractControllerResourceProvider {
 
-  protected static final String UPGRADE_CLUSTER_NAME = "Upgrade/cluster_name";
-  protected static final String UPGRADE_VERSION = "Upgrade/repository_version";
-  protected static final String UPGRADE_TYPE = "Upgrade/upgrade_type";
-  protected static final String UPGRADE_PACK = "Upgrade/pack";
-  protected static final String UPGRADE_REQUEST_ID = "Upgrade/request_id";
-  protected static final String UPGRADE_FROM_VERSION = "Upgrade/from_version";
-  protected static final String UPGRADE_TO_VERSION = "Upgrade/to_version";
-  protected static final String UPGRADE_DIRECTION = "Upgrade/direction";
-  protected static final String UPGRADE_DOWNGRADE_ALLOWED = "Upgrade/downgrade_allowed";
-  protected static final String UPGRADE_REQUEST_STATUS = "Upgrade/request_status";
-  protected static final String UPGRADE_SUSPENDED = "Upgrade/suspended";
-  protected static final String UPGRADE_ABORT_REASON = "Upgrade/abort_reason";
-  protected static final String UPGRADE_SKIP_PREREQUISITE_CHECKS = "Upgrade/skip_prerequisite_checks";
-  protected static final String UPGRADE_FAIL_ON_CHECK_WARNINGS = "Upgrade/fail_on_check_warnings";
+  public static final String UPGRADE_CLUSTER_NAME = "Upgrade/cluster_name";
+  public static final String UPGRADE_VERSION = "Upgrade/repository_version";
+  public static final String UPGRADE_TYPE = "Upgrade/upgrade_type";
+  public static final String UPGRADE_PACK = "Upgrade/pack";
+  public static final String UPGRADE_REQUEST_ID = "Upgrade/request_id";
+  public static final String UPGRADE_FROM_VERSION = "Upgrade/from_version";
+  public static final String UPGRADE_TO_VERSION = "Upgrade/to_version";
+  public static final String UPGRADE_DIRECTION = "Upgrade/direction";
+  public static final String UPGRADE_DOWNGRADE_ALLOWED = "Upgrade/downgrade_allowed";
+  public static final String UPGRADE_REQUEST_STATUS = "Upgrade/request_status";
+  public static final String UPGRADE_SUSPENDED = "Upgrade/suspended";
+  public static final String UPGRADE_ABORT_REASON = "Upgrade/abort_reason";
+  public static final String UPGRADE_SKIP_PREREQUISITE_CHECKS = "Upgrade/skip_prerequisite_checks";
+  public static final String UPGRADE_FAIL_ON_CHECK_WARNINGS = "Upgrade/fail_on_check_warnings";
 
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
index fee1826..099cfd4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
@@ -35,19 +35,19 @@ import java.util.Set;
 /**
  * Resource provider for user resources.
  */
-class UserResourceProvider extends AbstractControllerResourceProvider {
+public class UserResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 
   // Users
-  protected static final String USER_USERNAME_PROPERTY_ID     = PropertyHelper.getPropertyId("Users", "user_name");
-  protected static final String USER_PASSWORD_PROPERTY_ID     = PropertyHelper.getPropertyId("Users", "password");
-  protected static final String USER_OLD_PASSWORD_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "old_password");
-  protected static final String USER_LDAP_USER_PROPERTY_ID    = PropertyHelper.getPropertyId("Users", "ldap_user");
-  protected static final String USER_TYPE_PROPERTY_ID         = PropertyHelper.getPropertyId("Users", "user_type");
-  protected static final String USER_ACTIVE_PROPERTY_ID       = PropertyHelper.getPropertyId("Users", "active");
-  protected static final String USER_GROUPS_PROPERTY_ID       = PropertyHelper.getPropertyId("Users", "groups");
-  protected static final String USER_ADMIN_PROPERTY_ID        = PropertyHelper.getPropertyId("Users", "admin");
+  public static final String USER_USERNAME_PROPERTY_ID     = PropertyHelper.getPropertyId("Users", "user_name");
+  public static final String USER_PASSWORD_PROPERTY_ID     = PropertyHelper.getPropertyId("Users", "password");
+  public static final String USER_OLD_PASSWORD_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "old_password");
+  public static final String USER_LDAP_USER_PROPERTY_ID    = PropertyHelper.getPropertyId("Users", "ldap_user");
+  public static final String USER_TYPE_PROPERTY_ID         = PropertyHelper.getPropertyId("Users", "user_type");
+  public static final String USER_ACTIVE_PROPERTY_ID       = PropertyHelper.getPropertyId("Users", "active");
+  public static final String USER_GROUPS_PROPERTY_ID       = PropertyHelper.getPropertyId("Users", "groups");
+  public static final String USER_ADMIN_PROPERTY_ID        = PropertyHelper.getPropertyId("Users", "admin");
 
   private static Set<String> pkPropertyIds =
       new HashSet<String>(Arrays.asList(new String[]{

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java b/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java
index 9c2b42b..e9009c3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java
@@ -68,7 +68,7 @@ public class EmailDispatcher implements NotificationDispatcher {
   /**
    * The JavaMail property for the {@code From:} header.
    */
-  private static final String JAVAMAIL_FROM_PROPERTY = "mail.smtp.from";
+  public static final String JAVAMAIL_FROM_PROPERTY = "mail.smtp.from";
 
   /**
    * {@inheritDoc}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilter.java b/ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilter.java
index 5663ed2..0a312f3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilter.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilter.java
@@ -76,7 +76,7 @@ public class AmbariAuthenticationFilter extends BasicAuthenticationFilter {
   public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
     HttpServletRequest request = (HttpServletRequest) req;
     String header = request.getHeader("Authorization");
-    if (AuthorizationHelper.getAuthenticatedName() == null && (header == null || !header.startsWith("Basic "))) {
+    if (auditLogger.isEnabled() && AuthorizationHelper.getAuthenticatedName() == null && (header == null || !header.startsWith("Basic "))) {
       AuditEvent loginFailedAuditEvent = LoginAuditEvent.builder()
         .withRemoteIp(RequestUtils.getRemoteAddress(request))
         .withTimestamp(System.currentTimeMillis())
@@ -97,6 +97,9 @@ public class AmbariAuthenticationFilter extends BasicAuthenticationFilter {
    */
   @Override
   protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException {
+    if(!auditLogger.isEnabled()) {
+      return;
+    }
     AuditEvent loginSucceededAuditEvent = LoginAuditEvent.builder()
       .withRemoteIp(RequestUtils.getRemoteAddress(request))
       .withUserName(authResult.getName())
@@ -123,13 +126,15 @@ public class AmbariAuthenticationFilter extends BasicAuthenticationFilter {
     } catch (Exception e) {
       LOG.warn("Error occurred during decoding authorization header.",e);
     }
-    AuditEvent loginFailedAuditEvent = LoginAuditEvent.builder()
-      .withRemoteIp(RequestUtils.getRemoteAddress(request))
-      .withTimestamp(System.currentTimeMillis())
-      .withReasonOfFailure("Invalid username/password combination")
-      .withUserName(username)
-      .build();
-    auditLogger.log(loginFailedAuditEvent);
+    if(auditLogger.isEnabled()) {
+      AuditEvent loginFailedAuditEvent = LoginAuditEvent.builder()
+        .withRemoteIp(RequestUtils.getRemoteAddress(request))
+        .withTimestamp(System.currentTimeMillis())
+        .withReasonOfFailure("Invalid username/password combination")
+        .withUserName(username)
+        .build();
+      auditLogger.log(loginFailedAuditEvent);
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilter.java b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilter.java
index 96d6131..5c74f07 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilter.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariAuthorizationFilter.java
@@ -137,12 +137,14 @@ public class AmbariAuthorizationFilter implements Filter {
       if (token != null) {
         InternalAuthenticationToken internalAuthenticationToken = new InternalAuthenticationToken(token);
         context.setAuthentication(internalAuthenticationToken);
-        LoginAuditEvent loginAuditEvent = LoginAuditEvent.builder()
-          .withUserName(internalAuthenticationToken.getName())
-          .withRemoteIp(RequestUtils.getRemoteAddress(httpRequest))
-          .withRoles(permissionHelper.getPermissionLabels(authentication))
-          .withTimestamp(System.currentTimeMillis()).build();
-        auditLogger.log(loginAuditEvent);
+        if(auditLogger.isEnabled()) {
+          LoginAuditEvent loginAuditEvent = LoginAuditEvent.builder()
+            .withUserName(internalAuthenticationToken.getName())
+            .withRemoteIp(RequestUtils.getRemoteAddress(httpRequest))
+            .withRoles(permissionHelper.getPermissionLabels(authentication))
+            .withTimestamp(System.currentTimeMillis()).build();
+          auditLogger.log(loginAuditEvent);
+        }
       } else {
         // for view access, we should redirect to the Ambari login
         if (requestURI.matches(VIEWS_CONTEXT_ALL_PATTERN)) {
@@ -207,14 +209,17 @@ public class AmbariAuthorizationFilter implements Filter {
       if (!authorized &&
           (!httpRequest.getMethod().equals("GET")
               || requestURI.matches(API_LDAP_SYNC_EVENTS_ALL_PATTERN))) {
-        auditEvent = AccessUnauthorizedAuditEvent.builder()
-          .withHttpMethodName(httpRequest.getMethod())
-          .withRemoteIp(RequestUtils.getRemoteAddress(httpRequest))
-          .withResourcePath(httpRequest.getRequestURI())
-          .withUserName(AuthorizationHelper.getAuthenticatedName())
-          .withTimestamp(System.currentTimeMillis())
-          .build();
-        auditLogger.log(auditEvent);
+
+        if(auditLogger.isEnabled()) {
+          auditEvent = AccessUnauthorizedAuditEvent.builder()
+            .withHttpMethodName(httpRequest.getMethod())
+            .withRemoteIp(RequestUtils.getRemoteAddress(httpRequest))
+            .withResourcePath(httpRequest.getRequestURI())
+            .withUserName(AuthorizationHelper.getAuthenticatedName())
+            .withTimestamp(System.currentTimeMillis())
+            .build();
+          auditLogger.log(auditEvent);
+        }
 
         httpResponse.setHeader("WWW-Authenticate", "Basic realm=\"" + realm + "\"");
         httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "You do not have permissions to access this resource.");
@@ -224,7 +229,7 @@ public class AmbariAuthorizationFilter implements Filter {
     }
     if (AuthorizationHelper.getAuthenticatedName() != null) {
       httpResponse.setHeader("User", AuthorizationHelper.getAuthenticatedName());
-      if (httpResponse.getStatus() == HttpServletResponse.SC_FORBIDDEN) {
+      if (auditLogger.isEnabled() && httpResponse.getStatus() == HttpServletResponse.SC_FORBIDDEN) {
         auditEvent = AccessUnauthorizedAuditEvent.builder()
           .withHttpMethodName(httpRequest.getMethod())
           .withRemoteIp(RequestUtils.getRemoteAddress(httpRequest))

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/PermissionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/PermissionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/PermissionHelper.java
index ecf2d7a..3531fda 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/PermissionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/PermissionHelper.java
@@ -54,6 +54,9 @@ public class PermissionHelper {
     Map<String,List<String>> permissionLabels = new HashMap<>();
     if (authentication.getAuthorities() != null) {
       for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) {
+        if(!(grantedAuthority instanceof AmbariGrantedAuthority)) {
+          continue;
+        }
         AmbariGrantedAuthority ambariGrantedAuthority = (AmbariGrantedAuthority) grantedAuthority;
 
         PrivilegeEntity privilegeEntity = ambariGrantedAuthority.getPrivilegeEntity();

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
index 0b84568..9e424f7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
@@ -129,7 +129,7 @@ public class AlertNoticeDispatchService extends AbstractScheduledService {
   /**
    * The property containing the dispatch recipients
    */
-  private static final String AMBARI_DISPATCH_RECIPIENTS = "ambari.dispatch.recipients";
+  public static final String AMBARI_DISPATCH_RECIPIENTS = "ambari.dispatch.recipients";
 
   /**
    * The context key for Ambari information to be passed to Velocity.

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index 3976c03..17c5513 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -68,6 +68,7 @@ import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.agent.HostStatus.Status;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
@@ -92,6 +93,7 @@ import org.apache.ambari.server.utils.StageUtils;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.codehaus.jackson.JsonGenerationException;
+import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -135,6 +137,9 @@ public class TestHeartbeatHandler {
   @Inject
   HeartbeatTestHelper heartbeatTestHelper;
 
+  @Inject
+  AuditLogger auditLogger;
+
   private UnitOfWork unitOfWork;
 
   @Rule
@@ -152,11 +157,13 @@ public class TestHeartbeatHandler {
     injector.injectMembers(this);
     log.debug("Using server os type=" + config.getServerOsType());
     unitOfWork = injector.getInstance(UnitOfWork.class);
+    EasyMock.replay(auditLogger);
   }
 
   @After
   public void teardown() throws AmbariException {
     injector.getInstance(PersistService.class).stop();
+    EasyMock.reset(auditLogger);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/audit/ActionDBAAccessorAuditlogTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/ActionDBAAccessorAuditlogTest.java b/ambari-server/src/test/java/org/apache/ambari/server/audit/ActionDBAAccessorAuditlogTest.java
new file mode 100644
index 0000000..2fcf9d5
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/ActionDBAAccessorAuditlogTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.ambari.server.audit;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+import org.apache.ambari.server.actionmanager.ActionDBAccessorImpl;
+import org.junit.Test;
+
+public class ActionDBAAccessorAuditlogTest {
+
+  @Test
+  public void equalsVerifierTest() {
+
+    Class<?>[] innerClasses = ActionDBAccessorImpl.class.getDeclaredClasses();
+
+    for(Class<?> clazz : innerClasses) {
+      if(clazz.getSimpleName().contains("RequestDetails")) {
+        Class<?>[] innerClasses2 = clazz.getDeclaredClasses();
+        for(Class<?> clazz2 : innerClasses2) {
+          if (clazz2.getSimpleName().contains("Component")) {
+            EqualsVerifier.forClass(clazz2).verify();
+          }
+        }
+      }
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/audit/OperationStatusAuditEventTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/OperationStatusAuditEventTest.java b/ambari-server/src/test/java/org/apache/ambari/server/audit/OperationStatusAuditEventTest.java
index 0d2e710..038cebc 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/OperationStatusAuditEventTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/OperationStatusAuditEventTest.java
@@ -38,6 +38,7 @@ public class OperationStatusAuditEventTest {
       .withTimestamp(System.currentTimeMillis())
       .withRequestId(testRequestId.toString())
       .withStatus(testStatus)
+      .withUserName("testuser")
       .withRequestContext("Start Service")
       .build();
 
@@ -45,7 +46,7 @@ public class OperationStatusAuditEventTest {
     String actualAuditMessage = evnt.getAuditMessage();
 
     // Then
-    String expectedAuditMessage = String.format("Operation(Start Service), Status(%s), RequestId(%s)", testStatus, testRequestId);
+    String expectedAuditMessage = String.format("User(testuser), Operation(Start Service), Status(%s), RequestId(%s)", testStatus, testRequestId);
 
     assertThat(actualAuditMessage, equalTo(expectedAuditMessage));
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/audit/request/AbstractBaseCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/AbstractBaseCreator.java b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/AbstractBaseCreator.java
index 02ecb00..c405668 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/AbstractBaseCreator.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/AbstractBaseCreator.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.audit.request;
 import org.apache.ambari.server.api.services.Request;
 import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.audit.event.AuditEvent;
+import org.apache.ambari.server.audit.request.eventcreator.RequestAuditEventCreator;
 
 public abstract class AbstractBaseCreator implements RequestAuditEventCreator {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/audit/request/RequestAuditLogModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/RequestAuditLogModule.java b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/RequestAuditLogModule.java
index 52ad44c..175e539 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/RequestAuditLogModule.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/RequestAuditLogModule.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.audit.request;
 
 import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.audit.AuditLoggerDefaultImpl;
+import org.apache.ambari.server.audit.request.eventcreator.RequestAuditEventCreator;
 import org.easymock.EasyMock;
 
 import com.google.inject.AbstractModule;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 05f3dcf..c79f9d2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -72,6 +72,7 @@ import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.actionmanager.TargetHostType;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.audit.AuditLoggerModule;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.ClusterStackVersionResourceProviderTest;
@@ -263,12 +264,14 @@ public class AmbariManagementControllerTest {
     topologyManager = injector.getInstance(TopologyManager.class);
     StageUtils.setTopologyManager(topologyManager);
     ActionManager.setTopologyManager(topologyManager);
+    EasyMock.replay(injector.getInstance(AuditLogger.class));
   }
 
   @After
   public void teardown() {
     injector.getInstance(PersistService.class).stop();
     actionDB = null;
+    EasyMock.reset(injector.getInstance(AuditLogger.class));
   }
 
   private void setOsFamily(Host host, String osFamily, String osVersion) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index 4a474bf..92043f0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -43,6 +43,7 @@ import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.api.resources.UpgradeResourceDefinition;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.AmbariServer;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -237,11 +238,13 @@ public class UpgradeResourceProviderTest {
     topologyManager = injector.getInstance(TopologyManager.class);
     StageUtils.setTopologyManager(topologyManager);
     ActionManager.setTopologyManager(topologyManager);
+    EasyMock.replay(injector.getInstance(AuditLogger.class));
   }
 
   @After
   public void after() {
     injector.getInstance(PersistService.class).stop();
+    EasyMock.reset(injector.getInstance(AuditLogger.class));
     injector = null;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
index b1336de..771f830 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
@@ -80,7 +80,9 @@ public class InMemoryDefaultTestModule extends AbstractModule {
 
     try {
       install(new BeanDefinitionsCachingTestControllerModule(properties));
-      bind(AuditLogger.class).toInstance(EasyMock.createNiceMock(AuditLoggerDefaultImpl.class));
+      AuditLogger al = EasyMock.createNiceMock(AuditLogger.class);
+      EasyMock.expect(al.isEnabled()).andReturn(false).anyTimes();
+      bind(AuditLogger.class).toInstance(al);
     } catch (Exception e) {
       throw new RuntimeException(e);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6320d589/ambari-server/src/test/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilterTest.java b/ambari-server/src/test/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilterTest.java
index f6a885d..0f2b104 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationFilterTest.java
@@ -78,6 +78,7 @@ public class AmbariAuthenticationFilterTest {
     FilterChain filterChain = createMock(FilterChain.class);
     expect(request.getHeader("Authorization")).andReturn("header").andReturn(null);
     expect(request.getHeader("X-Forwarded-For")).andReturn("1.2.3.4");
+    expect(mockedAuditLogger.isEnabled()).andReturn(true);
     mockedAuditLogger.log(anyObject(AuditEvent.class));
     expectLastCall().times(1);
     filterChain.doFilter(request, response);
@@ -106,6 +107,7 @@ public class AmbariAuthenticationFilterTest {
     expect(AuthorizationHelper.getAuthenticatedName()).andReturn("perm1");
     expect(request.getHeader("X-Forwarded-For")).andReturn("1.2.3.4");
     expect(authentication.getName()).andReturn("admin");
+    expect(mockedAuditLogger.isEnabled()).andReturn(true);
     mockedAuditLogger.log(anyObject(AuditEvent.class));
     expectLastCall().times(1);
     replay(mockedAuditLogger, request, authentication, permissionHelper);
@@ -125,6 +127,7 @@ public class AmbariAuthenticationFilterTest {
     expect(request.getHeader("X-Forwarded-For")).andReturn("1.2.3.4");
     expect(request.getHeader("Authorization")).andReturn(
       "Basic " + new String(Base64.encode("admin:admin".getBytes("UTF-8"))));
+    expect(mockedAuditLogger.isEnabled()).andReturn(true);
     mockedAuditLogger.log(anyObject(AuditEvent.class));
     expectLastCall().times(1);
     replay(mockedAuditLogger, request, authEx);


Mime
View raw message