http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/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 new file mode 100644 index 0000000..29dca27 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/OperationStatusAuditEvent.java @@ -0,0 +1,105 @@ +/* + * 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; + + +import javax.annotation.concurrent.Immutable; + +@Immutable +public class OperationStatusAuditEvent extends AbstractAuditEvent { + + public static class OperationStatusAuditEventBuilder extends AbstractAuditEventBuilder<OperationStatusAuditEvent, OperationStatusAuditEventBuilder> { + + /** + * Request identifier + */ + private String requestId; + + /** + * Status of the whole request + */ + private String status; + + /** + * Name of the operation + */ + private String operation; + + private OperationStatusAuditEventBuilder() { + } + + @Override + protected OperationStatusAuditEvent newAuditEvent() { + return new OperationStatusAuditEvent(this); + } + + /** + * Builds and audit log message based on the member variables + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + builder + .append("Operation(") + .append(this.operation) + .append("), Status(") + .append(this.status) + .append("), RequestId(") + .append(this.requestId) + .append(")"); + } + + + public OperationStatusAuditEventBuilder withStatus(String status) { + this.status = status; + return this; + } + + public OperationStatusAuditEventBuilder withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public OperationStatusAuditEventBuilder withRequestContext(String operation) { + this.operation = operation; + return this; + } + } + + private OperationStatusAuditEvent() { + } + + /** + * {@inheritDoc} + */ + private OperationStatusAuditEvent(OperationStatusAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link OperationStatusAuditEvent} + * + * @return a builder instance + */ + public static OperationStatusAuditEventBuilder builder() { + return new OperationStatusAuditEventBuilder(); + } + +}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/StartOperationAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/StartOperationAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/StartOperationAuditEvent.java new file mode 100644 index 0000000..58caf0a --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/StartOperationAuditEvent.java @@ -0,0 +1,115 @@ +/* + * 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; + + +import javax.annotation.concurrent.Immutable; + +/** + * Start operation request was accepted. + */ +@Immutable +public class StartOperationAuditEvent extends AbstractUserAuditEvent { + + public static class StartOperationAuditEventBuilder + extends AbstractUserAuditEventBuilder<StartOperationAuditEvent, StartOperationAuditEventBuilder> { + + private String requestId; + + private String reasonOfFailure; + + private String operation; + + private StartOperationAuditEventBuilder() { + } + + /** + * Appends to the audit event the identifier of the + * operation through whcih the operation progress can be tracked. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Operation(") + .append(operation) + .append("), RequestId(") + .append(requestId) + .append("), Status(") + .append(reasonOfFailure == null ? "Successfully queued" : "Failed to queue"); + + if (reasonOfFailure != null) { + builder.append("), Reason(") + .append(reasonOfFailure); + } + builder.append(")"); + } + + /** + * {@inheritDoc} + */ + @Override + protected StartOperationAuditEvent newAuditEvent() { + return new StartOperationAuditEvent(this); + } + + /** + * Sets the identifier of the operation through which the operation progress can be tracked. + * + * @param requestId the identifier of the operation through which the operation progress can be tracked. + * @return this builder + */ + public StartOperationAuditEventBuilder withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public StartOperationAuditEventBuilder withReasonOfFailure(String reasonOfFailure) { + this.reasonOfFailure = reasonOfFailure; + return this; + } + + public StartOperationAuditEventBuilder withOperation(String operation) { + this.operation = operation; + return this; + } + } + + private StartOperationAuditEvent() { + } + + /** + * {@inheritDoc} + */ + private StartOperationAuditEvent(StartOperationAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link StartOperationAuditEvent} + * + * @return a builder instance + */ + public static StartOperationAuditEventBuilder builder() { + return new StartOperationAuditEventBuilder(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/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 new file mode 100644 index 0000000..985d8fd --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/TaskStatusAuditEvent.java @@ -0,0 +1,145 @@ +/* + * 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; + + +import javax.annotation.concurrent.Immutable; + +@Immutable +public class TaskStatusAuditEvent extends AbstractAuditEvent { + + public static class TaskStatusAuditEventBuilder extends AbstractAuditEventBuilder<TaskStatusAuditEvent, TaskStatusAuditEventBuilder> { + + /** + * Request identifier + */ + private String requestId; + + /** + * Task identifier + */ + private String taskId; + + /** + * Request identifier + */ + private String hostName; + + /** + * Status of the whole request + */ + private String status; + + /** + * Name of the operation + */ + private String operation; + + /** + * Task command details + */ + private String details; + + private TaskStatusAuditEventBuilder() { + } + + @Override + protected TaskStatusAuditEvent newAuditEvent() { + return new TaskStatusAuditEvent(this); + } + + /** + * Builds and audit log message based on the member variables + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + builder + .append("Operation(") + .append(this.operation); + + if (details != null) { + builder.append("), Details(") + .append(this.details); + } + + builder.append("), Status(") + .append(this.status) + .append("), RequestId(") + .append(this.requestId) + .append("), TaskId(") + .append(this.taskId) + .append("), Hostname(") + .append(this.hostName) + .append(")"); + } + + + public TaskStatusAuditEventBuilder withStatus(String status) { + this.status = status; + return this; + } + + public TaskStatusAuditEventBuilder withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public TaskStatusAuditEventBuilder withTaskId(String taskId) { + this.taskId = taskId; + return this; + } + + public TaskStatusAuditEventBuilder withHostName(String hostName) { + this.hostName = hostName; + return this; + } + + public TaskStatusAuditEventBuilder withOperation(String operation) { + this.operation = operation; + return this; + } + + public TaskStatusAuditEventBuilder withDetails(String details) { + this.details = details; + return this; + } + } + + private TaskStatusAuditEvent() { + } + + /** + * {@inheritDoc} + */ + private TaskStatusAuditEvent(TaskStatusAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link TaskStatusAuditEvent} + * + * @return a builder instance + */ + public static TaskStatusAuditEventBuilder builder() { + return new TaskStatusAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/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 new file mode 100644 index 0000000..a13beb8 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/AbstractKerberosAuditEvent.java @@ -0,0 +1,77 @@ +/* + * 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.kerberos; + + +import javax.annotation.concurrent.Immutable; + +import org.apache.ambari.server.audit.event.AbstractAuditEvent; + +@Immutable +public class AbstractKerberosAuditEvent extends AbstractAuditEvent { + static abstract class AbstractKerberosAuditEventBuilder<T extends AbstractKerberosAuditEvent, TBuilder extends AbstractKerberosAuditEventBuilder<T, TBuilder>> + extends AbstractAuditEvent.AbstractAuditEventBuilder<T, TBuilder> { + + protected String operation; + protected String reasonOfFailure; + + /** + * Builds and audit log message based on the member variables + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + builder + .append("Operation(") + .append(operation); + + builder.append("), Status(") + .append(reasonOfFailure == null ? "Success" : "Failed"); + + if (reasonOfFailure != null) { + builder.append("), Reason of failure(") + .append(reasonOfFailure); + } + + builder.append(")"); + } + + public TBuilder withOperation(String operation) { + this.operation = operation; + return (TBuilder) this; + } + + public TBuilder withReasonOfFailure(String reasonOfFailure) { + this.reasonOfFailure = reasonOfFailure; + return (TBuilder) this; + } + } + + protected AbstractKerberosAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AbstractKerberosAuditEvent(AbstractKerberosAuditEventBuilder<?, ?> builder) { + super(builder); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/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 new file mode 100644 index 0000000..180eb93 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/ChangeSecurityStateKerberosAuditEvent.java @@ -0,0 +1,100 @@ +/* + * 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.kerberos; + +import javax.annotation.concurrent.Immutable; + +@Immutable +public class ChangeSecurityStateKerberosAuditEvent extends AbstractKerberosAuditEvent { + + public static class ChangeSecurityStateKerberosAuditEventBuilder extends AbstractKerberosAuditEventBuilder<ChangeSecurityStateKerberosAuditEvent, ChangeSecurityStateKerberosAuditEventBuilder> { + + private String service; + private String component; + private String hostName; + private String state; + + private ChangeSecurityStateKerberosAuditEventBuilder() { + this.withOperation("Security state change"); + } + + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Hostname(") + .append(hostName) + .append("), Service(") + .append(service) + .append("), Component(") + .append(component) + .append("), State(") + .append(state) + .append(")"); + } + + /** + * {@inheritDoc} + */ + @Override + protected ChangeSecurityStateKerberosAuditEvent newAuditEvent() { + return new ChangeSecurityStateKerberosAuditEvent(this); + } + + public ChangeSecurityStateKerberosAuditEventBuilder withService(String service) { + this.service = service; + return this; + } + + public ChangeSecurityStateKerberosAuditEventBuilder withComponent(String component) { + this.component = component; + return this; + } + + public ChangeSecurityStateKerberosAuditEventBuilder withHostName(String hostName) { + this.hostName = hostName; + return this; + } + + public ChangeSecurityStateKerberosAuditEventBuilder withState(String state) { + this.state = state; + return this; + } + } + + private ChangeSecurityStateKerberosAuditEvent() { + } + + /** + * {@inheritDoc} + */ + private ChangeSecurityStateKerberosAuditEvent(ChangeSecurityStateKerberosAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ChangeSecurityStateKerberosAuditEvent} + * + * @return a builder instance + */ + public static ChangeSecurityStateKerberosAuditEventBuilder builder() { + return new ChangeSecurityStateKerberosAuditEventBuilder(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/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 new file mode 100644 index 0000000..a17bb32 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreateKeyTabKerberosAuditEvent.java @@ -0,0 +1,96 @@ +/* + * 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.kerberos; + +import javax.annotation.concurrent.Immutable; + +@Immutable +public class CreateKeyTabKerberosAuditEvent extends AbstractKerberosAuditEvent { + + public static class CreateKeyTabKerberosAuditEventBuilder extends AbstractKerberosAuditEventBuilder<CreateKeyTabKerberosAuditEvent, CreateKeyTabKerberosAuditEventBuilder> { + + private String keyTabFilePath; + private String hostName; + private String principal; + + private CreateKeyTabKerberosAuditEventBuilder() { + this.withOperation("Keytab file creation"); + } + + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Principal(") + .append(principal) + .append("), Hostname(") + .append(hostName) + .append("), Keytab file(") + .append(keyTabFilePath) + .append(")"); + } + + /** + * {@inheritDoc} + */ + @Override + protected CreateKeyTabKerberosAuditEvent newAuditEvent() { + return new CreateKeyTabKerberosAuditEvent(this); + } + + public CreateKeyTabKerberosAuditEventBuilder withKeyTabFilePath(String keyTabFilePath) { + this.keyTabFilePath = keyTabFilePath; + return this; + } + + public CreateKeyTabKerberosAuditEventBuilder withHostName(String hostName) { + this.hostName = hostName; + return this; + } + + public CreateKeyTabKerberosAuditEventBuilder withPrincipal(String principal) { + this.principal = principal; + return this; + } + + public boolean hasPrincipal() { + return principal != null; + } + } + + private CreateKeyTabKerberosAuditEvent() { + } + + /** + * {@inheritDoc} + */ + private CreateKeyTabKerberosAuditEvent(CreateKeyTabKerberosAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link CreateKeyTabKerberosAuditEvent} + * + * @return a builder instance + */ + public static CreateKeyTabKerberosAuditEventBuilder builder() { + return new CreateKeyTabKerberosAuditEventBuilder(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/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 new file mode 100644 index 0000000..f8ac9fb --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/CreatePrincipalKerberosAuditEvent.java @@ -0,0 +1,73 @@ +/* + * 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.kerberos; + +import javax.annotation.concurrent.Immutable; + +@Immutable +public class CreatePrincipalKerberosAuditEvent extends AbstractKerberosAuditEvent { + + public static class CreatePrincipalKerberosAuditEventBuilder extends AbstractKerberosAuditEventBuilder<CreatePrincipalKerberosAuditEvent, CreatePrincipalKerberosAuditEventBuilder> { + + private String principal; + + private CreatePrincipalKerberosAuditEventBuilder() { + this.withOperation("Principal creation"); + } + + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + builder.append("), Principal(") + .append(principal); + } + + /** + * {@inheritDoc} + */ + @Override + protected CreatePrincipalKerberosAuditEvent newAuditEvent() { + return new CreatePrincipalKerberosAuditEvent(this); + } + + public CreatePrincipalKerberosAuditEventBuilder withPrincipal(String principal) { + this.principal = principal; + return this; + } + } + + private CreatePrincipalKerberosAuditEvent() { + } + + /** + * {@inheritDoc} + */ + private CreatePrincipalKerberosAuditEvent(CreatePrincipalKerberosAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link CreatePrincipalKerberosAuditEvent} + * + * @return a builder instance + */ + public static CreatePrincipalKerberosAuditEventBuilder builder() { + return new CreatePrincipalKerberosAuditEventBuilder(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/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 new file mode 100644 index 0000000..da7f250 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/kerberos/DestroyPrincipalKerberosAuditEvent.java @@ -0,0 +1,74 @@ +/* + * 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.kerberos; + +import javax.annotation.concurrent.Immutable; + +@Immutable +public class DestroyPrincipalKerberosAuditEvent extends AbstractKerberosAuditEvent { + + public static class DestroyPrincipalKerberosAuditEventBuilder extends AbstractKerberosAuditEventBuilder<DestroyPrincipalKerberosAuditEvent, DestroyPrincipalKerberosAuditEventBuilder> { + + private String principal; + + private DestroyPrincipalKerberosAuditEventBuilder() { + this.withOperation("Principal removal"); + } + + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append("), Principal(") + .append(principal); + } + + /** + * {@inheritDoc} + */ + @Override + protected DestroyPrincipalKerberosAuditEvent newAuditEvent() { + return new DestroyPrincipalKerberosAuditEvent(this); + } + + public DestroyPrincipalKerberosAuditEventBuilder withPrincipal(String principal) { + this.principal = principal; + return this; + } + } + + private DestroyPrincipalKerberosAuditEvent() { + } + + /** + * {@inheritDoc} + */ + private DestroyPrincipalKerberosAuditEvent(DestroyPrincipalKerberosAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DestroyPrincipalKerberosAuditEvent} + * + * @return a builder instance + */ + public static DestroyPrincipalKerberosAuditEventBuilder builder() { + return new DestroyPrincipalKerberosAuditEventBuilder(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditEvent.java new file mode 100644 index 0000000..0bb9b25 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditEvent.java @@ -0,0 +1,145 @@ +/* + * 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 org.apache.ambari.server.api.services.Request; +import org.apache.ambari.server.api.services.ResultStatus; +import org.apache.ambari.server.audit.event.AbstractUserAuditEvent; + +/** + * Base class for start operation audit events. + */ +public class RequestAuditEvent extends AbstractUserAuditEvent { + + public static class RequestAuditEventBuilder<T extends RequestAuditEvent, TBuilder extends RequestAuditEventBuilder<T, TBuilder>> extends AbstractUserAuditEventBuilder<T, TBuilder> { + + private Request.Type requestType; + + private ResultStatus resultStatus; + + private String url; + + private String operation; + + @Override + protected T newAuditEvent() { + return (T) new RequestAuditEvent(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); + if (operation != null) { + builder + .append(", Operation(") + .append(operation) + .append(")"); + } + builder + .append(", RequestType(") + .append(requestType) + .append("), ") + .append("url(") + .append(url) + .append("), ResultStatus(") + .append(resultStatus.getStatusCode()) + .append(" ") + .append(resultStatus.getStatus()) + .append(")"); + + if (resultStatus.isErrorState()) { + builder.append(", Reason(") + .append(resultStatus.getMessage()) + .append(")"); + } + } + + /** + * Sets the request type to be added to the audit event. + * + * @param requestType request type to be added to the audit event. + * @return this builder + */ + public TBuilder withRequestType(Request.Type requestType) { + this.requestType = requestType; + + return (TBuilder) this; + } + + /** + * Sets the url to be added to the audit event. + * + * @param url url to be added to the audit event. + * @return this builder + */ + public TBuilder withUrl(String url) { + this.url = url; + + return (TBuilder) this; + } + + /** + * Sets the result status to be added to the audit event. + * + * @param resultStatus result status to be added to the audit event. + * @return this builder + */ + public TBuilder withResultStatus(ResultStatus resultStatus) { + this.resultStatus = resultStatus; + + return (TBuilder) this; + } + + /** + * Sets the operation to be added to the audit event. + * + * @param operation operation to be added to the audit event. + * @return this builder + */ + public TBuilder withOperation(String operation) { + this.operation = operation; + + return (TBuilder) this; + } + } + + protected RequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected RequestAuditEvent(RequestAuditEventBuilder<?, ?> builder) { + super(builder); + } + + /** + * Returns an builder for {@link RequestAuditEvent} + * + * @return a builder instance + */ + public static RequestAuditEventBuilder<?, ?> builder() { + return new RequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditEventCreator.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditEventCreator.java new file mode 100644 index 0000000..e642541 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/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 + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request; + +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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLogger.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLogger.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLogger.java new file mode 100644 index 0000000..a5003e0 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLogger.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request; + +import org.apache.ambari.server.api.services.Request; +import org.apache.ambari.server.api.services.Result; + +/** + * Audit logger interface for logging requests + */ +public interface RequestAuditLogger { + + /** + * Logs an audit event based on the http request and result + * @param request + * @param result + */ + void log(Request request, Result result); + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLoggerImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLoggerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLoggerImpl.java new file mode 100644 index 0000000..0c9edea --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/RequestAuditLoggerImpl.java @@ -0,0 +1,146 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request; + + +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.AuditLogger; +import org.apache.ambari.server.audit.event.AuditEvent; +import org.apache.ambari.server.controller.spi.Resource; + +import com.google.inject.Inject; +import com.google.inject.Singleton; + +/** + * The purpose of this class is to create audit log entries for the HTTP requests + */ +@Singleton +public class RequestAuditLoggerImpl implements RequestAuditLogger { + + /** + * Priorities for searching the proper creator + */ + private static final int REQUEST_TYPE_PRIORITY = 1; + private static final int RESULT_STATUS_PRIORITY = 2; + private static final int RESOURCE_TYPE_PRIORITY = 4; + + /** + * Container for the {@link RequestAuditEventCreator} + */ + private Set<RequestAuditEventCreator> creators; + + /** + * Audit logger that receives {@link AuditEvent}s and does the actual logging + */ + private AuditLogger auditLogger; + + /** + * Injecting dependencies through the constructor + * @param auditLogger Audit Logger + * @param creatorSet Set of plugins that are registered for requests + */ + @Inject + public RequestAuditLoggerImpl(AuditLogger auditLogger, Set<RequestAuditEventCreator> creatorSet) { + this.auditLogger = auditLogger; + this.creators = creatorSet; + } + + /** + * Finds the proper creator, then creates and logs and {@link AuditEvent} + * @param request + * @param result + */ + @Override + public void log(Request request, Result result) { + Resource.Type resourceType = request.getResource().getResourceDefinition().getType(); + Request.Type requestType = request.getRequestType(); + ResultStatus resultStatus = result.getStatus(); + + RequestAuditEventCreator creator = selectCreator(resourceType, resultStatus, requestType); + if (creator != null) { + AuditEvent ae = creator.createAuditEvent(request, result); + if (ae != null) { + auditLogger.log(ae); + } + } + } + + /** + * Select the proper creator. Priority order: resourceType > resultStatus > requestType + * The most matching creator is returned + * If there is no creator found, then null is returned. + * @param resourceType + * @param requestType + * @param resultStatus + * @return + */ + private RequestAuditEventCreator selectCreator(Resource.Type resourceType, ResultStatus resultStatus, Request.Type requestType) { + + RequestAuditEventCreator selected = null; + Integer priority = -1; + + for (RequestAuditEventCreator creator : creators) { + Integer creatorPriority = getPriority(creator, resourceType, resultStatus, requestType); + if (creatorPriority != null && priority < creatorPriority) { + priority = creatorPriority; + selected = creator; + } + } + return selected; + } + + /** + * Calculates the creator priority for the actual resouce type, result status and request type + * @param creator + * @param resourceType + * @param resultStatus + * @param requestType + * @return + */ + private Integer getPriority(RequestAuditEventCreator creator, Resource.Type resourceType, ResultStatus resultStatus, Request.Type requestType) { + Integer priority = 0; + + if (isIncompatible(creator, resourceType, resultStatus, requestType)) { + return null; + } + + priority += creator.getRequestTypes() != null && creator.getRequestTypes().contains(requestType) ? REQUEST_TYPE_PRIORITY : 0; + priority += creator.getResultStatuses() != null && creator.getResultStatuses().contains(resultStatus.getStatus()) ? RESULT_STATUS_PRIORITY : 0; + priority += creator.getResourceTypes() != null && creator.getResourceTypes().contains(resourceType) ? RESOURCE_TYPE_PRIORITY : 0; + return priority; + } + + /** + * Checks if the creator is a possible candidate for creating audit log event for the request + * @param creator + * @param resourceType + * @param resultStatus + * @param requestType + * @return + */ + private boolean isIncompatible(RequestAuditEventCreator creator, Resource.Type resourceType, ResultStatus resultStatus, Request.Type requestType) { + return creator.getRequestTypes() != null && !creator.getRequestTypes().contains(requestType) || + creator.getResultStatuses() != null && !creator.getResultStatuses().contains(resultStatus.getStatus()) || + creator.getResourceTypes() != null && !creator.getResourceTypes().contains(resourceType); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ActivateUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ActivateUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ActivateUserRequestAuditEvent.java new file mode 100644 index 0000000..937291c --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ActivateUserRequestAuditEvent.java @@ -0,0 +1,89 @@ +/* + * 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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class ActivateUserRequestAuditEvent extends RequestAuditEvent { + + public static class ActivateUserRequestAuditEventBuilder extends RequestAuditEventBuilder<ActivateUserRequestAuditEvent, ActivateUserRequestAuditEventBuilder> { + + private boolean active; + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertGroupRequestAuditEvent.java new file mode 100644 index 0000000..51e8045 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertGroupRequestAuditEvent.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.event; + +import java.util.List; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +public class AddAlertGroupRequestAuditEvent extends RequestAuditEvent { + + public static class AddAlertGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<AddAlertGroupRequestAuditEvent, AddAlertGroupRequestAuditEventBuilder> { + + private String name; + + private List<String> definitionIds; + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertTargetRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertTargetRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertTargetRequestAuditEvent.java new file mode 100644 index 0000000..fc5ccc5 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddAlertTargetRequestAuditEvent.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.event; + +import java.util.List; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +public class AddAlertTargetRequestAuditEvent extends RequestAuditEvent { + + public static class AddAlertTargetRequestAuditEventBuilder extends RequestAuditEventBuilder<AddAlertTargetRequestAuditEvent, AddAlertTargetRequestAuditEventBuilder> { + + private String name; + private String description; + private String notificationType; + private List<String> groupIds; + private String emailFrom; + private List<String> emailRecipients; + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddBlueprintRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddBlueprintRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddBlueprintRequestAuditEvent.java new file mode 100644 index 0000000..2e0cce4 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddBlueprintRequestAuditEvent.java @@ -0,0 +1,79 @@ +/* + * 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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddBlueprintRequestAuditEvent extends RequestAuditEvent { + + public static class AddBlueprintRequestAuditEventBuilder extends RequestAuditEventBuilder<AddBlueprintRequestAuditEvent, AddBlueprintRequestAuditEventBuilder> { + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddComponentToHostRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddComponentToHostRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddComponentToHostRequestAuditEvent.java new file mode 100644 index 0000000..ad6233a --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddComponentToHostRequestAuditEvent.java @@ -0,0 +1,85 @@ +/* + * 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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddComponentToHostRequestAuditEvent extends RequestAuditEvent { + + public static class AddComponentToHostRequestAuditEventBuilder extends RequestAuditEventBuilder<AddComponentToHostRequestAuditEvent, AddComponentToHostRequestAuditEventBuilder> { + + private String hostName; + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddCredentialRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddCredentialRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddCredentialRequestAuditEvent.java new file mode 100644 index 0000000..2804820 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddCredentialRequestAuditEvent.java @@ -0,0 +1,104 @@ +/* + * 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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddCredentialRequestAuditEvent extends RequestAuditEvent { + + public static class AddCredentialAuditEventBuilder extends RequestAuditEventBuilder<AddCredentialRequestAuditEvent, AddCredentialAuditEventBuilder> { + + private String type; + + private String clusterName; + + private String principal; + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddHostRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddHostRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddHostRequestAuditEvent.java new file mode 100644 index 0000000..8d7206e --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddHostRequestAuditEvent.java @@ -0,0 +1,77 @@ +/* + * 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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddHostRequestAuditEvent extends RequestAuditEvent { + + public static class AddHostRequestAuditEventBuilder extends RequestAuditEventBuilder<AddHostRequestAuditEvent, AddHostRequestAuditEventBuilder> { + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryRequestAuditEvent.java new file mode 100644 index 0000000..2635b44 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryRequestAuditEvent.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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddRepositoryRequestAuditEvent extends RequestAuditEvent { + + public static class AddRepositoryRequestAuditEventBuilder extends RequestAuditEventBuilder<AddRepositoryRequestAuditEvent, AddRepositoryRequestAuditEventBuilder> { + + private String repo; + + private String stackName; + + private String osType; + + private String baseUrl; + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryVersionRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryVersionRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryVersionRequestAuditEvent.java new file mode 100644 index 0000000..0d95636 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRepositoryVersionRequestAuditEvent.java @@ -0,0 +1,131 @@ +/* + * 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.event; + +import java.util.List; +import java.util.Map; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddRepositoryVersionRequestAuditEvent extends RequestAuditEvent { + + public static class AddRepositoryVersionAuditEventBuilder extends RequestAuditEventBuilder<AddRepositoryVersionRequestAuditEvent, AddRepositoryVersionAuditEventBuilder> { + + private String stackName; + + private String displayName; + + private String stackVersion; + + private String repoVersion; + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRequestRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRequestRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRequestRequestAuditEvent.java new file mode 100644 index 0000000..3095d09 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddRequestRequestAuditEvent.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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddRequestRequestAuditEvent extends RequestAuditEvent { + + public static class AddRequestAuditEventBuilder extends RequestAuditEventBuilder<AddRequestRequestAuditEvent, AddRequestAuditEventBuilder> { + + private String command; + + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUpgradeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUpgradeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUpgradeRequestAuditEvent.java new file mode 100644 index 0000000..0fc1b06 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUpgradeRequestAuditEvent.java @@ -0,0 +1,94 @@ +/* + * 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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddUpgradeRequestAuditEvent extends RequestAuditEvent { + + public static class AddUpgradeRequestAuditEventBuilder extends RequestAuditEventBuilder<AddUpgradeRequestAuditEvent, AddUpgradeRequestAuditEventBuilder> { + + private String repositoryVersion; + private String upgradeType; + 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/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUserToGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUserToGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUserToGroupRequestAuditEvent.java new file mode 100644 index 0000000..1e18268 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddUserToGroupRequestAuditEvent.java @@ -0,0 +1,85 @@ +/* + * 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.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddUserToGroupRequestAuditEvent extends RequestAuditEvent { + + public static class AddUserToGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<AddUserToGroupRequestAuditEvent, AddUserToGroupRequestAuditEventBuilder> { + + private String groupName; + 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(); + } + +}
