From 698a128adfdc29e91ea0a289e169e1f4b6c3e2e7 Mon Sep 17 00:00:00 2001 From: Neelesh Thakur <NThakur4@slb.com> Date: Thu, 13 Aug 2020 11:03:01 -0500 Subject: [PATCH] refactor --- .../opengroup/osdu/notification/api/PubsubEndpoint.java | 2 +- .../osdu/notification/auth/AuthorizationFilter.java | 2 +- .../osdu/notification/auth/EntitlementsClientFactory.java | 2 +- .../osdu/notification/di/CredentialHeadersProvider.java | 1 - .../osdu/notification/di/SubscriptionClientFactory.java | 8 ++------ .../notification/provider/interfaces/IAppProperties.java | 2 +- .../provider/interfaces/IGoogleServiceAccount.java | 2 +- .../provider/interfaces/ServiceAccountValidator.java | 4 ++-- .../osdu/notification/api/PubsubEndpointTests.java | 2 +- .../osdu/notification/auth/AuthorizationFilterTest.java | 2 +- .../opengroup/osdu/notification/di/RequestInfoTest.java | 2 +- .../notification/provider/gcp/util/AppProperties.java | 2 +- .../provider/gcp/util/GoogleServiceAccountImpl.java | 2 +- .../gcp/util/GoogleServiceAccountValidatorImpl.java | 2 +- 14 files changed, 15 insertions(+), 20 deletions(-) diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java b/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java index 975d66958..89a3376a1 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java @@ -36,7 +36,7 @@ import org.opengroup.osdu.core.common.notification.SubscriptionException; import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; import org.opengroup.osdu.notification.utils.Config; -import org.opengroup.osdu.notification.utils.IGoogleServiceAccount; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java index c720b2d5c..e646b8779 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java @@ -23,7 +23,7 @@ import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService; import org.opengroup.osdu.notification.di.RequestInfoExt; import org.opengroup.osdu.notification.utils.Config; -import org.opengroup.osdu.notification.utils.ServiceAccountValidator; +import org.opengroup.osdu.notification.provider.interfaces.ServiceAccountValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.RequestScope; diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java index efd7a908e..53a5427d1 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java @@ -19,7 +19,7 @@ package org.opengroup.osdu.notification.auth; import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; import org.opengroup.osdu.core.common.entitlements.EntitlementsFactory; import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.stereotype.Component; diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java b/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java index f27e7815c..24b6646c8 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java @@ -18,7 +18,6 @@ package org.opengroup.osdu.notification.di; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; -import org.opengroup.osdu.notification.utils.IAppProperties; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java b/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java index b367f7fc1..feda29e96 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java @@ -16,17 +16,13 @@ package org.opengroup.osdu.notification.di; +import org.opengroup.osdu.core.common.notification.ISubscriptionFactory; import org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig; import org.opengroup.osdu.core.common.notification.SubscriptionFactory; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import org.opengroup.osdu.core.common.notification.ISubscriptionFactory; -import org.opengroup.osdu.core.common.model.notification.*; @Component public class SubscriptionClientFactory extends AbstractFactoryBean<ISubscriptionFactory> { diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IAppProperties.java b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IAppProperties.java index 855d35126..188ca8c28 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IAppProperties.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IAppProperties.java @@ -1,4 +1,4 @@ -package org.opengroup.osdu.notification.utils; +package org.opengroup.osdu.notification.provider.interfaces; public interface IAppProperties { diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IGoogleServiceAccount.java b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IGoogleServiceAccount.java index ae067a8a9..33628ba3d 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IGoogleServiceAccount.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IGoogleServiceAccount.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.opengroup.osdu.notification.utils; +package org.opengroup.osdu.notification.provider.interfaces; public interface IGoogleServiceAccount { diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/ServiceAccountValidator.java b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/ServiceAccountValidator.java index f733ea724..fc3648987 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/ServiceAccountValidator.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/ServiceAccountValidator.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package org.opengroup.osdu.notification.utils; +package org.opengroup.osdu.notification.provider.interfaces; public interface ServiceAccountValidator { - + boolean isValidPublisherServiceAccount(String jwt); boolean isValidServiceAccount(String jwt, String userIdentity, String... audiences); diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java b/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java index 67b9a4a81..d3155489b 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java @@ -37,7 +37,7 @@ import org.opengroup.osdu.core.common.notification.SubscriptionService; import org.opengroup.osdu.notification.di.CredentialHeadersProvider; import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; -import org.opengroup.osdu.notification.utils.IGoogleServiceAccount; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.http.ResponseEntity; diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java index c73e87d11..6becc37ed 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java @@ -28,7 +28,7 @@ import org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService; import org.opengroup.osdu.notification.di.RequestInfoExt; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; import org.opengroup.osdu.notification.utils.Config; -import org.opengroup.osdu.notification.utils.ServiceAccountValidator; +import org.opengroup.osdu.notification.provider.interfaces.ServiceAccountValidator; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashMap; diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java index 2518ce8e1..a0a7d4814 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java @@ -20,7 +20,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.powermock.modules.junit4.PowerMockRunner; import javax.servlet.http.HttpServletRequest; diff --git a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java index 19789adf6..1aa85c59d 100644 --- a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java +++ b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java @@ -16,7 +16,7 @@ package org.opengroup.osdu.notification.provider.gcp.util; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java index 7dcf3ba66..1555ab181 100644 --- a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java +++ b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java @@ -19,7 +19,7 @@ package org.opengroup.osdu.notification.provider.gcp.util; import lombok.SneakyThrows; import org.apache.http.impl.client.CloseableHttpClient; import org.opengroup.osdu.core.gcp.GoogleIdToken.IGoogleIdTokenFactory; -import org.opengroup.osdu.notification.utils.IGoogleServiceAccount; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java index 2d70b3d3c..eaac68d6c 100644 --- a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java +++ b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java @@ -21,7 +21,7 @@ import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.jackson2.JacksonFactory; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; -import org.opengroup.osdu.notification.utils.ServiceAccountValidator; +import org.opengroup.osdu.notification.provider.interfaces.ServiceAccountValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -- GitLab