From 9a6f9215df1426a230137e829e14a1139533d66b Mon Sep 17 00:00:00 2001 From: egernug Date: Thu, 2 Nov 2023 11:28:51 +0000 Subject: Sonar Fixes Fixing deprecations in WebSecurityConfig and DmiConfiguration Issue-ID: CPS-89 Signed-off-by: egernug Change-Id: I4c6d10ff7ef174db2a6e93e5e6e4b2b0b97b12f6 --- .../org/onap/cps/ncmp/dmi/config/DmiConfiguration.java | 1 - .../org/onap/cps/ncmp/dmi/config/WebSecurityConfig.java | 15 +++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java b/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java index 18b22dbe..83ef6f89 100644 --- a/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java +++ b/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java @@ -81,7 +81,6 @@ public class DmiConfiguration { private void setCustomRequestFactoryToSupportPatch(final RestTemplate restTemplate) { final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); requestFactory.setConnectTimeout(TIMEOUT); - requestFactory.setReadTimeout(TIMEOUT); restTemplate.setRequestFactory(requestFactory); } } \ No newline at end of file diff --git a/src/main/java/org/onap/cps/ncmp/dmi/config/WebSecurityConfig.java b/src/main/java/org/onap/cps/ncmp/dmi/config/WebSecurityConfig.java index 11d2ae53..ac92cb4a 100644 --- a/src/main/java/org/onap/cps/ncmp/dmi/config/WebSecurityConfig.java +++ b/src/main/java/org/onap/cps/ncmp/dmi/config/WebSecurityConfig.java @@ -20,14 +20,13 @@ package org.onap.cps.ncmp.dmi.config; -import static org.springframework.security.config.Customizer.withDefaults; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.provisioning.InMemoryUserDetailsManager; @@ -79,12 +78,12 @@ public class WebSecurityConfig { @SuppressWarnings("squid:S4502") public SecurityFilterChain filterChain(final HttpSecurity http) throws Exception { http - .httpBasic(withDefaults()) - .authorizeRequests() - .requestMatchers(permitUris).permitAll() - .anyRequest().authenticated() - .and() - .csrf((csrf) -> csrf.disable()); + .httpBasic(httpBasicCustomizer -> {}) + .authorizeHttpRequests(authorizeHttpRequestsCustomizer -> { + authorizeHttpRequestsCustomizer.requestMatchers(permitUris).permitAll(); + authorizeHttpRequestsCustomizer.anyRequest().authenticated(); + }) + .csrf(AbstractHttpConfigurer::disable); return http.build(); } -- cgit 1.2.3-korg