diff options
author | MukeshKumar <mukeshsharma@est.tech> | 2021-08-06 01:00:46 +0100 |
---|---|---|
committer | Mukesh <mukeshsharma@est.tech> | 2021-08-06 17:19:37 +0100 |
commit | 06b09776f5390fd763a39c9ab1f005e46fc00104 (patch) | |
tree | 626e4d818218bca2c53a3b7cb7c0e41c2ac4fed8 /so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main | |
parent | 89792d8a23d8c83d3097becf6459d4b905305b5b (diff) |
Fixing vulnerabilities1.9.0
Issue-ID: SO-3726
Signed-off-by: Mukesh <mukeshsharma@est.tech>
Change-Id: Ie23b56383c776033d0577fbdafcb4e8746272a1f
Diffstat (limited to 'so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main')
3 files changed, 21 insertions, 42 deletions
diff --git a/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java index 1ff3672..f83d975 100644 --- a/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java +++ b/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -25,6 +25,7 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; +import java.time.format.DateTimeFormatter; import java.util.concurrent.TimeUnit; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; @@ -40,7 +41,9 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContextBuilder; import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.common.utils.LocalDateTimeTypeAdapter; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; +import org.onap.so.adapters.etsi.sol003.adapter.common.GsonProvider; import org.onap.so.configuration.rest.HttpClientConnectionConfiguration; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.onap.so.rest.service.HttpRestServiceProvider; @@ -75,6 +78,10 @@ public class EtsiCatalogServiceProviderConfiguration extends AbstractServiceProv private final HttpClientConnectionConfiguration clientConnectionConfiguration; + private final GsonProvider gsonProvider; + + private final LocalDateTimeTypeAdapter localDateTimeTypeAdapter; + @Value("${etsi-catalog-manager.http.client.ssl.trust-store:#{null}}") private Resource trustStore; @Value("${etsi-catalog-manager.http.client.ssl.trust-store-password:#{null}}") @@ -82,8 +89,10 @@ public class EtsiCatalogServiceProviderConfiguration extends AbstractServiceProv @Autowired public EtsiCatalogServiceProviderConfiguration( - final HttpClientConnectionConfiguration clientConnectionConfiguration) { + final HttpClientConnectionConfiguration clientConnectionConfiguration, final GsonProvider gsonProvider) { this.clientConnectionConfiguration = clientConnectionConfiguration; + this.gsonProvider = gsonProvider; + this.localDateTimeTypeAdapter = new LocalDateTimeTypeAdapter(DateTimeFormatter.ISO_LOCAL_DATE); } @Bean @@ -170,7 +179,7 @@ public class EtsiCatalogServiceProviderConfiguration extends AbstractServiceProv @Override protected Gson getGson() { - return new JSON().getGson(); + return gsonProvider.getGson(localDateTimeTypeAdapter); } } diff --git a/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java b/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java index 22bbef9..72b937c 100644 --- a/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java +++ b/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java @@ -20,11 +20,8 @@ package org.onap.so.adapters.etsisol003adapter.pkgm.extclients.vnfm; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; -import org.onap.so.adapters.etsisol003adapter.pkgm.JSON; -import org.onap.so.adapters.etsisol003adapter.pkgm.rest.EtsiSubscriptionNotificationController; +import org.onap.so.adapters.etsi.sol003.adapter.common.GsonProvider; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; @@ -41,10 +38,16 @@ import com.google.gson.Gson; */ @Configuration public class VnfmHttpServiceProviderConfiguration extends AbstractServiceProviderConfiguration { - private final JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new JSON.OffsetDateTimeTypeAdapter(); public static final String VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN = "vnfmAdapterHttpServiceProvider"; + private final GsonProvider gsonProvider; + + @Autowired + public VnfmHttpServiceProviderConfiguration(final GsonProvider gsonProvider) { + this.gsonProvider = gsonProvider; + } + @Bean @Qualifier(VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN) public HttpRestServiceProvider vnfmAdapterHttpRestServiceProvider( @@ -55,10 +58,7 @@ public class VnfmHttpServiceProviderConfiguration extends AbstractServiceProvide @Override protected Gson getGson() { - return JSON.createGson().registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) - .registerTypeAdapter(LocalDateTime.class, - new EtsiSubscriptionNotificationController.LocalDateTimeTypeAdapter()) - .create(); + return gsonProvider.getGson(); } } diff --git a/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/EtsiSubscriptionNotificationController.java b/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/EtsiSubscriptionNotificationController.java index 2b4b486..b19fe2c 100644 --- a/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/EtsiSubscriptionNotificationController.java +++ b/so-etsi-sol003-adapter-pkgm/so-etsi-sol003-adapter-pkgm-service/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/EtsiSubscriptionNotificationController.java @@ -22,12 +22,11 @@ package org.onap.so.adapters.etsisol003adapter.pkgm.rest; import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL; import static org.slf4j.LoggerFactory.getLogger; -import java.io.IOException; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.AbstractMap; import java.util.Map.Entry; import javax.ws.rs.core.MediaType; +import org.onap.so.adapters.etsi.sol003.adapter.common.utils.LocalDateTimeTypeAdapter; import org.onap.so.adapters.etsisol003adapter.etsicatalog.notification.model.PkgChangeNotification; import org.onap.so.adapters.etsisol003adapter.etsicatalog.notification.model.PkgOnboardingNotification; import org.onap.so.adapters.etsisol003adapter.pkgm.rest.exceptions.InternalServerErrorException; @@ -45,9 +44,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; /** * This controller handles the ETSI Subscription Notification Endpoints. @@ -137,30 +133,4 @@ public class EtsiSubscriptionNotificationController { "Unable to parse notification type in object \n" + notification); } - public static class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> { - - private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - @Override - public void write(final JsonWriter out, final LocalDateTime localDateTime) throws IOException { - if (localDateTime == null) { - out.nullValue(); - } else { - out.value(FORMATTER.format(localDateTime)); - } - } - - @Override - public LocalDateTime read(final JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - final String dateTime = in.nextString(); - return LocalDateTime.parse(dateTime, FORMATTER); - } - } - } - } |