Skip to content
Snippets Groups Projects
Commit 698aae6d authored by Neelesh Thakur's avatar Neelesh Thakur Committed by ethiraj krishnamanaidu
Browse files

refactor provider interfaces

parent f962c2ad
No related branches found
No related tags found
No related merge requests found
Showing
with 53 additions and 38 deletions
## Type of change
- [ ] Bug Fix
- [ ] Feature
**Please provide link to gitlab issue or ADR(Architecture Decision Record)**
## Does this introduce a change in the core logic?
- [YES/NO]
## Does this introduce a change in the cloud provider implementation, if so which cloud?
- [ ] AWS
- [ ] Azure
- [ ] GCP
- [ ] IBM
## Does this introduce a breaking change?
- [YES/NO]
## What is the current behavior?
## What is the new/expected behavior?
## Have you added/updated Unit Tests and Integration Tests?
## Any other useful information
......@@ -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;
......
......@@ -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.IServiceAccountValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
......@@ -40,7 +40,7 @@ public class AuthorizationFilter {
@Autowired
private RequestInfoExt requestInfoExt;
@Autowired
private ServiceAccountValidator validator;
private IServiceAccountValidator validator;
public boolean hasAnyPermission(String... requiredRoles) {
DpsHeaders dpsHeaders = requestInfoExt.getHeaders();
......
......@@ -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;
......
......@@ -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;
......
......@@ -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> {
......
......@@ -14,10 +14,11 @@
* limitations under the License.
*/
package org.opengroup.osdu.notification.auth;
package org.opengroup.osdu.notification.provider.interfaces;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
public interface IAppProperties {
public interface AuthorizationService {
String authorizeAny(DpsHeaders headers, String... roles);
}
String getAuthorizeAPI();
String getRegisterAPI();
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.opengroup.osdu.notification.utils;
package org.opengroup.osdu.notification.provider.interfaces;
public interface IGoogleServiceAccount {
......
......@@ -14,9 +14,10 @@
* limitations under the License.
*/
package org.opengroup.osdu.notification.utils;
package org.opengroup.osdu.notification.provider.interfaces;
public interface IServiceAccountValidator {
public interface ServiceAccountValidator {
boolean isValidPublisherServiceAccount(String jwt);
boolean isValidServiceAccount(String jwt, String userIdentity, String... audiences);
......
package org.opengroup.osdu.notification.utils;
public interface IAppProperties {
String getAuthorizeAPI();
String getRegisterAPI();
}
\ No newline at end of file
......@@ -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;
......
......@@ -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.IServiceAccountValidator;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
......@@ -57,7 +57,7 @@ public class AuthorizationFilterTest {
@Mock
private IAuthorizationService authorizationService;
@Mock
private ServiceAccountValidator validator;
private IServiceAccountValidator validator;
@Mock
private PubsubRequestBodyExtractor extractor;
@InjectMocks
......
......@@ -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;
......
......@@ -19,7 +19,7 @@ import com.azure.cosmos.CosmosClient;
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
import org.opengroup.osdu.azure.KeyVaultFacade;
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.context.annotation.Bean;
......
......@@ -14,11 +14,11 @@
package org.opengroup.osdu.notification.provider.azure.util;
import org.opengroup.osdu.notification.utils.ServiceAccountValidator;
import org.opengroup.osdu.notification.provider.interfaces.IServiceAccountValidator;
import org.springframework.stereotype.Component;
@Component
public class AzureServiceAccountValidatorImpl implements ServiceAccountValidator {
public class AzureServiceAccountValidatorImpl implements IServiceAccountValidator {
@Override
public boolean isValidPublisherServiceAccount(String jwt) {
......
......@@ -15,7 +15,7 @@
package org.opengroup.osdu.notification.provider.azure.util;
import lombok.SneakyThrows;
import org.opengroup.osdu.notification.utils.IGoogleServiceAccount;
import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount;
import org.springframework.stereotype.Component;
import javax.naming.AuthenticationNotSupportedException;
......
......@@ -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;
......
......@@ -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;
......
......@@ -21,12 +21,12 @@ 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.IServiceAccountValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class GoogleServiceAccountValidatorImpl implements ServiceAccountValidator {
public class GoogleServiceAccountValidatorImpl implements IServiceAccountValidator {
private final NetHttpTransport netHttpTransport = new NetHttpTransport();
private final JacksonFactory jacksonFactory = new JacksonFactory();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment