Fix for review comments: package refactor, javadoc, configuration
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/565c2ea2 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/565c2ea2 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/565c2ea2 Branch: refs/heads/audit_logging Commit: 565c2ea24b16eee58d3ade63067ec1dd6164c647 Parents: d3d24a1 Author: Daniel Gergely <dgerg...@hortonworks.com> Authored: Tue Mar 8 14:32:21 2016 +0100 Committer: Toader, Sebastian <stoa...@hortonworks.com> Committed: Thu Mar 24 13:06:49 2016 +0100 ---------------------------------------------------------------------- .../actionmanager/ActionDBAccessorImpl.java | 4 + .../ambari/server/api/services/BaseService.java | 2 +- .../server/audit/AuditLoggerDefaultImpl.java | 3 + .../ambari/server/audit/AuditLoggerModule.java | 11 +- .../server/audit/BufferedAuditLogger.java | 20 +- .../server/audit/event/AbstractAuditEvent.java | 6 + .../audit/event/AbstractUserAuditEvent.java | 6 + .../event/AccessUnauthorizedAuditEvent.java | 7 + .../server/audit/event/LoginAuditEvent.java | 9 +- .../audit/event/OperationStatusAuditEvent.java | 3 + .../audit/event/TaskStatusAuditEvent.java | 3 + .../kerberos/AbstractKerberosAuditEvent.java | 10 + .../ChangeSecurityStateKerberosAuditEvent.java | 18 ++ .../CreateKeyTabKerberosAuditEvent.java | 14 ++ .../CreatePrincipalKerberosAuditEvent.java | 2 +- .../DestroyPrincipalKerberosAuditEvent.java | 8 +- .../request/ActivateUserRequestAuditEvent.java | 101 +++++++++ .../request/AddAlertGroupRequestAuditEvent.java | 113 ++++++++++ .../AddAlertTargetRequestAuditEvent.java | 167 ++++++++++++++ .../request/AddBlueprintRequestAuditEvent.java | 88 ++++++++ .../AddComponentToHostRequestAuditEvent.java | 98 +++++++++ .../request/AddCredentialRequestAuditEvent.java | 122 +++++++++++ .../event/request/AddHostRequestAuditEvent.java | 86 ++++++++ .../request/AddRepositoryRequestAuditEvent.java | 134 ++++++++++++ .../AddRepositoryVersionRequestAuditEvent.java | 153 +++++++++++++ .../request/AddRequestRequestAuditEvent.java | 98 +++++++++ .../request/AddUpgradeRequestAuditEvent.java | 111 ++++++++++ .../AddUserToGroupRequestAuditEvent.java | 98 +++++++++ .../AddViewInstanceRequestAuditEvent.java | 134 ++++++++++++ .../request/AdminUserRequestAuditEvent.java | 101 +++++++++ .../BlueprintExportRequestAuditEvent.java | 72 +++++++ .../ChangeAlertGroupRequestAuditEvent.java | 113 ++++++++++ .../ChangeAlertTargetRequestAuditEvent.java | 134 ++++++++++++ ...hangeRepositoryVersionRequestAuditEvent.java | 153 +++++++++++++ .../ChangeViewInstanceRequestAuditEvent.java | 134 ++++++++++++ .../ClientConfigDownloadRequestAuditEvent.java | 100 +++++++++ .../ClusterNameChangeRequestAuditEvent.java | 91 ++++++++ ...ClusterPrivilegeChangeRequestAuditEvent.java | 126 +++++++++++ .../ConfigurationChangeRequestAuditEvent.java | 101 +++++++++ .../request/CreateGroupRequestAuditEvent.java | 88 ++++++++ .../request/CreateUserRequestAuditEvent.java | 113 ++++++++++ .../DeleteAlertGroupRequestAuditEvent.java | 86 ++++++++ .../DeleteAlertTargetRequestAuditEvent.java | 86 ++++++++ .../DeleteBlueprintRequestAuditEvent.java | 88 ++++++++ .../request/DeleteGroupRequestAuditEvent.java | 88 ++++++++ .../request/DeleteHostRequestAuditEvent.java | 88 ++++++++ ...eleteRepositoryVersionRequestAuditEvent.java | 110 ++++++++++ .../request/DeleteServiceRequestAuditEvent.java | 88 ++++++++ .../request/DeleteUserRequestAuditEvent.java | 88 ++++++++ .../DeleteViewInstanceRequestAuditEvent.java | 110 ++++++++++ .../MembershipChangeRequestAuditEvent.java | 108 ++++++++++ .../PrivilegeChangeRequestAuditEvent.java | 113 ++++++++++ .../RemoveUserFromGroupRequestAuditEvent.java | 98 +++++++++ .../audit/event/request/RequestAuditEvent.java | 145 ------------- .../event/request/RequestAuditEventCreator.java | 59 ----- .../audit/event/request/RequestAuditLogger.java | 36 ---- .../event/request/RequestAuditLoggerImpl.java | 146 ------------- .../StartOperationRequestAuditEvent.java | 126 +++++++++++ .../UpdateRepositoryRequestAuditEvent.java | 134 ++++++++++++ .../UpdateUpgradeItemRequestAuditEvent.java | 111 ++++++++++ .../UserPasswordChangeRequestAuditEvent.java | 88 ++++++++ .../ViewPrivilegeChangeRequestAuditEvent.java | 163 ++++++++++++++ .../event/ActivateUserRequestAuditEvent.java | 89 -------- .../event/AddAlertGroupRequestAuditEvent.java | 98 --------- .../event/AddAlertTargetRequestAuditEvent.java | 134 ------------ .../event/AddBlueprintRequestAuditEvent.java | 79 ------- .../AddComponentToHostRequestAuditEvent.java | 85 -------- .../event/AddCredentialRequestAuditEvent.java | 104 --------- .../request/event/AddHostRequestAuditEvent.java | 77 ------- .../event/AddRepositoryRequestAuditEvent.java | 113 ---------- .../AddRepositoryVersionRequestAuditEvent.java | 131 ----------- .../event/AddRequestRequestAuditEvent.java | 86 -------- .../event/AddUpgradeRequestAuditEvent.java | 94 -------- .../event/AddUserToGroupRequestAuditEvent.java | 85 -------- .../event/AddViewInstanceRequestAuditEvent.java | 113 ---------- .../event/AdminUserRequestAuditEvent.java | 89 -------- .../event/BlueprintExportRequestAuditEvent.java | 66 ------ .../ChangeAlertGroupRequestAuditEvent.java | 98 --------- .../ChangeAlertTargetRequestAuditEvent.java | 134 ------------ ...hangeRepositoryVersionRequestAuditEvent.java | 131 ----------- .../ChangeViewInstanceRequestAuditEvent.java | 113 ---------- .../ClientConfigDownloadRequestAuditEvent.java | 88 -------- .../ClusterNameChangeRequestAuditEvent.java | 91 -------- ...ClusterPrivilegeChangeRequestAuditEvent.java | 111 ---------- .../ConfigurationChangeRequestAuditEvent.java | 92 -------- .../event/CreateGroupRequestAuditEvent.java | 79 ------- .../event/CreateUserRequestAuditEvent.java | 98 --------- .../DeleteAlertGroupRequestAuditEvent.java | 77 ------- .../DeleteAlertTargetRequestAuditEvent.java | 77 ------- .../event/DeleteBlueprintRequestAuditEvent.java | 79 ------- .../event/DeleteGroupRequestAuditEvent.java | 79 ------- .../event/DeleteHostRequestAuditEvent.java | 79 ------- ...eleteRepositoryVersionRequestAuditEvent.java | 95 -------- .../event/DeleteServiceRequestAuditEvent.java | 79 ------- .../event/DeleteUserRequestAuditEvent.java | 79 ------- .../DeleteViewInstanceRequestAuditEvent.java | 95 -------- .../MembershipChangeRequestAuditEvent.java | 96 --------- .../event/PrivilegeChangeRequestAuditEvent.java | 98 --------- .../RemoveUserFromGroupRequestAuditEvent.java | 85 -------- .../event/StartOperationRequestAuditEvent.java | 117 ---------- .../UpdateRepositoryRequestAuditEvent.java | 113 ---------- .../UpdateUpgradeItemRequestAuditEvent.java | 94 -------- .../UserPasswordChangeRequestAuditEvent.java | 79 ------- .../ViewPrivilegeChangeRequestAuditEvent.java | 141 ------------ .../eventcreator/AlertGroupEventCreator.java | 152 ------------- .../eventcreator/AlertTargetEventCreator.java | 150 ------------- .../eventcreator/BlueprintEventCreator.java | 107 --------- .../BlueprintExportEventCreator.java | 91 -------- .../eventcreator/ComponentEventCreator.java | 176 --------------- .../ConfigurationChangeEventCreator.java | 134 ------------ .../eventcreator/CredentialEventCreator.java | 102 --------- .../eventcreator/DefaultEventCreator.java | 95 -------- .../request/eventcreator/GroupEventCreator.java | 117 ---------- .../request/eventcreator/HostEventCreator.java | 156 -------------- .../eventcreator/MemberEventCreator.java | 154 ------------- .../eventcreator/PrivilegeEventCreator.java | 139 ------------ .../RecommendationIgnoreEventCreator.java | 77 ------- .../eventcreator/RepositoryEventCreator.java | 124 ----------- .../RepositoryVersionEventCreator.java | 181 ---------------- .../eventcreator/RequestEventCreator.java | 103 --------- .../ServiceConfigDownloadEventCreator.java | 90 -------- .../eventcreator/ServiceEventCreator.java | 167 -------------- .../eventcreator/UnauthorizedEventCreator.java | 72 ------- .../eventcreator/UpgradeEventCreator.java | 101 --------- .../eventcreator/UpgradeItemEventCreator.java | 101 --------- .../request/eventcreator/UserEventCreator.java | 180 ---------------- .../ValidationIgnoreEventCreator.java | 77 ------- .../eventcreator/ViewInstanceEventCreator.java | 142 ------------ .../eventcreator/ViewPrivilegeEventCreator.java | 130 ----------- .../server/audit/request/RequestAuditEvent.java | 161 ++++++++++++++ .../audit/request/RequestAuditEventCreator.java | 59 +++++ .../audit/request/RequestAuditLogger.java | 36 ++++ .../audit/request/RequestAuditLoggerImpl.java | 146 +++++++++++++ .../eventcreator/AlertGroupEventCreator.java | 170 +++++++++++++++ .../eventcreator/AlertTargetEventCreator.java | 165 ++++++++++++++ .../eventcreator/BlueprintEventCreator.java | 110 ++++++++++ .../BlueprintExportEventCreator.java | 95 ++++++++ .../eventcreator/ComponentEventCreator.java | 189 ++++++++++++++++ .../ConfigurationChangeEventCreator.java | 151 +++++++++++++ .../eventcreator/CredentialEventCreator.java | 112 ++++++++++ .../eventcreator/DefaultEventCreator.java | 99 +++++++++ .../request/eventcreator/GroupEventCreator.java | 125 +++++++++++ .../request/eventcreator/HostEventCreator.java | 168 +++++++++++++++ .../eventcreator/MemberEventCreator.java | 176 +++++++++++++++ .../eventcreator/PrivilegeEventCreator.java | 148 +++++++++++++ .../RecommendationIgnoreEventCreator.java | 81 +++++++ .../eventcreator/RepositoryEventCreator.java | 133 ++++++++++++ .../RepositoryVersionEventCreator.java | 216 +++++++++++++++++++ .../eventcreator/RequestEventCreator.java | 102 +++++++++ .../ServiceConfigDownloadEventCreator.java | 93 ++++++++ .../eventcreator/ServiceEventCreator.java | 180 ++++++++++++++++ .../eventcreator/UnauthorizedEventCreator.java | 87 ++++++++ .../eventcreator/UpgradeEventCreator.java | 111 ++++++++++ .../eventcreator/UpgradeItemEventCreator.java | 111 ++++++++++ .../request/eventcreator/UserEventCreator.java | 212 ++++++++++++++++++ .../ValidationIgnoreEventCreator.java | 81 +++++++ .../eventcreator/ViewInstanceEventCreator.java | 150 +++++++++++++ .../eventcreator/ViewPrivilegeEventCreator.java | 146 +++++++++++++ .../server/configuration/Configuration.java | 16 ++ .../ambari/server/controller/AmbariServer.java | 2 +- .../server/controller/ControllerModule.java | 56 ++--- .../server/api/services/BaseServiceTest.java | 2 +- .../server/audit/BufferedAuditLoggerTest.java | 24 ++- .../StartOperationRequestAuditEventTest.java | 2 +- .../audit/request/AbstractBaseCreator.java | 1 - .../audit/request/DefaultEventCreatorTest.java | 2 +- .../audit/request/RequestAuditLogModule.java | 3 - .../audit/request/RequestAuditLoggerTest.java | 1 - 168 files changed, 8594 insertions(+), 7600 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java index c2be6a7..91a040d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java @@ -126,6 +126,10 @@ public class ActionDBAccessorImpl implements ActionDBAccessor { @Inject AuditLogger auditLogger; + /** + * Caches to store current request and task statuses. + * It is used for deduplicating status reports in order to avoid autitlog entry duplication + */ private Map<Long, HostRoleStatus> temporaryStatusCache = new HashMap<Long, HostRoleStatus>(); private Map<Long, HostRoleStatus> temporaryTaskStatusCache = new HashMap<Long, HostRoleStatus>(); http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java index cbdd96d..4f2359a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java @@ -27,7 +27,7 @@ import org.apache.ambari.server.api.services.parsers.RequestBodyParser; import org.apache.ambari.server.api.services.serializers.CsvSerializer; import org.apache.ambari.server.api.services.serializers.JsonSerializer; import org.apache.ambari.server.api.services.serializers.ResultSerializer; -import org.apache.ambari.server.audit.event.request.RequestAuditLogger; +import org.apache.ambari.server.audit.request.RequestAuditLogger; import org.apache.ambari.server.controller.spi.Resource; import org.apache.ambari.server.utils.RetryHelper; import org.eclipse.jetty.util.ajax.JSON; http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerDefaultImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerDefaultImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerDefaultImpl.java index 6b351e9..7f87293 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerDefaultImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerDefaultImpl.java @@ -32,6 +32,9 @@ public class AuditLoggerDefaultImpl implements AuditLogger { private static final Logger LOG = LoggerFactory.getLogger("audit"); + /** + * {@inheritDoc} + */ @Override public void log(AuditEvent event) { LOG.info("{}, {}", event.getTimestamp(), event.getAuditMessage()); http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerModule.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerModule.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerModule.java index 2c27b79..3c1938b 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerModule.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/AuditLoggerModule.java @@ -18,24 +18,19 @@ package org.apache.ambari.server.audit; +import org.apache.ambari.server.configuration.Configuration; + import com.google.inject.AbstractModule; +import com.google.inject.Inject; import com.google.inject.name.Names; public class AuditLoggerModule extends AbstractModule { - private final static int BUFFERED_LOGGER_CAPACITY = 10000; - @Override protected void configure() { bind(AuditLogger.class).to(BufferedAuditLogger.class); // set AuditLoggerDefaultImpl to be used by BufferedAuditLogger bind(AuditLogger.class).annotatedWith(Names.named(BufferedAuditLogger.InnerLogger)).to(AuditLoggerDefaultImpl.class); - - // set buffered audit logger capacity - bindConstant().annotatedWith(Names.named(BufferedAuditLogger.Capacity)).to(BUFFERED_LOGGER_CAPACITY); - } - - } http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/BufferedAuditLogger.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/BufferedAuditLogger.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/BufferedAuditLogger.java index 81a05c9..e11bfd5 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/BufferedAuditLogger.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/BufferedAuditLogger.java @@ -24,6 +24,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import org.apache.ambari.server.audit.event.AuditEvent; +import org.apache.ambari.server.configuration.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,14 +42,29 @@ public class BufferedAuditLogger implements AuditLogger { private static final Logger LOG = LoggerFactory.getLogger(BufferedAuditLogger.class); + /** + * Capacity of the buffer + */ private final int bufferCapacity; + /** + * Buffer capacity status + */ private final double capacityWaterMark; + /** + * Wrapped audit logger + */ private final AuditLogger auditLogger; + /** + * Thread pool + */ private final ExecutorService pool; + /** + * Names for guice injection + */ public final static String InnerLogger = "BufferedAuditLogger"; public final static String Capacity = "BufferedAuditLogger.capacity"; @@ -88,8 +104,8 @@ public class BufferedAuditLogger implements AuditLogger { * @param auditLogger the audit logger to extend */ @Inject - public BufferedAuditLogger(@Named(InnerLogger) AuditLogger auditLogger, @Named(Capacity) int bufferCapacity) { - this.bufferCapacity = bufferCapacity; + public BufferedAuditLogger(@Named(InnerLogger) AuditLogger auditLogger, Configuration configuration) { + this.bufferCapacity = configuration.getBufferedAuditLoggerCapacity(); this.capacityWaterMark = 0.2; // 20 percent of full capacity this.auditEventWorkQueue = new LinkedBlockingQueue<>(bufferCapacity); http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractAuditEvent.java index 2ed8f87..e43beeb 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractAuditEvent.java @@ -28,8 +28,14 @@ import org.joda.time.DateTime; */ public abstract class AbstractAuditEvent implements AuditEvent { + /** + * Timestamp for the audit event creation + */ private final DateTime timestamp; + /** + * Message to log + */ private final String auditMessage; /** http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractUserAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractUserAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractUserAuditEvent.java index a883740..a968a64 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractUserAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AbstractUserAuditEvent.java @@ -28,8 +28,14 @@ public abstract class AbstractUserAuditEvent extends AbstractAuditEvent { public static abstract class AbstractUserAuditEventBuilder<T extends AbstractUserAuditEvent, TBuilder extends AbstractUserAuditEventBuilder<T, TBuilder>> extends AbstractAuditEventBuilder<T, TBuilder> { + /** + * Name of the user started the operation + */ private String userName; + /** + * Ip of the user who started the operation. Note: remote ip might not be the original ip (proxies, routers can modify it) + */ private String remoteIp; /** http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AccessUnauthorizedAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AccessUnauthorizedAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AccessUnauthorizedAuditEvent.java index 9eaa3ee..b6e60e1 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AccessUnauthorizedAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/AccessUnauthorizedAuditEvent.java @@ -29,7 +29,14 @@ public class AccessUnauthorizedAuditEvent extends AbstractUserAuditEvent { public static class AccessUnauthorizedAuditEventBuilder extends AbstractUserAuditEventBuilder<AccessUnauthorizedAuditEvent, AccessUnauthorizedAuditEventBuilder> { + /** + * Name of http method (PUT, POST, DELETE, etc...) + */ private String httpMethodName; + + /** + * The resource path that is tried to be accessed + */ private String resourcePath; /** http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/LoginAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/LoginAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/LoginAuditEvent.java index 4a9daed..223dd18 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/LoginAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/LoginAuditEvent.java @@ -27,7 +27,7 @@ import javax.annotation.concurrent.Immutable; import org.apache.commons.lang.StringUtils; /** - * Successful login audit event. + * Login audit event. */ @Immutable public class LoginAuditEvent extends AbstractUserAuditEvent { @@ -38,8 +38,15 @@ public class LoginAuditEvent extends AbstractUserAuditEvent { private LoginAuditEventBuilder() { } + /** + * List of roles possessed by the principal requesting access to a resource. + * [ view name | cluster name | 'Ambari'] -> list of permissions + */ private Map<String, List<String>> roles; + /** + * Reason of failure, if it is not null, then the request status is consider as failed + */ private String reasonOfFailure; /** http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/OperationStatusAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/OperationStatusAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/OperationStatusAuditEvent.java index 29dca27..319d772 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/OperationStatusAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/OperationStatusAuditEvent.java @@ -21,6 +21,9 @@ package org.apache.ambari.server.audit.event; import javax.annotation.concurrent.Immutable; +/** + * Audit event for tracking operations + */ @Immutable public class OperationStatusAuditEvent extends AbstractAuditEvent { http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/TaskStatusAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/TaskStatusAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/TaskStatusAuditEvent.java index 985d8fd..eaea058 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/TaskStatusAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/TaskStatusAuditEvent.java @@ -21,6 +21,9 @@ package org.apache.ambari.server.audit.event; import javax.annotation.concurrent.Immutable; +/** + * Audit event for tracking task status + */ @Immutable public class TaskStatusAuditEvent extends AbstractAuditEvent { http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/AbstractKerberosAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/AbstractKerberosAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/AbstractKerberosAuditEvent.java index a13beb8..77c162c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/AbstractKerberosAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/AbstractKerberosAuditEvent.java @@ -23,12 +23,22 @@ import javax.annotation.concurrent.Immutable; import org.apache.ambari.server.audit.event.AbstractAuditEvent; +/** + * Base class for kerberos audit events + */ @Immutable public class AbstractKerberosAuditEvent extends AbstractAuditEvent { static abstract class AbstractKerberosAuditEventBuilder<T extends AbstractKerberosAuditEvent, TBuilder extends AbstractKerberosAuditEventBuilder<T, TBuilder>> extends AbstractAuditEvent.AbstractAuditEventBuilder<T, TBuilder> { + /** + * Description of the operation + */ protected String operation; + + /** + * Reason of failure, if it is not null, then the request is considered as failed + */ protected String reasonOfFailure; /** http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/ChangeSecurityStateKerberosAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/ChangeSecurityStateKerberosAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/ChangeSecurityStateKerberosAuditEvent.java index 180eb93..ffb7e8a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/ChangeSecurityStateKerberosAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/ChangeSecurityStateKerberosAuditEvent.java @@ -20,14 +20,32 @@ package org.apache.ambari.server.audit.event.kerberos; import javax.annotation.concurrent.Immutable; +/** + * Audit event for kerberos security state change of components + */ @Immutable public class ChangeSecurityStateKerberosAuditEvent extends AbstractKerberosAuditEvent { public static class ChangeSecurityStateKerberosAuditEventBuilder extends AbstractKerberosAuditEventBuilder<ChangeSecurityStateKerberosAuditEvent, ChangeSecurityStateKerberosAuditEventBuilder> { + /** + * Service name + */ private String service; + + /** + * Component name + */ private String component; + + /** + * Host name + */ private String hostName; + + /** + * Security state + */ private String state; private ChangeSecurityStateKerberosAuditEventBuilder() { http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreateKeyTabKerberosAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreateKeyTabKerberosAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreateKeyTabKerberosAuditEvent.java index a17bb32..7ac3ef4 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreateKeyTabKerberosAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreateKeyTabKerberosAuditEvent.java @@ -20,13 +20,27 @@ package org.apache.ambari.server.audit.event.kerberos; import javax.annotation.concurrent.Immutable; +/** + * Audit event for kerberos keytab change + */ @Immutable public class CreateKeyTabKerberosAuditEvent extends AbstractKerberosAuditEvent { public static class CreateKeyTabKerberosAuditEventBuilder extends AbstractKerberosAuditEventBuilder<CreateKeyTabKerberosAuditEvent, CreateKeyTabKerberosAuditEventBuilder> { + /** + * Path to keytab file + */ private String keyTabFilePath; + + /** + * Host name + */ private String hostName; + + /** + * Principal that belons to the keytab file + */ private String principal; private CreateKeyTabKerberosAuditEventBuilder() { http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreatePrincipalKerberosAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreatePrincipalKerberosAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreatePrincipalKerberosAuditEvent.java index f8ac9fb..e3fbbe4 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreatePrincipalKerberosAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreatePrincipalKerberosAuditEvent.java @@ -34,7 +34,7 @@ public class CreatePrincipalKerberosAuditEvent extends AbstractKerberosAuditEven @Override protected void buildAuditMessage(StringBuilder builder) { super.buildAuditMessage(builder); - builder.append("), Principal(") + builder.append(", Principal(") .append(principal); } http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/DestroyPrincipalKerberosAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/DestroyPrincipalKerberosAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/DestroyPrincipalKerberosAuditEvent.java index da7f250..ba56f21 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/DestroyPrincipalKerberosAuditEvent.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/DestroyPrincipalKerberosAuditEvent.java @@ -20,11 +20,17 @@ package org.apache.ambari.server.audit.event.kerberos; import javax.annotation.concurrent.Immutable; +/** + * Audit event for destroying principal + */ @Immutable public class DestroyPrincipalKerberosAuditEvent extends AbstractKerberosAuditEvent { public static class DestroyPrincipalKerberosAuditEventBuilder extends AbstractKerberosAuditEventBuilder<DestroyPrincipalKerberosAuditEvent, DestroyPrincipalKerberosAuditEventBuilder> { + /** + * Destroyed principal + */ private String principal; private DestroyPrincipalKerberosAuditEventBuilder() { @@ -35,7 +41,7 @@ public class DestroyPrincipalKerberosAuditEvent extends AbstractKerberosAuditEve protected void buildAuditMessage(StringBuilder builder) { super.buildAuditMessage(builder); - builder.append("), Principal(") + builder.append(", Principal(") .append(principal); } http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ActivateUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ActivateUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ActivateUserRequestAuditEvent.java new file mode 100644 index 0000000..df5726d --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ActivateUserRequestAuditEvent.java @@ -0,0 +1,101 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for setting a user active or inactive + */ +@Immutable +public class ActivateUserRequestAuditEvent extends RequestAuditEvent { + + public static class ActivateUserRequestAuditEventBuilder extends RequestAuditEventBuilder<ActivateUserRequestAuditEvent, ActivateUserRequestAuditEventBuilder> { + + /** + * Active or inactive + */ + private boolean active; + + /** + * Name of the user to set active or inactive + */ + private String username; + + public ActivateUserRequestAuditEventBuilder() { + super.withOperation("Set user activate"); + } + + @Override + protected ActivateUserRequestAuditEvent newAuditEvent() { + return new ActivateUserRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Affected username(") + .append(username) + .append("), ") + .append("Active(") + .append(active ? "yes" : "no") + .append(")"); + } + + public ActivateUserRequestAuditEventBuilder withActive(boolean active) { + this.active = active; + return this; + } + + public ActivateUserRequestAuditEventBuilder withAffectedUsername(String username) { + this.username = username; + return this; + } + + } + + protected ActivateUserRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ActivateUserRequestAuditEvent(ActivateUserRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ActivateUserRequestAuditEvent} + * + * @return a builder instance + */ + public static ActivateUserRequestAuditEventBuilder builder() { + return new ActivateUserRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertGroupRequestAuditEvent.java new file mode 100644 index 0000000..cd92ba0 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertGroupRequestAuditEvent.java @@ -0,0 +1,113 @@ +/* + * 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.event.request; + +import java.util.List; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +/** + * Audit event for adding alert group + */ +@Immutable +public class AddAlertGroupRequestAuditEvent extends RequestAuditEvent { + + public static class AddAlertGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<AddAlertGroupRequestAuditEvent, AddAlertGroupRequestAuditEventBuilder> { + + /** + * Group name + */ + private String name; + + /** + * Definition ids for the group + */ + private List<String> definitionIds; + + /** + * Notification ids for the group + */ + private List<String> notificationIds; + + public AddAlertGroupRequestAuditEventBuilder() { + super.withOperation("Alert group addition"); + } + + @Override + protected AddAlertGroupRequestAuditEvent newAuditEvent() { + return new AddAlertGroupRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Alert group name(") + .append(name) + .append("), Definition IDs(") + .append(StringUtils.join(definitionIds, ", ")) + .append("), Notification IDs(") + .append(StringUtils.join(notificationIds, ", ")) + .append(")"); + } + + public AddAlertGroupRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public AddAlertGroupRequestAuditEventBuilder withDefinitionIds(List<String> ids) { + this.definitionIds = ids; + return this; + } + + public AddAlertGroupRequestAuditEventBuilder withNotificationIds(List<String> ids) { + this.notificationIds = ids; + return this; + } + } + + protected AddAlertGroupRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddAlertGroupRequestAuditEvent(AddAlertGroupRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddAlertGroupRequestAuditEvent} + * + * @return a builder instance + */ + public static AddAlertGroupRequestAuditEventBuilder builder() { + return new AddAlertGroupRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertTargetRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertTargetRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertTargetRequestAuditEvent.java new file mode 100644 index 0000000..1c4a8d5 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddAlertTargetRequestAuditEvent.java @@ -0,0 +1,167 @@ +/* + * 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.event.request; + +import java.util.List; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +/** + * Audit event for adding alert target (= notification) + */ +@Immutable +public class AddAlertTargetRequestAuditEvent extends RequestAuditEvent { + + public static class AddAlertTargetRequestAuditEventBuilder extends RequestAuditEventBuilder<AddAlertTargetRequestAuditEvent, AddAlertTargetRequestAuditEventBuilder> { + + /** + * Name of the alert target + */ + private String name; + + /** + * Description of the alert target + */ + private String description; + + /** + * Type of the alert target + */ + private String notificationType; + + /** + * Group list that belongs to the alert target + */ + private List<String> groupIds; + + /** + * Email address that should be in the from field + */ + private String emailFrom; + + /** + * Eamil recipients + */ + private List<String> emailRecipients; + + /** + * Alert states for the alert target + */ + private List<String> alertStates; + + public AddAlertTargetRequestAuditEventBuilder() { + super.withOperation("Notification addition"); + } + + @Override + protected AddAlertTargetRequestAuditEvent newAuditEvent() { + return new AddAlertTargetRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Notification name(") + .append(name) + .append("), Description(") + .append(description) + .append("), Notification type(") + .append(notificationType) + .append("), Group IDs(") + .append(StringUtils.join(groupIds, ", ")); + + if (emailFrom != null) { + builder.append("), Email from(") + .append(emailFrom); + } + + if (emailRecipients != null && !emailRecipients.isEmpty()) { + builder.append("), Email to(") + .append(StringUtils.join(emailRecipients, ", ")); + } + builder.append("), Alert states(") + .append(StringUtils.join(alertStates, ", ")) + .append(")"); + } + + public AddAlertTargetRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public AddAlertTargetRequestAuditEventBuilder withDescription(String description) { + this.description = description; + return this; + } + + public AddAlertTargetRequestAuditEventBuilder withNotificationType(String notificationType) { + this.notificationType = notificationType; + return this; + } + + public AddAlertTargetRequestAuditEventBuilder withGroupIds(List<String> groupIds) { + this.groupIds = groupIds; + return this; + } + + public AddAlertTargetRequestAuditEventBuilder withEmailFrom(String emailFrom) { + this.emailFrom = emailFrom; + return this; + } + + public AddAlertTargetRequestAuditEventBuilder withEmailRecipients(List<String> emailRecipients) { + this.emailRecipients = emailRecipients; + return this; + } + + public AddAlertTargetRequestAuditEventBuilder withAlertStates(List<String> alertStates) { + this.alertStates = alertStates; + return this; + } + } + + protected AddAlertTargetRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddAlertTargetRequestAuditEvent(AddAlertTargetRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddAlertTargetRequestAuditEvent} + * + * @return a builder instance + */ + public static AddAlertTargetRequestAuditEventBuilder builder() { + return new AddAlertTargetRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddBlueprintRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddBlueprintRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddBlueprintRequestAuditEvent.java new file mode 100644 index 0000000..84431ab --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddBlueprintRequestAuditEvent.java @@ -0,0 +1,88 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding blueprint + */ +@Immutable +public class AddBlueprintRequestAuditEvent extends RequestAuditEvent { + + public static class AddBlueprintRequestAuditEventBuilder extends RequestAuditEventBuilder<AddBlueprintRequestAuditEvent, AddBlueprintRequestAuditEventBuilder> { + + /** + * Blueprint name + */ + private String blueprintName; + + public AddBlueprintRequestAuditEventBuilder() { + super.withOperation("Upload blueprint"); + } + + @Override + protected AddBlueprintRequestAuditEvent newAuditEvent() { + return new AddBlueprintRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Blueprint name(") + .append(blueprintName) + .append(")"); + } + + public AddBlueprintRequestAuditEventBuilder withBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + return this; + } + + } + + protected AddBlueprintRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddBlueprintRequestAuditEvent(AddBlueprintRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddBlueprintRequestAuditEvent} + * + * @return a builder instance + */ + public static AddBlueprintRequestAuditEventBuilder builder() { + return new AddBlueprintRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddComponentToHostRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddComponentToHostRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddComponentToHostRequestAuditEvent.java new file mode 100644 index 0000000..2c9eedd --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddComponentToHostRequestAuditEvent.java @@ -0,0 +1,98 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding component to a host + */ +@Immutable +public class AddComponentToHostRequestAuditEvent extends RequestAuditEvent { + + public static class AddComponentToHostRequestAuditEventBuilder extends RequestAuditEventBuilder<AddComponentToHostRequestAuditEvent, AddComponentToHostRequestAuditEventBuilder> { + + /** + * Host name + */ + private String hostName; + + /** + * Component name + */ + private String component; + + public AddComponentToHostRequestAuditEventBuilder() { + super.withOperation("Component addition to host"); + } + + @Override + protected AddComponentToHostRequestAuditEvent newAuditEvent() { + return new AddComponentToHostRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Hostname(") + .append(hostName) + .append(", Component(") + .append(component) + .append(")"); + } + + public AddComponentToHostRequestAuditEventBuilder withHostName(String hostName) { + this.hostName = hostName; + return this; + } + + public AddComponentToHostRequestAuditEventBuilder withComponent(String component) { + this.component = component; + return this; + } + } + + protected AddComponentToHostRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddComponentToHostRequestAuditEvent(AddComponentToHostRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddComponentToHostRequestAuditEvent} + * + * @return a builder instance + */ + public static AddComponentToHostRequestAuditEventBuilder builder() { + return new AddComponentToHostRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddCredentialRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddCredentialRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddCredentialRequestAuditEvent.java new file mode 100644 index 0000000..5d27abf --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddCredentialRequestAuditEvent.java @@ -0,0 +1,122 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding credential + */ +@Immutable +public class AddCredentialRequestAuditEvent extends RequestAuditEvent { + + public static class AddCredentialAuditEventBuilder extends RequestAuditEventBuilder<AddCredentialRequestAuditEvent, AddCredentialAuditEventBuilder> { + + /** + * Credential type (e.g. temporary) + */ + private String type; + + /** + * Cluster name + */ + private String clusterName; + + /** + * Principal + */ + private String principal; + + /** + * Alias for the credential + */ + private String alias; + + public AddCredentialAuditEventBuilder() { + super.withOperation("Credential addition"); + } + + @Override + protected AddCredentialRequestAuditEvent newAuditEvent() { + return new AddCredentialRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Type(") + .append(type) + .append("), Principal(") + .append(principal) + .append("), Alias(") + .append(alias) + .append("), Cluster name(") + .append(clusterName) + .append(")"); + } + + public AddCredentialAuditEventBuilder withType(String type) { + this.type = type; + return this; + } + + public AddCredentialAuditEventBuilder withClusterName(String clusterName) { + this.clusterName = clusterName; + return this; + } + + public AddCredentialAuditEventBuilder withPrincipal(String principal) { + this.principal = principal; + return this; + } + + public AddCredentialAuditEventBuilder withAlias(String alias) { + this.alias = alias; + return this; + } + } + + protected AddCredentialRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddCredentialRequestAuditEvent(AddCredentialAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddCredentialRequestAuditEvent} + * + * @return a builder instance + */ + public static AddCredentialAuditEventBuilder builder() { + return new AddCredentialAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddHostRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddHostRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddHostRequestAuditEvent.java new file mode 100644 index 0000000..c24175d --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddHostRequestAuditEvent.java @@ -0,0 +1,86 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding host + */ +@Immutable +public class AddHostRequestAuditEvent extends RequestAuditEvent { + + public static class AddHostRequestAuditEventBuilder extends RequestAuditEventBuilder<AddHostRequestAuditEvent, AddHostRequestAuditEventBuilder> { + + /** + * Hostname that is added + */ + private String hostName; + + public AddHostRequestAuditEventBuilder() { + super.withOperation("Host addition"); + } + + @Override + protected AddHostRequestAuditEvent newAuditEvent() { + return new AddHostRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Hostname(") + .append(hostName) + .append(")"); + } + + public AddHostRequestAuditEventBuilder withHostName(String hostName) { + this.hostName = hostName; + return this; + } + } + + protected AddHostRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddHostRequestAuditEvent(AddHostRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddHostRequestAuditEvent} + * + * @return a builder instance + */ + public static AddHostRequestAuditEventBuilder builder() { + return new AddHostRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryRequestAuditEvent.java new file mode 100644 index 0000000..ed6c1cd --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryRequestAuditEvent.java @@ -0,0 +1,134 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding repository + */ +@Immutable +public class AddRepositoryRequestAuditEvent extends RequestAuditEvent { + + public static class AddRepositoryRequestAuditEventBuilder extends RequestAuditEventBuilder<AddRepositoryRequestAuditEvent, AddRepositoryRequestAuditEventBuilder> { + + /** + * Repository name + */ + private String repo; + + /** + * Stack name + */ + private String stackName; + + /** + * Operating system type + */ + private String osType; + + /** + * Base url for the repository + */ + private String baseUrl; + + /** + * Stack version + */ + private String stackVersion; + + public AddRepositoryRequestAuditEventBuilder() { + super.withOperation("Repository addition"); + } + + @Override + protected AddRepositoryRequestAuditEvent newAuditEvent() { + return new AddRepositoryRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Stack(") + .append(stackName) + .append("), Stack version(") + .append(stackVersion) + .append("), OS(") + .append(osType) + .append("), Repo id(") + .append(repo) + .append("), Base URL(") + .append(baseUrl) + .append(")"); + } + + public AddRepositoryRequestAuditEventBuilder withRepo(String repo) { + this.repo = repo; + return this; + } + + public AddRepositoryRequestAuditEventBuilder withStackName(String stackName) { + this.stackName = stackName; + return this; + } + + public AddRepositoryRequestAuditEventBuilder withOsType(String osType) { + this.osType = osType; + return this; + } + + public AddRepositoryRequestAuditEventBuilder withBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public AddRepositoryRequestAuditEventBuilder withStackVersion(String stackVersion) { + this.stackVersion = stackVersion; + return this; + } + } + + protected AddRepositoryRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddRepositoryRequestAuditEvent(AddRepositoryRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddRepositoryRequestAuditEvent} + * + * @return a builder instance + */ + public static AddRepositoryRequestAuditEventBuilder builder() { + return new AddRepositoryRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryVersionRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryVersionRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryVersionRequestAuditEvent.java new file mode 100644 index 0000000..b4d3401 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRepositoryVersionRequestAuditEvent.java @@ -0,0 +1,153 @@ +/* + * 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.event.request; + +import java.util.List; +import java.util.Map; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding repository version + */ +@Immutable +public class AddRepositoryVersionRequestAuditEvent extends RequestAuditEvent { + + public static class AddRepositoryVersionAuditEventBuilder extends RequestAuditEventBuilder<AddRepositoryVersionRequestAuditEvent, AddRepositoryVersionAuditEventBuilder> { + + /** + * Stack name + */ + private String stackName; + + /** + * Display name + */ + private String displayName; + + /** + * Stack version + */ + private String stackVersion; + + /** + * Repository version + */ + private String repoVersion; + + /** + * Details of the repositories + * os type -> list of repositories, where a repository is a key-value map of the properties (repo_id, repo_name, base_url) + */ + private Map<String, List<Map<String, String>>> repos; + + public AddRepositoryVersionAuditEventBuilder() { + super.withOperation("Repository version addition"); + } + + @Override + protected AddRepositoryVersionRequestAuditEvent newAuditEvent() { + return new AddRepositoryVersionRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Stack(") + .append(stackName) + .append("), Stack version(") + .append(stackVersion) + .append("), Display name(") + .append(displayName) + .append("), Repo version(") + .append(repoVersion) + .append("), Repositories("); + + if (!repos.isEmpty()) { + builder.append(System.lineSeparator()); + } + + for (Map.Entry<String, List<Map<String, String>>> repo : repos.entrySet()) { + builder.append("Operating system: ").append(repo.getKey()); + builder.append(System.lineSeparator()); + for (Map<String, String> properties : repo.getValue()) { + builder.append(" Repository ID(").append(properties.get("repo_id")); + builder.append("), Repository name(").append(properties.get("repo_name")); + builder.append("), Base url(").append(properties.get("base_url")).append(")"); + builder.append(System.lineSeparator()); + } + } + + builder.append(")"); + } + + public AddRepositoryVersionAuditEventBuilder withStackName(String stackName) { + this.stackName = stackName; + return this; + } + + public AddRepositoryVersionAuditEventBuilder withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public AddRepositoryVersionAuditEventBuilder withStackVersion(String stackVersion) { + this.stackVersion = stackVersion; + return this; + } + + public AddRepositoryVersionAuditEventBuilder withRepoVersion(String repoVersion) { + this.repoVersion = repoVersion; + return this; + } + + public AddRepositoryVersionAuditEventBuilder withRepos(Map<String, List<Map<String, String>>> repos) { + this.repos = repos; + return this; + } + } + + protected AddRepositoryVersionRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddRepositoryVersionRequestAuditEvent(AddRepositoryVersionAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddRepositoryVersionRequestAuditEvent} + * + * @return a builder instance + */ + public static AddRepositoryVersionAuditEventBuilder builder() { + return new AddRepositoryVersionAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRequestRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRequestRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRequestRequestAuditEvent.java new file mode 100644 index 0000000..004c24a --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddRequestRequestAuditEvent.java @@ -0,0 +1,98 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for request + */ +@Immutable +public class AddRequestRequestAuditEvent extends RequestAuditEvent { + + public static class AddRequestAuditEventBuilder extends RequestAuditEventBuilder<AddRequestRequestAuditEvent, AddRequestAuditEventBuilder> { + + /** + * Command in the request + */ + private String command; + + /** + * Cluster name + */ + private String clusterName; + + public AddRequestAuditEventBuilder() { + super.withOperation("Request from server"); + } + + @Override + protected AddRequestRequestAuditEvent newAuditEvent() { + return new AddRequestRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Command(") + .append(command) + .append("), Cluster name(") + .append(clusterName) + .append(")"); + } + + public AddRequestAuditEventBuilder withClusterName(String clusterName) { + this.clusterName = clusterName; + return this; + } + + public AddRequestAuditEventBuilder withCommand(String command) { + this.command = command; + return this; + } + } + + protected AddRequestRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddRequestRequestAuditEvent(AddRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddRequestRequestAuditEvent} + * + * @return a builder instance + */ + public static AddRequestAuditEventBuilder builder() { + return new AddRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUpgradeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUpgradeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUpgradeRequestAuditEvent.java new file mode 100644 index 0000000..69b4536 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUpgradeRequestAuditEvent.java @@ -0,0 +1,111 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding upgrade + */ +@Immutable +public class AddUpgradeRequestAuditEvent extends RequestAuditEvent { + + public static class AddUpgradeRequestAuditEventBuilder extends RequestAuditEventBuilder<AddUpgradeRequestAuditEvent, AddUpgradeRequestAuditEventBuilder> { + + /** + * Repository version + */ + private String repositoryVersion; + + /** + * Upgrade type (rolling, non-rolling) + */ + private String upgradeType; + + /** + * Cluster name + */ + private String clusterName; + + + public AddUpgradeRequestAuditEventBuilder() { + super.withOperation("Upgrade addition"); + } + + @Override + protected AddUpgradeRequestAuditEvent newAuditEvent() { + return new AddUpgradeRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Repository version(") + .append(repositoryVersion) + .append("), Upgrade type(") + .append(upgradeType) + .append("), Cluster name(") + .append(clusterName) + .append(")"); + } + + public AddUpgradeRequestAuditEventBuilder withRepositoryVersion(String repositoryVersion) { + this.repositoryVersion = repositoryVersion; + return this; + } + + public AddUpgradeRequestAuditEventBuilder withUpgradeType(String upgradeType) { + this.upgradeType = upgradeType; + return this; + } + + public AddUpgradeRequestAuditEventBuilder withClusterName(String clusterName) { + this.clusterName = clusterName; + return this; + } + } + + protected AddUpgradeRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddUpgradeRequestAuditEvent(AddUpgradeRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddUpgradeRequestAuditEvent} + * + * @return a builder instance + */ + public static AddUpgradeRequestAuditEventBuilder builder() { + return new AddUpgradeRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUserToGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUserToGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUserToGroupRequestAuditEvent.java new file mode 100644 index 0000000..33293c0 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddUserToGroupRequestAuditEvent.java @@ -0,0 +1,98 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding a user to a group + */ +@Immutable +public class AddUserToGroupRequestAuditEvent extends RequestAuditEvent { + + public static class AddUserToGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<AddUserToGroupRequestAuditEvent, AddUserToGroupRequestAuditEventBuilder> { + + /** + * Group name + */ + private String groupName; + + /** + * Name of the user that is put to the group + */ + private String affectedUserName; + + public AddUserToGroupRequestAuditEventBuilder() { + super.withOperation("User addition to group"); + } + + @Override + protected AddUserToGroupRequestAuditEvent newAuditEvent() { + return new AddUserToGroupRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Group("); + builder.append(groupName); + builder.append("), Affected username("); + builder.append(affectedUserName); + builder.append(")"); + } + + public AddUserToGroupRequestAuditEventBuilder withGroupName(String groupName) { + this.groupName = groupName; + return this; + } + + public AddUserToGroupRequestAuditEventBuilder withAffectedUserName(String userName) { + this.affectedUserName = userName; + return this; + } + } + + protected AddUserToGroupRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddUserToGroupRequestAuditEvent(AddUserToGroupRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddUserToGroupRequestAuditEvent} + * + * @return a builder instance + */ + public static AddUserToGroupRequestAuditEventBuilder builder() { + return new AddUserToGroupRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddViewInstanceRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddViewInstanceRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddViewInstanceRequestAuditEvent.java new file mode 100644 index 0000000..d9ab59a --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AddViewInstanceRequestAuditEvent.java @@ -0,0 +1,134 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for adding view instance + */ +@Immutable +public class AddViewInstanceRequestAuditEvent extends RequestAuditEvent { + + public static class AddViewInstanceRequestAuditEventBuilder extends RequestAuditEventBuilder<AddViewInstanceRequestAuditEvent, AddViewInstanceRequestAuditEventBuilder> { + + /** + * View instance description + */ + private String description; + + /** + * View instance name + */ + private String name; + + /** + * View instance type (Files, Tez, etc) + */ + private String type; + + /** + * Display name for the view instance + */ + private String displayName; + + /** + * View instance version + */ + private String version; + + public AddViewInstanceRequestAuditEventBuilder() { + super.withOperation("View addition"); + } + + @Override + protected AddViewInstanceRequestAuditEvent newAuditEvent() { + return new AddViewInstanceRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Type(") + .append(type) + .append("), Version(") + .append(version) + .append("), Name(") + .append(name) + .append("), Display name(") + .append(displayName) + .append("), Description(") + .append(description) + .append(")"); + } + + public AddViewInstanceRequestAuditEventBuilder withDescription(String description) { + this.description = description; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withType(String type) { + this.type = type; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withVersion(String version) { + this.version = version; + return this; + } + } + + protected AddViewInstanceRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddViewInstanceRequestAuditEvent(AddViewInstanceRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddViewInstanceRequestAuditEvent} + * + * @return a builder instance + */ + public static AddViewInstanceRequestAuditEventBuilder builder() { + return new AddViewInstanceRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/565c2ea2/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AdminUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AdminUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AdminUserRequestAuditEvent.java new file mode 100644 index 0000000..a43d783 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/AdminUserRequestAuditEvent.java @@ -0,0 +1,101 @@ +/* + * 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.event.request; + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.request.RequestAuditEvent; + +/** + * Audit event for setting or unsetting a user as admin + */ +@Immutable +public class AdminUserRequestAuditEvent extends RequestAuditEvent { + + public static class AdminUserRequestAuditEventBuilder extends RequestAuditEventBuilder<AdminUserRequestAuditEvent, AdminUserRequestAuditEventBuilder> { + + /** + * Admin is set or not + */ + private boolean admin; + + /** + * Name of the user that is set or unset as admin + */ + private String username; + + public AdminUserRequestAuditEventBuilder() { + super.withOperation("Set user admin"); + } + + @Override + protected AdminUserRequestAuditEvent newAuditEvent() { + return new AdminUserRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Affeted username(") + .append(username) + .append("), ") + .append("Administrator(") + .append(admin ? "yes" : "no") + .append(")"); + } + + public AdminUserRequestAuditEventBuilder withAdmin(boolean admin) { + this.admin = admin; + return this; + } + + public AdminUserRequestAuditEventBuilder withAffectedUsername(String username) { + this.username = username; + return this; + } + + } + + protected AdminUserRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AdminUserRequestAuditEvent(AdminUserRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AdminUserRequestAuditEvent} + * + * @return a builder instance + */ + public static AdminUserRequestAuditEventBuilder builder() { + return new AdminUserRequestAuditEventBuilder(); + } + +}