You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ho...@apache.org on 2026/10/23 12:21:11 UTC
(streampipes) branch revert-5120-5115-add-configuration-to-audit-log created (now 0e577ae741)
This is an automated email from the ASF dual-hosted git repository.
JHoelli pushed a change to branch revert-5120-5115-add-configuration-to-audit-log
in repository https://gitbox.apache.org/repos/asf/streampipes.git
at 0e577ae741 Revert "feat(#5115): audit settings changes (#5120)"
This branch includes the following new commits:
new 0e577ae741 Revert "feat(#5115): audit settings changes (#5120)"
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(streampipes) 01/01: Revert "feat(#5115): audit settings changes (#5120)"
Posted by ho...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
JHoelli pushed a commit to branch revert-5120-5115-add-configuration-to-audit-log
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 0e577ae7411bfab4ae722d4ab33f9cc8f11dc537
Author: Jacqueline Höllig <78...@users.noreply.github.com>
AuthorDate: Fri Oct 23 14:21:00 2026 +0200
Revert "feat(#5115): audit settings changes (#5120)"
This reverts commit 57a6ad4d7c1cbc25f9c0773921ccd9c2f1479d85.
---
.../audit/events/StandardAuditEvents.java | 37 -----
.../audit/events/security/GroupAuditDetails.java | 27 ----
.../events/security/SecurityAuditRecorder.java | 83 ----------
.../events/settings/AssetTransferDetails.java | 32 ----
.../settings/ExportProviderAuditDetails.java | 30 ----
.../audit/events/settings/FileAuditDetails.java | 25 ---
.../audit/events/settings/MailAuditDetails.java | 30 ----
.../events/settings/SettingsAuditRecorder.java | 177 ---------------------
.../events/security/SecurityAuditRecorderTest.java | 80 ----------
.../events/settings/SettingsAuditRecorderTest.java | 140 ----------------
.../apache/streampipes/rest/impl/FileResource.java | 20 +--
.../rest/impl/admin/DataExportResource.java | 26 +--
.../rest/impl/admin/DataImportResource.java | 11 --
.../impl/admin/EmailConfigurationResource.java | 10 +-
.../admin/ExportProviderConfigurationResource.java | 26 +--
.../rest/impl/admin/UserGroupResource.java | 17 +-
16 files changed, 18 insertions(+), 753 deletions(-)
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
index a3cb8c8808..8cd6f33c10 100644
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
@@ -24,11 +24,6 @@ import org.apache.streampipes.audit.events.adapter.AdapterCreatedDetails;
import org.apache.streampipes.audit.events.adapter.AdapterEditedDetails;
import org.apache.streampipes.audit.events.adapter.AdapterLifecycleDetails;
import org.apache.streampipes.audit.events.authentication.AuthenticationDetails;
-import org.apache.streampipes.audit.events.security.GroupAuditDetails;
-import org.apache.streampipes.audit.events.settings.AssetTransferDetails;
-import org.apache.streampipes.audit.events.settings.ExportProviderAuditDetails;
-import org.apache.streampipes.audit.events.settings.FileAuditDetails;
-import org.apache.streampipes.audit.events.settings.MailAuditDetails;
import org.apache.streampipes.audit.events.dataset.DatasetCreatedDetails;
import org.apache.streampipes.audit.events.dataset.DatasetDataClearedDetails;
import org.apache.streampipes.audit.events.dataset.DatasetDataDeletedDetails;
@@ -97,40 +92,8 @@ public final class StandardAuditEvents implements AuditEventProvider {
public static final AuditEventDefinition<AuthenticationDetails> AUTH_LOGOUT =
new AuditEventDefinition<>("sp.auth.logout", AuthenticationDetails.class);
- public static final AuditEventDefinition<GroupAuditDetails> SECURITY_GROUP_CREATE =
- new AuditEventDefinition<>("sp.security.group.create", GroupAuditDetails.class, "security-group");
- public static final AuditEventDefinition<GroupAuditDetails> SECURITY_GROUP_UPDATE =
- new AuditEventDefinition<>("sp.security.group.update", GroupAuditDetails.class, "security-group");
- public static final AuditEventDefinition<GroupAuditDetails> SECURITY_GROUP_DELETE =
- new AuditEventDefinition<>("sp.security.group.delete", GroupAuditDetails.class, "security-group");
-
- public static final AuditEventDefinition<AssetTransferDetails> EXPORT_DOWNLOAD =
- new AuditEventDefinition<>("sp.export.download", AssetTransferDetails.class, "export");
- public static final AuditEventDefinition<AssetTransferDetails> IMPORT_EXECUTE =
- new AuditEventDefinition<>("sp.import.execute", AssetTransferDetails.class, "import");
-
- public static final AuditEventDefinition<ExportProviderAuditDetails> EXPORT_PROVIDER_CREATE =
- new AuditEventDefinition<>("sp.export-provider.create", ExportProviderAuditDetails.class, "export-provider");
- public static final AuditEventDefinition<ExportProviderAuditDetails> EXPORT_PROVIDER_UPDATE =
- new AuditEventDefinition<>("sp.export-provider.update", ExportProviderAuditDetails.class, "export-provider");
- public static final AuditEventDefinition<ExportProviderAuditDetails> EXPORT_PROVIDER_DELETE =
- new AuditEventDefinition<>("sp.export-provider.delete", ExportProviderAuditDetails.class, "export-provider");
- public static final AuditEventDefinition<FileAuditDetails> FILE_UPLOAD =
- new AuditEventDefinition<>("sp.file.upload", FileAuditDetails.class, "file");
- public static final AuditEventDefinition<FileAuditDetails> FILE_DELETE =
- new AuditEventDefinition<>("sp.file.delete", FileAuditDetails.class, "file");
-
- public static final AuditEventDefinition<MailAuditDetails> MAIL_CONFIGURATION_UPDATE =
- new AuditEventDefinition<>("sp.mail.configuration.update", MailAuditDetails.class, "mail-configuration");
- public static final AuditEventDefinition<MailAuditDetails> MAIL_TEMPLATE_UPDATE =
- new AuditEventDefinition<>("sp.mail.template.update", MailAuditDetails.class, "mail-template");
private static final List<AuditEventDefinition<?>> EVENT_TYPES = List.of(
- ADAPTER_CREATE, ADAPTER_START, ADAPTER_STOP, ADAPTER_EDIT, AUTH_LOGIN, AUTH_LOGOUT,
- SECURITY_GROUP_CREATE, SECURITY_GROUP_UPDATE, SECURITY_GROUP_DELETE,
- EXPORT_DOWNLOAD, IMPORT_EXECUTE,
- EXPORT_PROVIDER_CREATE, EXPORT_PROVIDER_UPDATE, EXPORT_PROVIDER_DELETE,
- FILE_UPLOAD, FILE_DELETE, MAIL_CONFIGURATION_UPDATE, MAIL_TEMPLATE_UPDATE);
DATASET_CREATE, DATASET_EDIT, DATASET_DELETE,
DATASET_DATA_DELETE, DATASET_DATA_TRUNCATE, DATASET_DROP, DATASET_DATA_CLEAR,
DATASET_RETENTION_CONFIGURE, DATASET_RETENTION_REMOVE, DATASET_RETENTION_RUN,
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/security/GroupAuditDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/security/GroupAuditDetails.java
deleted file mode 100644
index 5417a274dc..0000000000
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/security/GroupAuditDetails.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.security;
-
-import org.apache.streampipes.audit.api.AuditDetails;
-
-import java.util.List;
-
-/** Changed group fields only; does not expose group names, external IDs, or role assignments. */
-public record GroupAuditDetails(List<String> changedFields) implements AuditDetails {
-}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/security/SecurityAuditRecorder.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/security/SecurityAuditRecorder.java
deleted file mode 100644
index e26a946c90..0000000000
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/security/SecurityAuditRecorder.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.security;
-
-import org.apache.streampipes.audit.api.AuditOutcome;
-import org.apache.streampipes.audit.api.AuditService;
-import org.apache.streampipes.audit.events.StandardAuditEvents;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-/** Publishes group lifecycle events without serializing security assignments or external identifiers. */
-public final class SecurityAuditRecorder {
- private final AuditService auditService;
-
- public SecurityAuditRecorder(AuditService auditService) {
- this.auditService = Objects.requireNonNull(auditService);
- }
-
- public void groupCreated(String actor, String groupId) {
- auditService.record(StandardAuditEvents.SECURITY_GROUP_CREATE, AuditOutcome.SUCCEEDED, actor,
- groupId, new GroupAuditDetails(List.of()));
- }
-
- public void groupUpdated(String actor,
- String groupId,
- String beforeName,
- String afterName,
- Set<String> beforeRoles,
- Set<String> afterRoles,
- Set<String> beforeAlternateIds,
- Set<String> afterAlternateIds) {
- auditService.record(StandardAuditEvents.SECURITY_GROUP_UPDATE, AuditOutcome.SUCCEEDED, actor,
- groupId, new GroupAuditDetails(changedFields(beforeName, afterName, beforeRoles, afterRoles,
- beforeAlternateIds, afterAlternateIds)));
- }
-
- public void groupDeleted(String actor, String groupId) {
- auditService.record(StandardAuditEvents.SECURITY_GROUP_DELETE, AuditOutcome.SUCCEEDED, actor,
- groupId, new GroupAuditDetails(List.of()));
- }
-
- private List<String> changedFields(String beforeName,
- String afterName,
- Set<String> beforeRoles,
- Set<String> afterRoles,
- Set<String> beforeAlternateIds,
- Set<String> afterAlternateIds) {
- if (beforeName == null && beforeRoles == null && beforeAlternateIds == null) {
- return List.of("group");
- }
-
- var changes = new ArrayList<String>();
- addIfChanged(changes, "groupName", beforeName, afterName);
- addIfChanged(changes, "roles", beforeRoles, afterRoles);
- addIfChanged(changes, "alternateIds", beforeAlternateIds, afterAlternateIds);
- return List.copyOf(changes);
- }
-
- private void addIfChanged(List<String> changes, String field, Object before, Object after) {
- if (!Objects.equals(before, after)) {
- changes.add(field);
- }
- }
-}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/AssetTransferDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/AssetTransferDetails.java
deleted file mode 100644
index f9f28f2918..0000000000
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/AssetTransferDetails.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.settings;
-
-import org.apache.streampipes.audit.api.AuditDetails;
-
-import java.util.List;
-
-/** Bounded transfer scope. The package contents and export item labels are deliberately excluded. */
-public record AssetTransferDetails(List<String> assetIds, int assetCount,
- boolean overwriteExistingDocuments,
- boolean overrideBrokerSettings) implements AuditDetails {
- public AssetTransferDetails {
- assetIds = List.copyOf(assetIds);
- }
-}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/ExportProviderAuditDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/ExportProviderAuditDetails.java
deleted file mode 100644
index 6753adc82d..0000000000
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/ExportProviderAuditDetails.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.settings;
-
-import org.apache.streampipes.audit.api.AuditDetails;
-
-import java.util.List;
-
-/** Safe provider metadata; changed fields name credentials but never expose their values. */
-public record ExportProviderAuditDetails(String providerType, List<String> changedFields) implements AuditDetails {
- public ExportProviderAuditDetails {
- changedFields = List.copyOf(changedFields);
- }
-}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/FileAuditDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/FileAuditDetails.java
deleted file mode 100644
index 5701550822..0000000000
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/FileAuditDetails.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.settings;
-
-import org.apache.streampipes.audit.api.AuditDetails;
-
-/** File type is retained for audit filtering; names and contents are excluded. */
-public record FileAuditDetails(String fileType) implements AuditDetails {
-}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/MailAuditDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/MailAuditDetails.java
deleted file mode 100644
index ee9d8c29b5..0000000000
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/MailAuditDetails.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.settings;
-
-import org.apache.streampipes.audit.api.AuditDetails;
-
-import java.util.List;
-
-/** Changed field names only; server, recipient, credentials, and template contents are never stored. */
-public record MailAuditDetails(List<String> changedFields) implements AuditDetails {
- public MailAuditDetails {
- changedFields = List.copyOf(changedFields);
- }
-}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/SettingsAuditRecorder.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/SettingsAuditRecorder.java
deleted file mode 100644
index 97bebaf32a..0000000000
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/settings/SettingsAuditRecorder.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.settings;
-
-import org.apache.streampipes.audit.api.AuditOutcome;
-import org.apache.streampipes.audit.api.AuditService;
-import org.apache.streampipes.audit.events.StandardAuditEvents;
-import org.apache.streampipes.model.configuration.EmailConfig;
-import org.apache.streampipes.model.configuration.ExportProviderSettings;
-import org.apache.streampipes.model.export.AssetExportConfiguration;
-import org.apache.streampipes.model.export.ExportConfiguration;
-import org.apache.streampipes.model.file.FileMetadata;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-/** Publishes bounded settings events without serializing configuration values or file contents. */
-public final class SettingsAuditRecorder {
- private static final int MAX_ASSET_IDS = 100;
-
- private final AuditService auditService;
-
- public SettingsAuditRecorder(AuditService auditService) {
- this.auditService = Objects.requireNonNull(auditService);
- }
-
- public void exportDownloaded(String actor, AuditOutcome outcome, ExportConfiguration configuration) {
- auditService.record(StandardAuditEvents.EXPORT_DOWNLOAD, outcome, actor, null,
- transferDetails(configuration));
- }
-
- public void imported(String actor, AuditOutcome outcome, AssetExportConfiguration configuration) {
- auditService.record(StandardAuditEvents.IMPORT_EXECUTE, outcome, actor, null,
- transferDetails(configuration));
- }
-
- public void exportProviderCreated(String actor, ExportProviderSettings settings) {
- auditService.record(StandardAuditEvents.EXPORT_PROVIDER_CREATE, AuditOutcome.SUCCEEDED, actor,
- settings.getProviderId(), providerDetails(settings, List.of()));
- }
-
- public void exportProviderUpdated(String actor, ExportProviderSettings before, ExportProviderSettings after) {
- auditService.record(StandardAuditEvents.EXPORT_PROVIDER_UPDATE, AuditOutcome.SUCCEEDED, actor,
- after.getProviderId(), providerDetails(after, changedProviderFields(before, after)));
- }
-
- public void exportProviderDeleted(String actor, ExportProviderSettings settings) {
- auditService.record(StandardAuditEvents.EXPORT_PROVIDER_DELETE, AuditOutcome.SUCCEEDED, actor,
- settings.getProviderId(), providerDetails(settings, List.of()));
- }
-
- public void fileUploaded(String actor, FileMetadata file) {
- auditService.record(StandardAuditEvents.FILE_UPLOAD, AuditOutcome.SUCCEEDED, actor, file.getFileId(),
- new FileAuditDetails(file.getFiletype()));
- }
-
- public void fileUploadFailed(String actor) {
- auditService.record(StandardAuditEvents.FILE_UPLOAD, AuditOutcome.FAILED, actor, null, null);
- }
-
- public void fileDeleted(String actor, String fileId) {
- auditService.record(StandardAuditEvents.FILE_DELETE, AuditOutcome.SUCCEEDED, actor, fileId, null);
- }
-
- public void fileDeleteFailed(String actor, String fileId) {
- auditService.record(StandardAuditEvents.FILE_DELETE, AuditOutcome.FAILED, actor, fileId, null);
- }
-
- public void mailConfigurationUpdated(String actor, EmailConfig before, EmailConfig after) {
- auditService.record(StandardAuditEvents.MAIL_CONFIGURATION_UPDATE, AuditOutcome.SUCCEEDED, actor, null,
- new MailAuditDetails(changedMailFields(before, after)));
- }
-
- public void mailTemplateUpdated(String actor) {
- auditService.record(StandardAuditEvents.MAIL_TEMPLATE_UPDATE, AuditOutcome.SUCCEEDED, actor, null,
- new MailAuditDetails(List.of("template")));
- }
-
- private AssetTransferDetails transferDetails(List<String> assetIds,
- boolean overwriteExistingDocuments,
- boolean overrideBrokerSettings) {
- var allAssetIds = assetIds == null ? List.<String>of() : assetIds.stream()
- .filter(Objects::nonNull)
- .filter(id -> !id.isBlank())
- .toList();
- return new AssetTransferDetails(allAssetIds.stream().limit(MAX_ASSET_IDS).toList(), allAssetIds.size(),
- overwriteExistingDocuments, overrideBrokerSettings);
- }
-
- private AssetTransferDetails transferDetails(ExportConfiguration configuration) {
- if (configuration == null || configuration.getAssetExportConfiguration() == null) {
- return transferDetails(List.of(), false, false);
- }
- return transferDetails(configuration.getAssetExportConfiguration());
- }
-
- private AssetTransferDetails transferDetails(AssetExportConfiguration configuration) {
- return configuration == null ? transferDetails(List.of(), false, false)
- : transferDetails(List.of(configuration));
- }
-
- private AssetTransferDetails transferDetails(List<AssetExportConfiguration> configurations) {
- var validConfigurations = configurations == null ? List.<AssetExportConfiguration>of() : configurations.stream()
- .filter(Objects::nonNull)
- .toList();
- var assetIds = validConfigurations.stream().map(AssetExportConfiguration::getAssetId).toList();
- boolean overwriteExistingDocuments = validConfigurations.stream()
- .anyMatch(AssetExportConfiguration::isOverwriteExistingDocuments);
- boolean overrideBrokerSettings = validConfigurations.stream()
- .anyMatch(AssetExportConfiguration::isOverrideBrokerSettings);
- return transferDetails(assetIds, overwriteExistingDocuments, overrideBrokerSettings);
- }
-
- private ExportProviderAuditDetails providerDetails(ExportProviderSettings settings, List<String> changedFields) {
- var providerType = settings.getProviderType() == null ? null : settings.getProviderType().name();
- return new ExportProviderAuditDetails(providerType, changedFields);
- }
-
- private List<String> changedProviderFields(ExportProviderSettings before, ExportProviderSettings after) {
- var changes = new ArrayList<String>();
- addIfChanged(changes, "providerType", before.getProviderType(), after.getProviderType());
- addIfChanged(changes, "accessKey", before.getAccessKey(), after.getAccessKey());
- addIfChanged(changes, "secretKey", before.getSecretKey(), after.getSecretKey());
- addIfChanged(changes, "bucketName", before.getBucketName(), after.getBucketName());
- addIfChanged(changes, "endPoint", before.getEndPoint(), after.getEndPoint());
- addIfChanged(changes, "awsRegion", before.getAwsRegion(), after.getAwsRegion());
- return List.copyOf(changes);
- }
-
- private List<String> changedMailFields(EmailConfig before, EmailConfig after) {
- if (before == null || after == null) {
- return List.of("configuration");
- }
- var changes = new ArrayList<String>();
- addIfChanged(changes, "emailConfigured", before.isEmailConfigured(), after.isEmailConfigured());
- addIfChanged(changes, "transportStrategy", before.getTransportStrategy(), after.getTransportStrategy());
- addIfChanged(changes, "smtpServerHost", before.getSmtpServerHost(), after.getSmtpServerHost());
- addIfChanged(changes, "smtpServerPort", before.getSmtpServerPort(), after.getSmtpServerPort());
- addIfChanged(changes, "usesAuthentication", before.isUsesAuthentication(), after.isUsesAuthentication());
- addIfChanged(changes, "smtpUsername", before.getSmtpUsername(), after.getSmtpUsername());
- addIfChanged(changes, "smtpPassword", before.getSmtpPassword(), after.getSmtpPassword());
- addIfChanged(changes, "senderAddress", before.getSenderAddress(), after.getSenderAddress());
- addIfChanged(changes, "senderName", before.getSenderName(), after.getSenderName());
- addIfChanged(changes, "usesProxy", before.isUsesProxy(), after.isUsesProxy());
- addIfChanged(changes, "proxyHost", before.getProxyHost(), after.getProxyHost());
- addIfChanged(changes, "proxyPort", before.getProxyPort(), after.getProxyPort());
- addIfChanged(changes, "usesProxyAuthentication", before.isUsesProxyAuthentication(),
- after.isUsesProxyAuthentication());
- addIfChanged(changes, "proxyUser", before.getProxyUser(), after.getProxyUser());
- addIfChanged(changes, "proxyPassword", before.getProxyPassword(), after.getProxyPassword());
- addIfChanged(changes, "testRecipientAddress", before.getTestRecipientAddress(), after.getTestRecipientAddress());
- return List.copyOf(changes);
- }
-
- private void addIfChanged(List<String> changes, String field, Object before, Object after) {
- if (!Objects.equals(before, after)) {
- changes.add(field);
- }
- }
-}
diff --git a/streampipes-audit-events/src/test/java/org/apache/streampipes/audit/events/security/SecurityAuditRecorderTest.java b/streampipes-audit-events/src/test/java/org/apache/streampipes/audit/events/security/SecurityAuditRecorderTest.java
deleted file mode 100644
index f00fbab1b0..0000000000
--- a/streampipes-audit-events/src/test/java/org/apache/streampipes/audit/events/security/SecurityAuditRecorderTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.security;
-
-import org.apache.streampipes.audit.api.AuditDetails;
-import org.apache.streampipes.audit.api.AuditEventDefinition;
-import org.apache.streampipes.audit.api.AuditOutcome;
-import org.apache.streampipes.audit.api.AuditService;
-import org.apache.streampipes.audit.events.StandardAuditEvents;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class SecurityAuditRecorderTest {
-
- @Test
- void recordsChangedGroupFieldsWithoutSecurityAssignments() {
- var auditService = new CapturingAuditService();
- var recorder = new SecurityAuditRecorder(auditService);
- recorder.groupUpdated("admin-1", "group-1", "Old operators", "New operators",
- Set.of("ROLE_USER"), Set.of("ROLE_ADMIN"), Set.of("old-id"), Set.of("new-id"));
-
- var call = auditService.calls.getFirst();
- var details = (GroupAuditDetails) call.details();
- assertEquals(StandardAuditEvents.SECURITY_GROUP_UPDATE, call.definition());
- assertEquals(AuditOutcome.SUCCEEDED, call.outcome());
- assertEquals(List.of("groupName", "roles", "alternateIds"), details.changedFields());
- assertFalse(details.toString().contains("ROLE_ADMIN"));
- assertFalse(details.toString().contains("new-id"));
- }
-
- @Test
- void registersGroupLifecycleEventTypes() {
- var eventTypes = new StandardAuditEvents().eventTypes();
-
- assertTrue(eventTypes.containsAll(List.of(
- StandardAuditEvents.SECURITY_GROUP_CREATE,
- StandardAuditEvents.SECURITY_GROUP_UPDATE,
- StandardAuditEvents.SECURITY_GROUP_DELETE)));
- }
-
- private record AuditCall(AuditEventDefinition<?> definition, AuditOutcome outcome, AuditDetails details) {
- }
-
- private static final class CapturingAuditService implements AuditService {
- private final List<AuditCall> calls = new ArrayList<>();
-
- @Override
- public <T extends AuditDetails> void record(AuditEventDefinition<T> definition,
- AuditOutcome outcome,
- String actor,
- String resourceId,
- T details) {
- calls.add(new AuditCall(definition, outcome, details));
- }
- }
-}
diff --git a/streampipes-audit-events/src/test/java/org/apache/streampipes/audit/events/settings/SettingsAuditRecorderTest.java b/streampipes-audit-events/src/test/java/org/apache/streampipes/audit/events/settings/SettingsAuditRecorderTest.java
deleted file mode 100644
index 049f12e6d9..0000000000
--- a/streampipes-audit-events/src/test/java/org/apache/streampipes/audit/events/settings/SettingsAuditRecorderTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.audit.events.settings;
-
-import org.apache.streampipes.audit.api.AuditDetails;
-import org.apache.streampipes.audit.api.AuditEventDefinition;
-import org.apache.streampipes.audit.api.AuditOutcome;
-import org.apache.streampipes.audit.api.AuditService;
-import org.apache.streampipes.audit.events.StandardAuditEvents;
-import org.apache.streampipes.model.configuration.EmailConfig;
-import org.apache.streampipes.model.configuration.ExportProviderSettings;
-import org.apache.streampipes.model.configuration.ProviderType;
-import org.apache.streampipes.model.export.AssetExportConfiguration;
-import org.apache.streampipes.model.export.ExportConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class SettingsAuditRecorderTest {
-
- @Test
- void recordsBoundedAssetScopeForExportDownload() {
- var auditService = new CapturingAuditService();
- var recorder = new SettingsAuditRecorder(auditService);
- var assetConfigurations = new ArrayList<AssetExportConfiguration>();
- for (int i = 0; i < 101; i++) {
- var assetConfiguration = new AssetExportConfiguration();
- assetConfiguration.setAssetId("asset-" + i);
- assetConfigurations.add(assetConfiguration);
- }
- var exportConfiguration = new ExportConfiguration();
- exportConfiguration.setAssetExportConfiguration(assetConfigurations);
-
- recorder.exportDownloaded("user-1", AuditOutcome.REQUESTED, exportConfiguration);
-
- var call = auditService.calls.getFirst();
- var details = (AssetTransferDetails) call.details();
- assertEquals(StandardAuditEvents.EXPORT_DOWNLOAD, call.definition());
- assertEquals(AuditOutcome.REQUESTED, call.outcome());
- assertEquals(101, details.assetCount());
- assertEquals(100, details.assetIds().size());
- }
-
- @Test
- void recordsMailConfigurationChangesWithoutConfigurationValues() {
- var auditService = new CapturingAuditService();
- var recorder = new SettingsAuditRecorder(auditService);
- var before = new EmailConfig();
- before.setSmtpServerHost("old.example.org");
- before.setSmtpPassword("old-password");
- var after = new EmailConfig();
- after.setSmtpServerHost("new.example.org");
- after.setSmtpPassword("new-password");
-
- recorder.mailConfigurationUpdated("user-1", before, after);
-
- var call = auditService.calls.getFirst();
- var details = (MailAuditDetails) call.details();
- assertEquals(StandardAuditEvents.MAIL_CONFIGURATION_UPDATE, call.definition());
- assertEquals(List.of("smtpServerHost", "smtpPassword"), details.changedFields());
- assertFalse(details.toString().contains("old-password"));
- assertFalse(details.toString().contains("new-password"));
- }
-
- @Test
- void recordsProviderChangesWithoutProviderCredentials() {
- var auditService = new CapturingAuditService();
- var recorder = new SettingsAuditRecorder(auditService);
- var before = provider("old-access-key", "old-secret-key");
- var after = provider("new-access-key", "new-secret-key");
-
- recorder.exportProviderUpdated("user-1", before, after);
-
- var call = auditService.calls.getFirst();
- var details = (ExportProviderAuditDetails) call.details();
- assertEquals(StandardAuditEvents.EXPORT_PROVIDER_UPDATE, call.definition());
- assertEquals(List.of("accessKey", "secretKey"), details.changedFields());
- assertFalse(details.toString().contains("old-access-key"));
- assertFalse(details.toString().contains("new-secret-key"));
- }
-
- @Test
- void registersAllSettingsEventTypes() {
- var eventTypes = new StandardAuditEvents().eventTypes();
-
- assertTrue(eventTypes.containsAll(List.of(
- StandardAuditEvents.EXPORT_DOWNLOAD,
- StandardAuditEvents.IMPORT_EXECUTE,
- StandardAuditEvents.EXPORT_PROVIDER_CREATE,
- StandardAuditEvents.EXPORT_PROVIDER_UPDATE,
- StandardAuditEvents.EXPORT_PROVIDER_DELETE,
- StandardAuditEvents.FILE_UPLOAD,
- StandardAuditEvents.FILE_DELETE,
- StandardAuditEvents.MAIL_CONFIGURATION_UPDATE,
- StandardAuditEvents.MAIL_TEMPLATE_UPDATE)));
- }
-
- private ExportProviderSettings provider(String accessKey, String secretKey) {
- return new ExportProviderSettings(ProviderType.S3, "provider-1", accessKey, secretKey,
- "bucket", "https://storage.example.org", "eu-central-1");
- }
-
- private record AuditCall(AuditEventDefinition<?> definition, AuditOutcome outcome, AuditDetails details) {
- }
-
- private static final class CapturingAuditService implements AuditService {
- private final List<AuditCall> calls = new ArrayList<>();
-
- @Override
- public <T extends AuditDetails> void record(AuditEventDefinition<T> definition,
- AuditOutcome outcome,
- String actor,
- String resourceId,
- T details) {
- calls.add(new AuditCall(definition, outcome, details));
- }
- }
-}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/FileResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/FileResource.java
index ba5ef19193..b80cd36cce 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/FileResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/FileResource.java
@@ -17,12 +17,10 @@
*/
package org.apache.streampipes.rest.impl;
-import org.apache.streampipes.audit.events.settings.SettingsAuditRecorder;
import org.apache.streampipes.manager.file.FileManager;
import org.apache.streampipes.model.file.FileMetadata;
import org.apache.streampipes.model.message.Notifications;
import org.apache.streampipes.resource.management.ResourceDeletionManager;
-import org.apache.streampipes.resource.management.SpResourceManager;
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.rest.shared.exception.SpMessageException;
@@ -61,15 +59,12 @@ public class FileResource extends AbstractAuthGuardedRestResource {
private final FileManager fileManager;
private final ResourceDeletionManager resourceDeletionManager;
- private final SettingsAuditRecorder audit;
public FileResource(ISpCoreConfigurationStorage coreConfigurationStorage,
IFileMetadataStorage fileMetadataStorage,
- ResourceDeletionManager resourceDeletionManager,
- SpResourceManager resourceManager) {
+ ResourceDeletionManager resourceDeletionManager) {
this.fileManager = new FileManager(coreConfigurationStorage, fileMetadataStorage);
this.resourceDeletionManager = resourceDeletionManager;
- this.audit = new SettingsAuditRecorder(resourceManager.getAuditService());
}
@PostMapping(
@@ -84,10 +79,8 @@ public class FileResource extends AbstractAuthGuardedRestResource {
fileDetail.getOriginalFilename(),
fileDetail.getInputStream()
);
- audit.fileUploaded(getAuthenticatedUserSid(), metadata);
return ok(metadata);
} catch (IllegalArgumentException e) {
- audit.fileUploadFailed(getAuthenticatedUserSid());
return badRequest(Notifications.error(
String.format(
"This file type is not supported. Allowed file types are %s.",
@@ -95,7 +88,6 @@ public class FileResource extends AbstractAuthGuardedRestResource {
)
));
} catch (Exception e) {
- audit.fileUploadFailed(getAuthenticatedUserSid());
return fail();
}
}
@@ -103,14 +95,8 @@ public class FileResource extends AbstractAuthGuardedRestResource {
@DeleteMapping(path = "{fileId}")
@PreAuthorize(AuthConstants.HAS_WRITE_FILE_PRIVILEGE)
public ResponseEntity<Void> deleteFile(@PathVariable("fileId") String fileId) {
- try {
- fileManager.deleteFile(fileId, resourceDeletionManager);
- audit.fileDeleted(getAuthenticatedUserSid(), fileId);
- return ok();
- } catch (RuntimeException e) {
- audit.fileDeleteFailed(getAuthenticatedUserSid(), fileId);
- throw e;
- }
+ fileManager.deleteFile(fileId, resourceDeletionManager);
+ return ok();
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataExportResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataExportResource.java
index 057a7897cb..b5ee2446ec 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataExportResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataExportResource.java
@@ -18,8 +18,6 @@
package org.apache.streampipes.rest.impl.admin;
-import org.apache.streampipes.audit.api.AuditOutcome;
-import org.apache.streampipes.audit.events.settings.SettingsAuditRecorder;
import org.apache.streampipes.export.ExportManager;
import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestManager;
import org.apache.streampipes.manager.pipeline.PipelineManager;
@@ -47,14 +45,12 @@ public class DataExportResource extends AbstractAuthGuardedRestResource {
private final ExtensionServiceRequestManager extensionServiceRequestManager;
private final PipelineManager pipelineManager;
private final SpResourceManager resourceManager;
- private final SettingsAuditRecorder audit;
public DataExportResource(ExtensionServiceRequestManager extensionServiceRequestManager,
SpResourceManager resourceManager) {
this.extensionServiceRequestManager = extensionServiceRequestManager;
this.pipelineManager = new PipelineManager(resourceManager);
this.resourceManager = resourceManager;
- this.audit = new SettingsAuditRecorder(resourceManager.getAuditService());
}
@@ -73,21 +69,13 @@ public class DataExportResource extends AbstractAuthGuardedRestResource {
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ResponseEntity<byte[]> download(@RequestBody ExportConfiguration exportConfiguration) throws IOException {
- var actor = getAuthenticatedUserSid();
- audit.exportDownloaded(actor, AuditOutcome.REQUESTED, exportConfiguration);
- try {
- var applicationPackage = ExportManager
- .getExportPackage(
- exportConfiguration,
- extensionServiceRequestManager,
- resourceManager,
- pipelineManager);
- audit.exportDownloaded(actor, AuditOutcome.SUCCEEDED, exportConfiguration);
- return ok(applicationPackage);
- } catch (IOException | RuntimeException e) {
- audit.exportDownloaded(actor, AuditOutcome.FAILED, exportConfiguration);
- throw e;
- }
+ var applicationPackage = ExportManager
+ .getExportPackage(
+ exportConfiguration,
+ extensionServiceRequestManager,
+ resourceManager,
+ pipelineManager);
+ return ok(applicationPackage);
}
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataImportResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataImportResource.java
index db877435f3..efe5f0f8aa 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataImportResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/DataImportResource.java
@@ -18,8 +18,6 @@
package org.apache.streampipes.rest.impl.admin;
-import org.apache.streampipes.audit.api.AuditOutcome;
-import org.apache.streampipes.audit.events.settings.SettingsAuditRecorder;
import org.apache.streampipes.export.ImportManager;
import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestManager;
import org.apache.streampipes.manager.pipeline.PipelineManager;
@@ -50,14 +48,12 @@ public class DataImportResource extends AbstractAuthGuardedRestResource {
private final ExtensionServiceRequestManager extensionServiceRequestManager;
private final PipelineManager pipelineManager;
private final SpResourceManager resourceManager;
- private final SettingsAuditRecorder audit;
public DataImportResource(ExtensionServiceRequestManager extensionServiceRequestManager,
SpResourceManager resourceManager) {
this.extensionServiceRequestManager = extensionServiceRequestManager;
this.pipelineManager = new PipelineManager(resourceManager);
this.resourceManager = resourceManager;
- this.audit = new SettingsAuditRecorder(resourceManager.getAuditService());
}
@PostMapping(
@@ -80,8 +76,6 @@ public class DataImportResource extends AbstractAuthGuardedRestResource {
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void> importData(@RequestPart("file_upload") MultipartFile fileDetail,
@RequestPart("configuration") AssetExportConfiguration exportConfiguration) {
- var actor = getAuthenticatedUserSid();
- audit.imported(actor, AuditOutcome.REQUESTED, exportConfiguration);
try {
ImportManager.performImport(
fileDetail.getInputStream(),
@@ -91,15 +85,10 @@ public class DataImportResource extends AbstractAuthGuardedRestResource {
resourceManager,
pipelineManager
);
- audit.imported(actor, AuditOutcome.SUCCEEDED, exportConfiguration);
return ok();
} catch (IOException e) {
- audit.imported(actor, AuditOutcome.FAILED, exportConfiguration);
LOG.error("An error occurred while importing resources", e);
return fail();
- } catch (RuntimeException e) {
- audit.imported(actor, AuditOutcome.FAILED, exportConfiguration);
- throw e;
}
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/EmailConfigurationResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/EmailConfigurationResource.java
index 2fd0c8684e..263307f255 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/EmailConfigurationResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/EmailConfigurationResource.java
@@ -17,12 +17,10 @@
*/
package org.apache.streampipes.rest.impl.admin;
-import org.apache.streampipes.audit.events.settings.SettingsAuditRecorder;
import org.apache.streampipes.mail.MailTester;
import org.apache.streampipes.model.configuration.EmailConfig;
import org.apache.streampipes.model.configuration.EmailTemplateConfig;
import org.apache.streampipes.model.message.Notifications;
-import org.apache.streampipes.resource.management.SpResourceManager;
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.rest.shared.exception.SpMessageException;
@@ -59,12 +57,9 @@ public class EmailConfigurationResource extends AbstractAuthGuardedRestResource
private static final Logger LOG = LoggerFactory.getLogger(EmailConfigurationResource.class);
private final ISpCoreConfigurationStorage configurationStorage;
- private final SettingsAuditRecorder audit;
- public EmailConfigurationResource(ISpCoreConfigurationStorage coreConfigurationStorage,
- SpResourceManager resourceManager) {
+ public EmailConfigurationResource(ISpCoreConfigurationStorage coreConfigurationStorage) {
this.configurationStorage = coreConfigurationStorage;
- this.audit = new SettingsAuditRecorder(resourceManager.getAuditService());
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@@ -85,7 +80,6 @@ public class EmailConfigurationResource extends AbstractAuthGuardedRestResource
var config = configurationStorage.get();
config.setEmailTemplateConfig(templateConfig);
configurationStorage.updateElement(config);
- audit.mailTemplateUpdated(getAuthenticatedUserSid());
return ok();
}
@@ -103,10 +97,8 @@ public class EmailConfigurationResource extends AbstractAuthGuardedRestResource
config.setSmtpPassEncrypted(true);
}
var cfg = configurationStorage.get();
- var oldConfig = cfg.getEmailConfig();
cfg.setEmailConfig(config);
configurationStorage.updateElement(cfg);
- audit.mailConfigurationUpdated(getAuthenticatedUserSid(), oldConfig, config);
return ok();
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExportProviderConfigurationResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExportProviderConfigurationResource.java
index 37a62ccd16..84e5459fd9 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExportProviderConfigurationResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExportProviderConfigurationResource.java
@@ -17,11 +17,9 @@
*/
package org.apache.streampipes.rest.impl.admin;
-import org.apache.streampipes.audit.events.settings.SettingsAuditRecorder;
import org.apache.streampipes.dataexplorer.export.objectstorage.TestExportProviderConnection;
import org.apache.streampipes.model.configuration.ExportProviderSettings;
import org.apache.streampipes.model.monitoring.SpLogMessage;
-import org.apache.streampipes.resource.management.SpResourceManager;
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.storage.api.system.ISpCoreConfigurationStorage;
@@ -49,12 +47,9 @@ import java.util.stream.Collectors;
public class ExportProviderConfigurationResource extends AbstractAuthGuardedRestResource {
private final ISpCoreConfigurationStorage configurationStorage;
- private final SettingsAuditRecorder audit;
- public ExportProviderConfigurationResource(ISpCoreConfigurationStorage configurationStorage,
- SpResourceManager resourceManager) {
+ public ExportProviderConfigurationResource(ISpCoreConfigurationStorage configurationStorage) {
this.configurationStorage = configurationStorage;
- this.audit = new SettingsAuditRecorder(resourceManager.getAuditService());
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@@ -85,7 +80,10 @@ public class ExportProviderConfigurationResource extends AbstractAuthGuardedRest
if (exportProviderSetting.isPresent()) {
try {
Map<String, Object> response = TestExportProviderConnection.connectionTest(exportProviderSetting.get());
- return ok(response);
+
+
+ return ok(response);
+
} catch (Exception e) {
return serverError(SpLogMessage.from(e));
}
@@ -111,10 +109,6 @@ public class ExportProviderConfigurationResource extends AbstractAuthGuardedRest
providerSettings = new ArrayList<>();
}
- var existingSetting = providerSettings.stream()
- .filter(existing -> existing != null && existing.getProviderId().equals(config.getProviderId()))
- .findFirst();
-
List<ExportProviderSettings> providerSettingsWithoutExisting = providerSettings.stream()
.filter(existing -> existing != null && !existing.getProviderId().equals(config.getProviderId()))
.collect(Collectors.toList());
@@ -123,11 +117,6 @@ public class ExportProviderConfigurationResource extends AbstractAuthGuardedRest
cfg.setExportProviderSettings(providerSettingsWithoutExisting);
configurationStorage.updateElement(cfg);
- if (existingSetting.isPresent()) {
- audit.exportProviderUpdated(getAuthenticatedUserSid(), existingSetting.get(), config);
- } else {
- audit.exportProviderCreated(getAuthenticatedUserSid(), config);
- }
return ok();
}
@@ -138,10 +127,6 @@ public class ExportProviderConfigurationResource extends AbstractAuthGuardedRest
List<ExportProviderSettings> allProviders = configurationStorage.get().getExportProviderSettings();
- var deletedProvider = allProviders.stream()
- .filter(provider -> provider.getProviderId().equals(providerId))
- .findFirst();
-
List<ExportProviderSettings> filteredProviders = allProviders.stream()
.filter(provider -> !provider.getProviderId().equals(providerId))
.collect(Collectors.toList());
@@ -149,7 +134,6 @@ public class ExportProviderConfigurationResource extends AbstractAuthGuardedRest
var cfg = configurationStorage.get();
cfg.setExportProviderSettings(filteredProviders);
configurationStorage.updateElement(cfg);
- deletedProvider.ifPresent(provider -> audit.exportProviderDeleted(getAuthenticatedUserSid(), provider));
return ok();
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/UserGroupResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/UserGroupResource.java
index fd9d8544e1..8cce352be0 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/UserGroupResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/UserGroupResource.java
@@ -17,10 +17,8 @@
*/
package org.apache.streampipes.rest.impl.admin;
-import org.apache.streampipes.audit.events.security.SecurityAuditRecorder;
import org.apache.streampipes.model.client.user.Group;
import org.apache.streampipes.model.message.Notifications;
-import org.apache.streampipes.resource.management.SpResourceManager;
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.rest.shared.exception.SpMessageException;
@@ -48,14 +46,11 @@ public class UserGroupResource extends AbstractAuthGuardedRestResource {
private final IUserGroupStorage userGroupStorage;
private final IUserStorage userStorage;
- private final SecurityAuditRecorder audit;
public UserGroupResource(IUserGroupStorage userGroupStorage,
- IUserStorage userStorage,
- SpResourceManager resourceManager) {
+ IUserStorage userStorage) {
this.userGroupStorage = userGroupStorage;
this.userStorage = userStorage;
- this.audit = new SecurityAuditRecorder(resourceManager.getAuditService());
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@@ -67,7 +62,6 @@ public class UserGroupResource extends AbstractAuthGuardedRestResource {
@PreAuthorize(AuthConstants.IS_ADMIN_ROLE)
public ResponseEntity<Void> addUserGroup(@RequestBody Group group) {
userGroupStorage.persist(group);
- audit.groupCreated(getAuthenticatedUserSid(), group.getGroupId());
return ok();
}
@@ -80,13 +74,7 @@ public class UserGroupResource extends AbstractAuthGuardedRestResource {
HttpStatus.BAD_REQUEST,
Notifications.error("Wrong group id provided"));
} else {
- var existingGroup = userGroupStorage.getElementById(groupId);
- var updatedGroup = userGroupStorage.updateElement(group);
- audit.groupUpdated(getAuthenticatedUserSid(), updatedGroup.getGroupId(),
- existingGroup == null ? null : existingGroup.getGroupName(), updatedGroup.getGroupName(),
- existingGroup == null ? null : existingGroup.getRoles(), updatedGroup.getRoles(),
- existingGroup == null ? null : existingGroup.getAlternateIds(), updatedGroup.getAlternateIds());
- return ok(updatedGroup);
+ return ok(userGroupStorage.updateElement(group));
}
}
@@ -104,7 +92,6 @@ public class UserGroupResource extends AbstractAuthGuardedRestResource {
userStorage.updateUser(user);
}
});
- audit.groupDeleted(getAuthenticatedUserSid(), group.getGroupId());
return ok();
} else {
return badRequest();