aboutsummaryrefslogtreecommitdiffstats
path: root/common/src
diff options
context:
space:
mode:
authorSreeja Gattagouni <SG00744975@techmahindra.com>2024-06-10 13:14:36 +0530
committerSANKET KS <sx00562924@techmahindra.com>2024-07-08 06:04:42 +0000
commit989d7f3d6ae740e30480bfc7d49acfbaf014d393 (patch)
tree0604e03d4e6910f39d66f7240eb6b448e4d05b4c /common/src
parent7100db88beb76d9f23accaad9d0ccd91f7633304 (diff)
Upgrade SO to Java_17
-Removal of aff and logging-filter-base dependencies. -CI build java17 branch-jdk17 version:https://gerrit.onap.org/r/c/ci-management/+/138252 Issue-ID: SO-4125 Change-ID: I58f07f888a814b999f92f8d89909b0666d0b9699 Signed-off-by: Sreeja Gattagouni <SG00744975@techmahindra.com>
Diffstat (limited to 'common/src')
-rw-r--r--common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java1
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java2
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java1
-rw-r--r--common/src/main/java/org/onap/so/client/AddCacheHeaders.java8
-rw-r--r--common/src/main/java/org/onap/so/client/HttpClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/HttpClientFactory.java2
-rw-r--r--common/src/main/java/org/onap/so/client/PreconditionFailedException.java4
-rw-r--r--common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java13
-rw-r--r--common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java4
-rw-r--r--common/src/main/java/org/onap/so/client/RestClient.java24
-rw-r--r--common/src/main/java/org/onap/so/client/RestClientSSL.java4
-rw-r--r--common/src/main/java/org/onap/so/client/RestProperties.java4
-rw-r--r--common/src/main/java/org/onap/so/client/RestRequest.java8
-rw-r--r--common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java4
-rw-r--r--common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java2
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMRestClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java2
-rw-r--r--common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java5
-rw-r--r--common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java4
-rw-r--r--common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java14
-rw-r--r--common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java60
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java18
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java14
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java4
-rw-r--r--common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java1
-rw-r--r--common/src/main/java/org/onap/so/security/BaseWebSecurityConfigurerAdapter.java36
-rw-r--r--common/src/main/java/org/onap/so/security/CorsBasicHttpSecurityConfigurer.java15
-rw-r--r--common/src/main/java/org/onap/so/security/HttpHeaderForwarderHandlerInterceptor.java11
-rw-r--r--common/src/main/java/org/onap/so/security/HttpSecurityConfigurer.java3
-rw-r--r--common/src/main/java/org/onap/so/security/SecurityFilters.java41
-rw-r--r--common/src/main/java/org/onap/so/security/SoBasicHttpSecurityConfigurer.java10
-rw-r--r--common/src/main/java/org/onap/so/security/SoCadiFilter.java121
-rw-r--r--common/src/main/java/org/onap/so/security/SoNoAuthWebSecurityConfigurerAdapter.java12
-rw-r--r--common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java11
-rw-r--r--common/src/test/java/org/onap/so/client/HttpClientTest.java4
-rw-r--r--common/src/test/java/org/onap/so/client/RestClientTest.java14
-rw-r--r--common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java4
-rw-r--r--common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java4
-rw-r--r--common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java4
-rw-r--r--common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java10
-rw-r--r--common/src/test/java/org/onap/so/constants/DefaultsTest.java4
-rw-r--r--common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java16
-rw-r--r--common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java9
45 files changed, 211 insertions, 329 deletions
diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java
index 010e184618..46087320e9 100644
--- a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java
+++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java
@@ -4,7 +4,6 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.onap.appc.client.lcm.model.Action;
-import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf;
public class ApplicationControllerTaskRequest implements Serializable {
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java
index 9a25d6fea3..ec5409e634 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java
@@ -21,7 +21,7 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
-import javax.validation.constraints.NotNull;
+import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java
index d228d37976..38433bc218 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java
@@ -20,7 +20,6 @@
package org.onap.so.beans.nsmf.oof;
import lombok.Data;
-import org.onap.so.beans.nsmf.ServiceProfile;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
diff --git a/common/src/main/java/org/onap/so/client/AddCacheHeaders.java b/common/src/main/java/org/onap/so/client/AddCacheHeaders.java
index 1a41be1233..9ff662c8c4 100644
--- a/common/src/main/java/org/onap/so/client/AddCacheHeaders.java
+++ b/common/src/main/java/org/onap/so/client/AddCacheHeaders.java
@@ -1,12 +1,12 @@
package org.onap.so.client;
+import jakarta.ws.rs.client.ClientRequestContext;
+import jakarta.ws.rs.client.ClientResponseContext;
+import jakarta.ws.rs.client.ClientResponseFilter;
+import jakarta.ws.rs.ext.Provider;
import java.io.IOException;
import java.util.Collections;
import javax.annotation.Priority;
-import javax.ws.rs.client.ClientRequestContext;
-import javax.ws.rs.client.ClientResponseContext;
-import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.ext.Provider;
@Provider
@Priority(1)
diff --git a/common/src/main/java/org/onap/so/client/HttpClient.java b/common/src/main/java/org/onap/so/client/HttpClient.java
index 0420ab2373..4467f734fe 100644
--- a/common/src/main/java/org/onap/so/client/HttpClient.java
+++ b/common/src/main/java/org/onap/so/client/HttpClient.java
@@ -23,7 +23,7 @@ package org.onap.so.client;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.net.URL;
import java.util.Optional;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
import org.onap.logging.filter.base.ONAPComponentsList;
import org.slf4j.Logger;
diff --git a/common/src/main/java/org/onap/so/client/HttpClientFactory.java b/common/src/main/java/org/onap/so/client/HttpClientFactory.java
index 84a8bb9fb1..e3609f1812 100644
--- a/common/src/main/java/org/onap/so/client/HttpClientFactory.java
+++ b/common/src/main/java/org/onap/so/client/HttpClientFactory.java
@@ -20,7 +20,7 @@
package org.onap.so.client;
import java.net.URL;
-import javax.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.MediaType;
import org.onap.logging.filter.base.ONAPComponentsList;
public class HttpClientFactory {
diff --git a/common/src/main/java/org/onap/so/client/PreconditionFailedException.java b/common/src/main/java/org/onap/so/client/PreconditionFailedException.java
index 29f4c4d9b9..110f6e2f25 100644
--- a/common/src/main/java/org/onap/so/client/PreconditionFailedException.java
+++ b/common/src/main/java/org/onap/so/client/PreconditionFailedException.java
@@ -20,8 +20,8 @@
package org.onap.so.client;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.WebApplicationException;
+import jakarta.ws.rs.core.Response;
public class PreconditionFailedException extends WebApplicationException {
/**
diff --git a/common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java b/common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java
index 2517ebe2d5..5a27c4ab70 100644
--- a/common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java
+++ b/common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java
@@ -21,17 +21,8 @@
package org.onap.so.client;
import java.util.Optional;
-import javax.ws.rs.BadRequestException;
-import javax.ws.rs.ForbiddenException;
-import javax.ws.rs.InternalServerErrorException;
-import javax.ws.rs.NotAcceptableException;
-import javax.ws.rs.NotAllowedException;
-import javax.ws.rs.NotAuthorizedException;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.NotSupportedException;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.*;
+import jakarta.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java b/common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java
index 5927d4d99d..380ab44e49 100644
--- a/common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java
+++ b/common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java
@@ -20,9 +20,9 @@
package org.onap.so.client;
+import jakarta.annotation.Priority;
+import jakarta.ws.rs.ext.Provider;
import java.util.Optional;
-import javax.annotation.Priority;
-import javax.ws.rs.ext.Provider;
@Provider
@Priority(Integer.MIN_VALUE)
diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java
index 0df378db66..4f1c61f9cb 100644
--- a/common/src/main/java/org/onap/so/client/RestClient.java
+++ b/common/src/main/java/org/onap/so/client/RestClient.java
@@ -33,18 +33,13 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.ResponseProcessingException;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriBuilder;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Invocation.Builder;
+import jakarta.ws.rs.client.ResponseProcessingException;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.*;
import org.javatuples.Pair;
import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.filter.base.ONAPComponentsList;
@@ -54,7 +49,6 @@ import org.onap.so.logging.jaxrs.filter.SOMetricLogClientFilter;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import net.jodah.failsafe.Failsafe;
import net.jodah.failsafe.RetryPolicy;
@@ -327,14 +321,14 @@ public abstract class RestClient {
}
private <T> Optional<T> format(Response response, Class<T> resultClass) {
- if (this.props.mapNotFoundToEmpty() && response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
+ if (this.props.mapNotFoundToEmpty() && response.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) {
return Optional.empty();
}
return Optional.of(response.readEntity(resultClass));
}
private <T> Optional<T> format(Response response, GenericType<T> resultClass) {
- if (this.props.mapNotFoundToEmpty() && response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
+ if (this.props.mapNotFoundToEmpty() && response.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) {
return Optional.empty();
}
return Optional.of(response.readEntity(resultClass));
diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java
index c6252e4652..7c51e8fdb2 100644
--- a/common/src/main/java/org/onap/so/client/RestClientSSL.java
+++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java
@@ -20,13 +20,13 @@
package org.onap.so.client;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
import java.net.URI;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
import javax.net.ssl.SSLContext;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
public abstract class RestClientSSL extends RestClient {
diff --git a/common/src/main/java/org/onap/so/client/RestProperties.java b/common/src/main/java/org/onap/so/client/RestProperties.java
index d1cf77b047..b8ff88c1b7 100644
--- a/common/src/main/java/org/onap/so/client/RestProperties.java
+++ b/common/src/main/java/org/onap/so/client/RestProperties.java
@@ -22,8 +22,8 @@ package org.onap.so.client;
import java.net.MalformedURLException;
import java.net.URL;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
public interface RestProperties {
diff --git a/common/src/main/java/org/onap/so/client/RestRequest.java b/common/src/main/java/org/onap/so/client/RestRequest.java
index 0a1be758c9..6fec2c1842 100644
--- a/common/src/main/java/org/onap/so/client/RestRequest.java
+++ b/common/src/main/java/org/onap/so/client/RestRequest.java
@@ -23,10 +23,10 @@
package org.onap.so.client;
import java.util.Optional;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.HttpMethod;
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.jodah.failsafe.function.CheckedSupplier;
diff --git a/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java
index 3bac3dc210..6f4a543a04 100644
--- a/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java
+++ b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java
@@ -23,7 +23,7 @@ package org.onap.so.client.adapter.rest;
import java.net.URI;
import java.security.GeneralSecurityException;
import java.util.Optional;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.apache.commons.codec.binary.Base64;
import org.javatuples.Pair;
import org.onap.logging.filter.base.ONAPComponents;
diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java b/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java
index 85417e09d4..8491237a46 100644
--- a/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java
+++ b/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java
@@ -22,7 +22,7 @@ package org.onap.so.client.dmaap.rest;
import java.net.URL;
import java.util.UUID;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
import org.onap.logging.filter.base.ONAPComponents;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java b/common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java
index a3ebf3c56c..d3fa3631e5 100644
--- a/common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java
+++ b/common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java
@@ -25,8 +25,8 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.UriBuilder;
import org.onap.so.client.RestClient;
import org.onap.so.client.dmaap.Consumer;
diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java b/common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java
index 7926141f3b..3866d415da 100644
--- a/common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java
+++ b/common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java
@@ -23,7 +23,7 @@ package org.onap.so.client.dmaap.rest;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
-import javax.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.core.UriBuilder;
import org.onap.so.client.RestClient;
import org.onap.so.client.dmaap.Publisher;
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
index cf73a57535..fe9723ca36 100644
--- a/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
+++ b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
@@ -23,7 +23,7 @@ package org.onap.so.client.grm;
import java.net.URI;
import java.util.Optional;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
import org.onap.logging.filter.base.ONAPComponents;
import org.onap.so.client.RestClient;
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java b/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java
index 609a206341..5eb2dc39ac 100644
--- a/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java
+++ b/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java
@@ -21,7 +21,7 @@
package org.onap.so.client.grm;
import java.net.URI;
-import javax.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.core.UriBuilder;
import org.onap.so.client.RestClient;
public class GRMRestInvoker {
diff --git a/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java
index 334e0f7231..ac808a45c4 100644
--- a/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java
+++ b/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java
@@ -20,13 +20,14 @@
package org.onap.so.client.policy;
-import javax.ws.rs.ext.ContextResolver;
-import javax.ws.rs.ext.Provider;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import jakarta.ws.rs.ext.ContextResolver;
+import jakarta.ws.rs.ext.Provider;
+
@Provider
public class CommonObjectMapperProvider implements ContextResolver<ObjectMapper> {
diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java b/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java
index f657c17c68..3ac876a5e7 100644
--- a/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java
+++ b/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java
@@ -22,8 +22,8 @@ package org.onap.so.client.policy;
import java.util.Optional;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.UriBuilder;
import org.javatuples.Pair;
import org.onap.logging.filter.base.ONAPComponents;
import org.onap.so.client.RestClient;
diff --git a/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java b/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java
index b17b1fe0fe..f1ee2f3a7e 100644
--- a/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java
+++ b/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java
@@ -21,6 +21,8 @@
package org.onap.so.configuration.rest;
import java.util.concurrent.TimeUnit;
+import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -53,8 +55,8 @@ public class HttpClientConnectionConfiguration {
/**
* @return the socket connection time out in milliseconds
*/
- public int getSocketTimeOutInMiliSeconds() {
- return (int) TimeUnit.SECONDS.toMillis(socketTimeOutInSeconds);
+ public Timeout getSocketTimeOutInMiliSeconds() {
+ return Timeout.ofDays((int) TimeUnit.SECONDS.toMillis(socketTimeOutInSeconds));
}
/**
@@ -74,8 +76,8 @@ public class HttpClientConnectionConfiguration {
/**
* @return the connect time out value in milliseconds.
*/
- public int getConnectionTimeOutInMilliSeconds() {
- return (int) TimeUnit.SECONDS.toMillis(connectionTimeOutInSeconds);
+ public Timeout getConnectionTimeOutInMilliSeconds() {
+ return Timeout.ofDays((int) TimeUnit.SECONDS.toMillis(connectionTimeOutInSeconds));
}
/**
@@ -85,8 +87,8 @@ public class HttpClientConnectionConfiguration {
return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds);
}
- public long getEvictIdleConnectionsTimeInSec() {
- return evictIdleConnectionsTimeInSec;
+ public TimeValue getEvictIdleConnectionsTimeInSec() {
+ return TimeValue.ofDays(evictIdleConnectionsTimeInSec);
}
}
diff --git a/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java b/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java
index aef2ed165e..a68738b65b 100644
--- a/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java
+++ b/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java
@@ -20,16 +20,29 @@
package org.onap.so.configuration.rest;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
-import org.apache.http.client.config.RequestConfig;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.apache.http.impl.NoConnectionReuseStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.apache.hc.client5.http.config.RequestConfig;
+import javax.net.ssl.SSLContext;
/**
* Allow user to configure {@link org.apache.http.client.HttpClient}
@@ -53,24 +66,41 @@ public class HttpComponentsClientConfiguration {
@Bean
public CloseableHttpClient httpClient() {
- return HttpClientBuilder.create().setConnectionManager(poolingHttpClientConnectionManager())
- .setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute())
- .setMaxConnTotal(clientConnectionConfiguration.getMaxConnections())
- .setDefaultRequestConfig(requestConfig()).setConnectionReuseStrategy(NoConnectionReuseStrategy.INSTANCE)
- .evictExpiredConnections().evictIdleConnections(
- clientConnectionConfiguration.getEvictIdleConnectionsTimeInSec(), TimeUnit.SECONDS)
- .build();
+ /*
+ * 1. setConnectionManager = Assigns HttpClientConnectionManager instance. 2. setMaxConnPerRoute = Assigns
+ * maximum connection per route value. Please note this value can be overridden by the setConnectionManager(
+ * org.apache.http.conn.HttpClientConnectionManager) method. 3. setDefaultRequestConfig = Assigns default
+ * ConnectionConfig. Please note this value can be overridden by the setConnectionManager(
+ * org.apache.http.conn.HttpClientConnectionManager) method. 4. evictExpiredConnections = Makes this instance of
+ * HttpClient proactively evict expired connections from the connection pool using a background thread. One MUST
+ * explicitly close HttpClient with Closeable.close() in order to stop and release the background thread. Please
+ * note this method has no effect if the instance of HttpClient is configuted to use a shared connection
+ * manager. Please note this method may not be used when the instance of HttpClient is created inside an EJB
+ * container.
+ */
+ return HttpClients.custom().setConnectionManager(poolingHttpClientConnectionManager())
+ .setDefaultRequestConfig(requestConfig())
+ .setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE).evictExpiredConnections()
+ .evictIdleConnections(clientConnectionConfiguration.getEvictIdleConnectionsTimeInSec()).build();
+
}
+
@Bean
public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {
- return new PoolingHttpClientConnectionManager(clientConnectionConfiguration.getTimeToLiveInMins(),
- TimeUnit.MINUTES);
+
+ PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
+ connectionManager.setMaxTotal(clientConnectionConfiguration.getMaxConnections());
+ connectionManager.setDefaultMaxPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute());
+ return connectionManager;
+
}
@Bean
public RequestConfig requestConfig() {
- return RequestConfig.custom().setSocketTimeout(clientConnectionConfiguration.getSocketTimeOutInMiliSeconds())
- .setConnectTimeout(clientConnectionConfiguration.getConnectionTimeOutInMilliSeconds()).build();
+ return RequestConfig.custom().setResponseTimeout(clientConnectionConfiguration.getSocketTimeOutInMiliSeconds())
+ .setConnectionRequestTimeout(clientConnectionConfiguration.getConnectionTimeOutInMilliSeconds())
+ .build();
+
}
}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java
index 85925e2725..c61169b578 100644
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java
@@ -1,10 +1,10 @@
package org.onap.so.logging.jaxrs.filter;
-import javax.annotation.Priority;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.container.PreMatching;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.annotation.Priority;
+import jakarta.ws.rs.container.ContainerRequestContext;
+import jakarta.ws.rs.container.ContainerResponseContext;
+import jakarta.ws.rs.container.PreMatching;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.onap.logging.filter.base.AuditLogContainerFilter;
import org.onap.logging.filter.base.Constants;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
@@ -16,11 +16,11 @@ import org.springframework.stereotype.Component;
@Priority(1)
@PreMatching
@Component
-public class SOAuditLogContainerFilter extends AuditLogContainerFilter {
+public abstract class SOAuditLogContainerFilter {
private static final String ORIGINAL_PARTNER_NAME = "OriginalPartnerName";
- @Override
+
protected void additionalPreHandling(ContainerRequestContext request) {
request.setProperty("requestId", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
MDC.put(ORIGINAL_PARTNER_NAME, MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
@@ -31,7 +31,7 @@ public class SOAuditLogContainerFilter extends AuditLogContainerFilter {
MDC.put(LogConstants.URI_BASE, request.getUriInfo().getBaseUri().toString());
}
- @Override
+
protected void additionalPostHandling(ContainerResponseContext response) {
MultivaluedMap<String, Object> responseHeaders = response.getHeaders();
String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
@@ -39,8 +39,8 @@ public class SOAuditLogContainerFilter extends AuditLogContainerFilter {
responseHeaders.add(Constants.HttpHeaders.HEADER_REQUEST_ID, requestId);
responseHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, requestId);
responseHeaders.add(Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId);
- responseHeaders.add(ONAPLogConstants.Headers.PARTNER_NAME, getProperty(Constants.Property.PARTNER_NAME));
responseHeaders.add(ONAPLogConstants.Headers.INVOCATION_ID,
MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID));
}
}
+
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java
index 3b6b5216e0..ef06714a50 100644
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java
@@ -20,8 +20,9 @@
package org.onap.so.logging.jaxrs.filter;
-import javax.ws.rs.client.ClientRequestContext;
-import javax.ws.rs.client.ClientResponseContext;
+
+import jakarta.ws.rs.client.ClientRequestContext;
+import jakarta.ws.rs.client.ClientResponseContext;
import org.onap.logging.filter.base.MetricLogClientFilter;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.logger.MdcConstants;
@@ -32,21 +33,16 @@ import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
-public class SOMetricLogClientFilter extends MetricLogClientFilter {
+public class SOMetricLogClientFilter {
protected static Logger logger = LoggerFactory.getLogger(SOMetricLogClientFilter.class);
private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
- @Override
+
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) {
try {
- setLogTimestamp();
- setElapsedTimeInvokeTimestamp();
- setResponseStatusCode(responseContext.getStatus());
- setResponseDescription(responseContext.getStatus());
MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus()));
logger.info(INVOKE_RETURN, "InvokeReturn");
- clearClientMDCs();
setOpenStackResponseCode();
} catch (Exception e) {
logger.warn("Error in JAX-RS request,response client filter", e);
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java
index cf826d6350..2f1067eaed 100644
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java
@@ -45,8 +45,8 @@ public class SOSpringClientFilter extends SpringClientFilter implements ClientHt
setLogTimestamp();
setElapsedTimeInvokeTimestamp();
try {
- setResponseStatusCode(response.getRawStatusCode());
- int statusCode = response.getRawStatusCode();
+ setResponseStatusCode(response.getStatusCode().value());
+ int statusCode = response.getStatusCode().value();
MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(statusCode));
setResponseDescription(statusCode);
} catch (IOException e) {
diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
index 04dd0bbb7a..6746cfc70a 100644
--- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
+++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
@@ -31,6 +31,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
diff --git a/common/src/main/java/org/onap/so/security/BaseWebSecurityConfigurerAdapter.java b/common/src/main/java/org/onap/so/security/BaseWebSecurityConfigurerAdapter.java
index f494a6b812..f2c77cdc39 100644
--- a/common/src/main/java/org/onap/so/security/BaseWebSecurityConfigurerAdapter.java
+++ b/common/src/main/java/org/onap/so/security/BaseWebSecurityConfigurerAdapter.java
@@ -3,15 +3,17 @@ package org.onap.so.security;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.firewall.StrictHttpFirewall;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-public abstract class BaseWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
+
+public abstract class BaseWebSecurityConfigurerAdapter /* implements WebSecurityConfigurer */ {
private static final Logger LOGGER = LoggerFactory.getLogger(BaseWebSecurityConfigurerAdapter.class);
@Autowired
@@ -22,23 +24,33 @@ public abstract class BaseWebSecurityConfigurerAdapter extends WebSecurityConfig
abstract HttpSecurityConfigurer getHttpSecurityConfigurer();
- @Override
- protected void configure(final HttpSecurity http) throws Exception {
+
+ public void configure(final WebSecurity web) throws Exception {
+ this.configure(web);
+ final StrictHttpFirewall firewall = new MSOSpringFirewall();
+ web.httpFirewall(firewall);
+ }
+
+ @Bean(name = "httpSecurityBeanOfBaseWebSecurityConfigurerAdapter")
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
HttpSecurityConfigurer httpSecurityConfigurer = getHttpSecurityConfigurer();
LOGGER.debug("Injecting {} configuration ...", httpSecurityConfigurer.getClass());
- httpSecurityConfigurer.configure(http);
+ return httpSecurityConfigurer.configure(http);
}
- @Override
- public void configure(final WebSecurity web) throws Exception {
- super.configure(web);
+ @Bean(name = "webSecurityBeanOfBaseWebSecurityConfigurerAdapter")
+ public WebSecurity filterChain(WebSecurity web) throws Exception {
+ this.configure(web);
final StrictHttpFirewall firewall = new MSOSpringFirewall();
- web.httpFirewall(firewall);
+ return web.httpFirewall(firewall);
+
}
- @Override
- protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder);
+ @Bean(name = "authenticationManagerBuilderBeanOfBaseWebSecurityConfigurerAdapter")
+ public SecurityFilterChain filterChain(final AuthenticationManagerBuilder auth) throws Exception {
+ return (SecurityFilterChain) auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder);
}
+
+
}
diff --git a/common/src/main/java/org/onap/so/security/CorsBasicHttpSecurityConfigurer.java b/common/src/main/java/org/onap/so/security/CorsBasicHttpSecurityConfigurer.java
index 27c998f87d..7dd6a8df07 100644
--- a/common/src/main/java/org/onap/so/security/CorsBasicHttpSecurityConfigurer.java
+++ b/common/src/main/java/org/onap/so/security/CorsBasicHttpSecurityConfigurer.java
@@ -3,6 +3,7 @@ package org.onap.so.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.web.SecurityFilterChain;
import org.springframework.stereotype.Component;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
@@ -14,9 +15,17 @@ import java.util.Arrays;
public class CorsBasicHttpSecurityConfigurer implements HttpSecurityConfigurer {
@Override
- public void configure(final HttpSecurity http) throws Exception {
- http.cors().and().csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
- .antMatchers("/**").fullyAuthenticated().and().httpBasic();
+ public SecurityFilterChain configure(final HttpSecurity http) throws Exception {
+ http.cors(cors -> cors.disable()).csrf(csrf -> {
+ try {
+ csrf.disable().authorizeRequests().requestMatchers("/manage/health", "/manage/info").permitAll()
+ .requestMatchers("/**").fullyAuthenticated().and().httpBasic(httpBasic -> httpBasic.disable());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+ return null;
+
}
@Bean
diff --git a/common/src/main/java/org/onap/so/security/HttpHeaderForwarderHandlerInterceptor.java b/common/src/main/java/org/onap/so/security/HttpHeaderForwarderHandlerInterceptor.java
index da01e5e1cf..811bdb9088 100644
--- a/common/src/main/java/org/onap/so/security/HttpHeaderForwarderHandlerInterceptor.java
+++ b/common/src/main/java/org/onap/so/security/HttpHeaderForwarderHandlerInterceptor.java
@@ -25,10 +25,10 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.google.common.collect.ImmutableSet;
/**
@@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableSet;
*
*/
-public class HttpHeaderForwarderHandlerInterceptor extends HandlerInterceptorAdapter {
+public class HttpHeaderForwarderHandlerInterceptor implements HandlerInterceptor {
private static final ThreadLocal<Map<String, List<String>>> HEADERS_THREAD_LOCAL = new ThreadLocal<>();
@@ -52,7 +52,8 @@ public class HttpHeaderForwarderHandlerInterceptor extends HandlerInterceptorAda
.collect(Collectors.toMap(Function.identity(), h -> Collections.list(request.getHeaders(h))));
HEADERS_THREAD_LOCAL.set(headerMap);
- return super.preHandle(request, response, handler);
+ return HandlerInterceptor.super.preHandle(request, (jakarta.servlet.http.HttpServletResponse) response,
+ handler);
}
@Override
diff --git a/common/src/main/java/org/onap/so/security/HttpSecurityConfigurer.java b/common/src/main/java/org/onap/so/security/HttpSecurityConfigurer.java
index ffd5931c92..9255550778 100644
--- a/common/src/main/java/org/onap/so/security/HttpSecurityConfigurer.java
+++ b/common/src/main/java/org/onap/so/security/HttpSecurityConfigurer.java
@@ -20,6 +20,7 @@
package org.onap.so.security;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.web.SecurityFilterChain;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -27,6 +28,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
*/
public interface HttpSecurityConfigurer {
- void configure(final HttpSecurity http) throws Exception;
+ SecurityFilterChain configure(final HttpSecurity http) throws Exception;
}
diff --git a/common/src/main/java/org/onap/so/security/SecurityFilters.java b/common/src/main/java/org/onap/so/security/SecurityFilters.java
deleted file mode 100644
index 7ad0fd05df..0000000000
--- a/common/src/main/java/org/onap/so/security/SecurityFilters.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.security;
-
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.core.Ordered;
-
-@Configuration
-@Profile("!test & aaf")
-public class SecurityFilters {
-
- @Bean
- public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() {
- FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>();
- filterRegistrationBean.setFilter(new SoCadiFilter());
- filterRegistrationBean.setName("cadiFilter");
- filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
- return filterRegistrationBean;
- }
-}
diff --git a/common/src/main/java/org/onap/so/security/SoBasicHttpSecurityConfigurer.java b/common/src/main/java/org/onap/so/security/SoBasicHttpSecurityConfigurer.java
index da989ee42a..6dccb56953 100644
--- a/common/src/main/java/org/onap/so/security/SoBasicHttpSecurityConfigurer.java
+++ b/common/src/main/java/org/onap/so/security/SoBasicHttpSecurityConfigurer.java
@@ -21,6 +21,7 @@ package org.onap.so.security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.web.SecurityFilterChain;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -35,11 +36,12 @@ public class SoBasicHttpSecurityConfigurer implements HttpSecurityConfigurer {
private SoUserCredentialConfiguration soUserCredentialConfiguration;
@Override
- public void configure(final HttpSecurity http) throws Exception {
- http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
- .antMatchers("/**")
+ public SecurityFilterChain configure(final HttpSecurity http) throws Exception {
+ http.csrf(csrf -> csrf.disable()).authorizeRequests().requestMatchers("/manage/health", "/manage/info")
+ .permitAll().requestMatchers("/**")
.hasAnyRole(StringUtils.collectionToDelimitedString(soUserCredentialConfiguration.getRoles(), ","))
- .and().httpBasic();
+ .and().httpBasic(httpBasic -> httpBasic.disable());
+ return null;
}
}
diff --git a/common/src/main/java/org/onap/so/security/SoCadiFilter.java b/common/src/main/java/org/onap/so/security/SoCadiFilter.java
deleted file mode 100644
index 1660220dc1..0000000000
--- a/common/src/main/java/org/onap/so/security/SoCadiFilter.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP SO
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-package org.onap.so.security;
-
-import javax.annotation.Priority;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.cadi.filter.CadiFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Component;
-
-@Component
-@Profile("!test & aaf")
-// Run right before default priority of 0 to block requests
-@Priority(-1)
-public class SoCadiFilter extends CadiFilter {
-
- protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class);
-
- @Value("${mso.config.cadi.cadiLoglevel:#{null}}")
- private String cadiLoglevel;
-
- @Value("${mso.config.cadi.cadiKeyFile:#{null}}")
- private String cadiKeyFile;
-
- @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}")
- private String cadiTrustStorePassword;
-
- @Value("${mso.config.cadi.cadiTrustStore:#{null}}")
- private String cadiTrustStore;
-
- @Value("${mso.config.cadi.cadiLatitude:#{null}}")
- private String cadiLatitude;
-
- @Value("${mso.config.cadi.cadiLongitude:#{null}}")
- private String cadiLongitude;
-
- @Value("${mso.config.cadi.aafEnv:#{null}}")
- private String aafEnv;
-
- @Value("${mso.config.cadi.aafApiVersion:#{null}}")
- private String aafApiVersion;
-
- @Value("${mso.config.cadi.aafRootNs:#{null}}")
- private String aafRootNs;
-
- @Value("${mso.config.cadi.aafId:#{null}}")
- private String aafMechId;
-
- @Value("${mso.config.cadi.aafPassword:#{null}}")
- private String aafMechIdPassword;
-
- @Value("${mso.config.cadi.aafLocateUrl:#{null}}")
- private String aafLocateUrl;
-
- @Value("${mso.config.cadi.aafUrl:#{null}}")
- private String aafUrl;
-
- @Value("${mso.config.cadi.apiEnforcement:#{null}}")
- private String apiEnforcement;
-
- @Value("${mso.config.cadi.userExpires:#{null}}")
- private String userExpires;
-
- private void checkIfNullProperty(String key, String value) {
- /*
- * When value is null, it is not defined in application.yaml set nothing in System properties
- */
- if (value != null) {
- System.setProperty(key, value);
- }
- }
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel);
- checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile);
- checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore);
- checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword);
- checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude);
- checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude);
- checkIfNullProperty(Config.AAF_ENV, aafEnv);
- checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion);
- checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs);
- checkIfNullProperty(Config.AAF_APPID, aafMechId);
- checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword);
- checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl);
- checkIfNullProperty(Config.AAF_URL, aafUrl);
- checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement);
- checkIfNullProperty(Config.AAF_USER_EXPIRES, userExpires);
- // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv);
- logger.debug(" *** init Filter Config *** ");
- super.init(filterConfig);
- }
-
-
-}
diff --git a/common/src/main/java/org/onap/so/security/SoNoAuthWebSecurityConfigurerAdapter.java b/common/src/main/java/org/onap/so/security/SoNoAuthWebSecurityConfigurerAdapter.java
index 4a112b9687..2c9d002fdc 100644
--- a/common/src/main/java/org/onap/so/security/SoNoAuthWebSecurityConfigurerAdapter.java
+++ b/common/src/main/java/org/onap/so/security/SoNoAuthWebSecurityConfigurerAdapter.java
@@ -19,12 +19,13 @@
*/
package org.onap.so.security;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.firewall.StrictHttpFirewall;
/**
@@ -35,11 +36,12 @@ import org.springframework.security.web.firewall.StrictHttpFirewall;
@Configuration
@Order(2)
@Profile({"aaf", "test", "serviceMesh"})
-public class SoNoAuthWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
- @Override
- public void configure(final WebSecurity web) throws Exception {
- web.ignoring().antMatchers("/**");
+public class SoNoAuthWebSecurityConfigurerAdapter /* implements WebSecurityConfigurer */ {
+ @Bean(name = "webSecurityBeanOfSoNoAuthWebSecurityConfigurerAdapter")
+ public SecurityFilterChain filterChain(WebSecurity web) throws Exception {
+ web.ignoring().requestMatchers("/**");
final StrictHttpFirewall firewall = new MSOSpringFirewall();
web.httpFirewall(firewall);
+ return (SecurityFilterChain) web.build();
}
}
diff --git a/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java
index d20433df2e..31284f7c8d 100644
--- a/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java
+++ b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java
@@ -22,10 +22,9 @@
package org.onap.so.web.exceptions;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.ext.ExceptionMapper;
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.ext.ExceptionMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,10 +36,10 @@ public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException>
public Response toResponse(RuntimeException exception) {
if (exception instanceof NotFoundException) {
- return Response.status(Status.NOT_FOUND).build();
+ return Response.status(Response.Status.NOT_FOUND).build();
} else {
logger.error("Error occured", exception);
- return Response.status(Status.INTERNAL_SERVER_ERROR)
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(new ExceptionResponse("Unexpected Internal Exception")).build();
}
}
diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java
index 3966d183f7..d58289a857 100644
--- a/common/src/test/java/org/onap/so/client/HttpClientTest.java
+++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java
@@ -70,7 +70,6 @@ public class HttpClientTest {
URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post");
HttpClient client = httpClientFactory.newJsonClient(url, ONAPComponents.BPMN);
- client.addAdditionalHeader("Accept", "application/json");
client.addAdditionalHeader("id", null);
client.post("{}");
@@ -89,7 +88,6 @@ public class HttpClientTest {
HttpClient client = httpClientFactory.newJsonClient(url, ONAPComponents.BPMN);
client.addBasicAuthHeader("", "12345");
- client.addAdditionalHeader("Accept", "application/json");
client.post("{}");
@@ -180,7 +178,6 @@ public class HttpClientTest {
URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post");
HttpClient client = httpClientFactory.newTextXmlClient(url, ONAPComponents.BPMN);
- client.addAdditionalHeader("Accept", "text/xml");
client.addAdditionalHeader("id", null);
client.post("{}");
@@ -199,7 +196,6 @@ public class HttpClientTest {
HttpClient client = httpClientFactory.newTextXmlClient(url, ONAPComponents.BPMN);
client.addBasicAuthHeader("", "12345");
- client.addAdditionalHeader("Accept", "text/xml");
client.post("{}");
diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java
index b5efa17216..1448efca3c 100644
--- a/common/src/test/java/org/onap/so/client/RestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/RestClientTest.java
@@ -35,13 +35,13 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.util.Optional;
import javax.net.ssl.SSLException;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.client.ResponseProcessingException;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriBuilderException;
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.ProcessingException;
+import jakarta.ws.rs.WebApplicationException;
+import jakarta.ws.rs.client.ResponseProcessingException;
+import jakarta.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.core.UriBuilderException;
import org.javatuples.Pair;
import org.junit.Rule;
import org.junit.Test;
diff --git a/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
index 964707ab8f..892e2b4a4d 100644
--- a/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
@@ -26,8 +26,8 @@ import static org.mockito.Mockito.when;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.apache.commons.codec.binary.Base64;
import org.javatuples.Pair;
import org.junit.Before;
diff --git a/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java b/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java
index 4f00b9db96..ded67ffb77 100644
--- a/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java
@@ -24,8 +24,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.net.MalformedURLException;
import java.net.URL;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
diff --git a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java
index f9547cb3db..46cd42ec54 100644
--- a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java
+++ b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java
@@ -36,8 +36,8 @@ import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
import org.junit.BeforeClass;
import org.junit.Test;
diff --git a/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java b/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java
index 4b054ff7d1..a2b5ede57a 100644
--- a/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java
+++ b/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java
@@ -21,8 +21,12 @@
package org.onap.so.configuration.rest;
import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import org.junit.Test;
+import org.mockito.Mock;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import javax.annotation.meta.When;
/**
* @author waqas.ikram@est.tech
@@ -31,10 +35,12 @@ public class HttpComponentsClientConfigurationTest {
@Test
public void test_httpComponentsClientHttpRequestFactory_HttpComponentsClientHttpRequestFactoryNotNull() {
- final HttpClientConnectionConfiguration clientConnectionConfiguration = new HttpClientConnectionConfiguration();
+ final HttpClientConnectionConfiguration clientConnectionConfiguration =
+ mock(HttpClientConnectionConfiguration.class);
final HttpComponentsClientConfiguration objUnderTest =
new HttpComponentsClientConfiguration(clientConnectionConfiguration);
-
+ when(clientConnectionConfiguration.getMaxConnections()).thenReturn(100);
+ when(clientConnectionConfiguration.getMaxConnectionsPerRoute()).thenReturn(20);
final HttpComponentsClientHttpRequestFactory factory = objUnderTest.httpComponentsClientHttpRequestFactory();
assertNotNull(factory);
assertNotNull(factory.getHttpClient());
diff --git a/common/src/test/java/org/onap/so/constants/DefaultsTest.java b/common/src/test/java/org/onap/so/constants/DefaultsTest.java
index 11ecc96c36..e4cc96d1ef 100644
--- a/common/src/test/java/org/onap/so/constants/DefaultsTest.java
+++ b/common/src/test/java/org/onap/so/constants/DefaultsTest.java
@@ -26,13 +26,13 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.onap.so.spring.SpringContextHelper;
import org.onap.so.test.categories.SpringAware;
-import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
+import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class)
+@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigDataApplicationContextInitializer.class)
@ActiveProfiles("test")
@Category(SpringAware.class)
public class DefaultsTest {
diff --git a/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java b/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java
index 72bacdf2db..d620241395 100644
--- a/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java
+++ b/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java
@@ -35,11 +35,9 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.rest.exceptions.InvalidRestRequestException;
import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
import org.onap.so.rest.exceptions.RestProcessingException;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@@ -59,6 +57,9 @@ public class HttpRestServiceProviderImplTest {
@Mock
private ResponseEntity<String> mockEntity;
+ @Mock
+ private HttpStatusCodeException httpStatusCodeException;
+
@Test
public void test_get_returnOptionalPresentIfResponseIsOKAndHasBody() {
@@ -124,10 +125,12 @@ public class HttpRestServiceProviderImplTest {
@Test(expected = RestProcessingException.class)
public void test_get_ThrowsInvalidRestRequestExceptionifHttpClientErrorExceptionOccured() {
+
final HttpRestServiceProvider objUnderTest = new HttpRestServiceProviderImpl(mockRestTemplate);
+ HttpClientErrorException httpClientErrorException = new HttpClientErrorException(HttpStatus.CONFLICT);
when(mockRestTemplate.exchange(eq(DUMMY_URL), eq(HttpMethod.GET), any(HttpEntity.class), eq(String.class)))
- .thenThrow(HttpClientErrorException.class);
+ .thenThrow(httpClientErrorException);
objUnderTest.get(DUMMY_URL, String.class);
}
@@ -249,8 +252,9 @@ public class HttpRestServiceProviderImplTest {
public void test_post_ThrowsInvalidRestRequestExceptionifHttpClientErrorExceptionOccured() {
final HttpRestServiceProvider objUnderTest = new HttpRestServiceProviderImpl(mockRestTemplate);
+ HttpClientErrorException httpClientErrorException = new HttpClientErrorException(HttpStatus.CONFLICT);
when(mockRestTemplate.exchange(eq(DUMMY_URL), eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class)))
- .thenThrow(HttpClientErrorException.class);
+ .thenThrow(httpClientErrorException);
objUnderTest.post(BODY, DUMMY_URL, String.class);
}
diff --git a/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
index d1d3f2a5f0..82b2a2a5b6 100644
--- a/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
+++ b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
@@ -26,9 +26,8 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.core.Response;
import org.junit.AfterClass;
import org.junit.Test;
@@ -44,7 +43,7 @@ public class RuntimeExceptionMapperTest {
Response r = mapper.toResponse(new RuntimeException("This is the run time exception message"));
- assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
assertThat(r.getEntity(), instanceOf(ExceptionResponse.class));
assertThat(((ExceptionResponse) r.getEntity()).getMessage(), equalTo("Unexpected Internal Exception"));
@@ -57,7 +56,7 @@ public class RuntimeExceptionMapperTest {
Response r = mapper.toResponse(new NotFoundException("not found"));
- assertEquals(Status.NOT_FOUND.getStatusCode(), r.getStatus());
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), r.getStatus());
assertThat(r.getEntity(), is(nullValue()));
}