From 8152f873dfdf2429866ffc82bfcd35141564e7c8 Mon Sep 17 00:00:00 2001 From: Istvan Zoltan Nagy Date: Mon, 5 Feb 2024 16:46:29 +0100 Subject: [PATCH] Extend DTR APIs for Access management - Code review fixes #1 --- .../ShellAccessHandlerConfiguration.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/org/eclipse/tractusx/semantics/registry/service/ShellAccessHandlerConfiguration.java b/backend/src/main/java/org/eclipse/tractusx/semantics/registry/service/ShellAccessHandlerConfiguration.java index c3a8a444..6e8728b2 100644 --- a/backend/src/main/java/org/eclipse/tractusx/semantics/registry/service/ShellAccessHandlerConfiguration.java +++ b/backend/src/main/java/org/eclipse/tractusx/semantics/registry/service/ShellAccessHandlerConfiguration.java @@ -23,24 +23,22 @@ import org.eclipse.tractusx.semantics.RegistryProperties; import org.eclipse.tractusx.semantics.accesscontrol.api.AccessControlRuleService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class ShellAccessHandlerConfiguration { - @ConditionalOnProperty(prefix = "registry", name = "use-granular-access-control", matchIfMissing = true, havingValue = "false") - @Bean - @Autowired - public ShellAccessHandler createDefaultShellAccessHandler(final RegistryProperties registryProperties) { - return new DefaultShellAccessHandler(registryProperties); - } - - @ConditionalOnProperty(prefix = "registry", name = "use-granular-access-control", havingValue = "true") - @Bean - @Autowired - public ShellAccessHandler createGranularShellAccessHandler(final RegistryProperties registryProperties, final AccessControlRuleService accessControlRuleService) { - return new GranularShellAccessHandler(registryProperties, accessControlRuleService); - } + @Bean + @Autowired + public ShellAccessHandler createGranularShellAccessHandler( + final RegistryProperties registryProperties, final AccessControlRuleService accessControlRuleService ) { + final ShellAccessHandler result; + if ( Boolean.TRUE.equals( registryProperties.getUseGranularAccessControl() ) ) { + result = new GranularShellAccessHandler( registryProperties, accessControlRuleService ); + } else { + result = new DefaultShellAccessHandler( registryProperties ); + } + return result; + } }