diff --git a/src/main/java/cloud/fogbow/ms/Main.java b/src/main/java/cloud/fogbow/ms/Main.java index 756fce0..8474449 100644 --- a/src/main/java/cloud/fogbow/ms/Main.java +++ b/src/main/java/cloud/fogbow/ms/Main.java @@ -14,7 +14,7 @@ import cloud.fogbow.ms.core.MembershipService; import cloud.fogbow.ms.core.PluginInstantiator; import cloud.fogbow.ms.core.PropertiesHolder; -import cloud.fogbow.ms.core.authorization.AdminOperation; +import cloud.fogbow.ms.core.authorization.MsOperation; @Component public class Main implements ApplicationRunner { @@ -28,7 +28,7 @@ public void run(ApplicationArguments args) throws ConfigurationErrorException { ServiceAsymmetricKeysHolder.getInstance().setPublicKeyFilePath(publicKeyFilePath); ServiceAsymmetricKeysHolder.getInstance().setPrivateKeyFilePath(privateKeyFilePath); - AuthorizationPlugin authorizationPlugin = PluginInstantiator.getAuthorizationPlugin(); + AuthorizationPlugin authorizationPlugin = PluginInstantiator.getAuthorizationPlugin(); MembershipService membershipService = PluginInstantiator.getMembershipService(); ApplicationFacade.getInstance().setMembershipService(membershipService); diff --git a/src/main/java/cloud/fogbow/ms/core/ApplicationFacade.java b/src/main/java/cloud/fogbow/ms/core/ApplicationFacade.java index 8fbaece..2d1af59 100644 --- a/src/main/java/cloud/fogbow/ms/core/ApplicationFacade.java +++ b/src/main/java/cloud/fogbow/ms/core/ApplicationFacade.java @@ -17,7 +17,7 @@ import cloud.fogbow.common.util.ServiceAsymmetricKeysHolder; import cloud.fogbow.ms.constants.ConfigurationPropertyKeys; import cloud.fogbow.ms.constants.Messages; -import cloud.fogbow.ms.core.authorization.AdminOperation; +import cloud.fogbow.ms.core.authorization.MsOperation; // TODO add tests public class ApplicationFacade { @@ -26,7 +26,7 @@ public class ApplicationFacade { private static ApplicationFacade instance; private MembershipService membershipService; - private AuthorizationPlugin authorizationPlugin; + private AuthorizationPlugin authorizationPlugin; private long onGoingRequests; private boolean reloading; @@ -90,7 +90,7 @@ public MembershipService getMembershipService() { return membershipService; } - public void setAuthorizationPlugin(AuthorizationPlugin authorizationPlugin) { + public void setAuthorizationPlugin(AuthorizationPlugin authorizationPlugin) { this.authorizationPlugin = authorizationPlugin; } @@ -99,7 +99,7 @@ public void addProvider(String userToken, String provider) throws FogbowExceptio RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); setAsReloading(); @@ -115,7 +115,7 @@ public void removeProvider(String userToken, String provider) throws FogbowExcep RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); setAsReloading(); @@ -131,7 +131,7 @@ public void addTargetProvider(String userToken, String provider) throws FogbowEx RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); setAsReloading(); @@ -148,7 +148,7 @@ public void addRequesterProvider(String userToken, String provider) throws Fogbo RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); setAsReloading(); @@ -165,7 +165,7 @@ public void removeTargetProvider(String userToken, String provider) throws Fogbo RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); setAsReloading(); @@ -181,7 +181,7 @@ public void removeRequesterProvider(String userToken, String provider) throws Fo RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); setAsReloading(); @@ -198,7 +198,7 @@ public void reload(String userToken) throws FogbowException { RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); doReload(); } @@ -239,7 +239,7 @@ private void doReload() throws ConfigurationErrorException { public void updateMembershipService(String userToken, String className) throws FogbowException { RSAPublicKey asPublicKey = MSPublicKeysHolder.getInstance().getAsPublicKey(); SystemUser systemUser = AuthenticationUtil.authenticate(asPublicKey, userToken); - this.authorizationPlugin.isAuthorized(systemUser, new AdminOperation()); + this.authorizationPlugin.isAuthorized(systemUser, new MsOperation()); setAsReloading(); diff --git a/src/main/java/cloud/fogbow/ms/core/PluginInstantiator.java b/src/main/java/cloud/fogbow/ms/core/PluginInstantiator.java index 8ccc070..251f7ee 100644 --- a/src/main/java/cloud/fogbow/ms/core/PluginInstantiator.java +++ b/src/main/java/cloud/fogbow/ms/core/PluginInstantiator.java @@ -4,7 +4,7 @@ import cloud.fogbow.common.plugins.authorization.AuthorizationPlugin; import cloud.fogbow.ms.constants.ConfigurationPropertyKeys; import cloud.fogbow.ms.core.authorization.AdminAuthorizationPlugin; -import cloud.fogbow.ms.core.authorization.AdminOperation; +import cloud.fogbow.ms.core.authorization.MsOperation; import cloud.fogbow.ms.core.service.AllowList; public class PluginInstantiator { @@ -19,7 +19,7 @@ public static MembershipService getMembershipService() throws ConfigurationError } } - public static AuthorizationPlugin getAuthorizationPlugin() throws ConfigurationErrorException { + public static AuthorizationPlugin getAuthorizationPlugin() throws ConfigurationErrorException { if (PropertiesHolder.getInstance().getProperties().containsKey(ConfigurationPropertyKeys.AUTHORIZATION_PLUGIN_CLASS_KEY)) { String className = PropertiesHolder.getInstance().getProperty(ConfigurationPropertyKeys.AUTHORIZATION_PLUGIN_CLASS_KEY); return getAuthorizationPlugin(className); @@ -28,8 +28,8 @@ public static AuthorizationPlugin getAuthorizationPlugin() throw } } - public static AuthorizationPlugin getAuthorizationPlugin(String className) { - return (AuthorizationPlugin) PluginInstantiator.classFactory.createPluginInstance(className); + public static AuthorizationPlugin getAuthorizationPlugin(String className) { + return (AuthorizationPlugin) PluginInstantiator.classFactory.createPluginInstance(className); } public static MembershipService getMembershipService(String className) { diff --git a/src/main/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPlugin.java b/src/main/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPlugin.java index a006473..1ca1857 100644 --- a/src/main/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPlugin.java +++ b/src/main/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPlugin.java @@ -11,7 +11,7 @@ import cloud.fogbow.ms.constants.Messages; import cloud.fogbow.ms.core.PropertiesHolder; -public class AdminAuthorizationPlugin implements AuthorizationPlugin { +public class AdminAuthorizationPlugin implements AuthorizationPlugin { private static final String SEPARATOR = ","; private Set adminsIds; @@ -31,7 +31,7 @@ public AdminAuthorizationPlugin() throws ConfigurationErrorException { @Override - public boolean isAuthorized(SystemUser systemUser, AdminOperation operation) throws UnauthorizedRequestException { + public boolean isAuthorized(SystemUser systemUser, MsOperation operation) throws UnauthorizedRequestException { String userId = systemUser.getId(); if (!adminsIds.contains(userId)) { diff --git a/src/main/java/cloud/fogbow/ms/core/authorization/AdminOperation.java b/src/main/java/cloud/fogbow/ms/core/authorization/MsOperation.java similarity index 75% rename from src/main/java/cloud/fogbow/ms/core/authorization/AdminOperation.java rename to src/main/java/cloud/fogbow/ms/core/authorization/MsOperation.java index 3fe696f..f2c8c86 100644 --- a/src/main/java/cloud/fogbow/ms/core/authorization/AdminOperation.java +++ b/src/main/java/cloud/fogbow/ms/core/authorization/MsOperation.java @@ -2,7 +2,7 @@ import cloud.fogbow.common.models.FogbowOperation; -public class AdminOperation extends FogbowOperation { +public class MsOperation extends FogbowOperation { @Override public boolean equals(Object o) { diff --git a/src/test/java/cloud/fogbow/ms/core/ApplicationFacadeTest.java b/src/test/java/cloud/fogbow/ms/core/ApplicationFacadeTest.java index 1208f54..7c83830 100644 --- a/src/test/java/cloud/fogbow/ms/core/ApplicationFacadeTest.java +++ b/src/test/java/cloud/fogbow/ms/core/ApplicationFacadeTest.java @@ -24,7 +24,7 @@ import cloud.fogbow.common.util.PublicKeysHolder; import cloud.fogbow.ms.constants.ConfigurationPropertyKeys; import cloud.fogbow.ms.core.authorization.AdminAuthorizationPlugin; -import cloud.fogbow.ms.core.authorization.AdminOperation; +import cloud.fogbow.ms.core.authorization.MsOperation; @RunWith(PowerMockRunner.class) @PrepareForTest({AuthenticationUtil.class, MSPublicKeysHolder.class, @@ -34,7 +34,7 @@ public class ApplicationFacadeTest { private ApplicationFacade facade; private MembershipService membershipService; - private AuthorizationPlugin authorizationPlugin; + private AuthorizationPlugin authorizationPlugin; private String member1 = "member1"; private String member2 = "member2"; private List members = Arrays.asList(member1, member2); @@ -48,12 +48,12 @@ public class ApplicationFacadeTest { private SystemUser systemUser; private RSAPublicKey key; - private AdminOperation operation; + private MsOperation operation; private PropertiesHolder propertiesHolder; @Before public void setUp() throws FogbowException { - this.operation = new AdminOperation(); + this.operation = new MsOperation(); this.systemUser = new SystemUser(userId, userName, provider); // authentication diff --git a/src/test/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPluginTest.java b/src/test/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPluginTest.java index 92262de..d9370d8 100644 --- a/src/test/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPluginTest.java +++ b/src/test/java/cloud/fogbow/ms/core/authorization/AdminAuthorizationPluginTest.java @@ -21,7 +21,7 @@ @PrepareForTest({PropertiesHolder.class}) public class AdminAuthorizationPluginTest { - private AuthorizationPlugin plugin; + private AuthorizationPlugin plugin; private final String userIdAdmin1 = "userIdAdmin1"; private final String userNameAdmin1 = "userNameAdmin1"; private final String userIdAdmin2 = "userIdAdmin2"; @@ -39,7 +39,7 @@ public void testIsAuthorizedUserIsAdmin() throws UnauthorizedRequestException, C SystemUser admin1 = new SystemUser(userIdAdmin1, userNameAdmin1, identityProviderId); SystemUser admin2 = new SystemUser(userIdAdmin2, userNameAdmin2, identityProviderId); - AdminOperation operation = new AdminOperation(); + MsOperation operation = new MsOperation(); plugin = new AdminAuthorizationPlugin(); @@ -54,7 +54,7 @@ public void testIsAuthorizedUserIsNotAdmin() throws UnauthorizedRequestException setUpConfiguration(); SystemUser notAdmin = new SystemUser(userIdNotAdmin, userNameNotAdmin, identityProviderId); - AdminOperation operation = new AdminOperation(); + MsOperation operation = new MsOperation(); plugin = new AdminAuthorizationPlugin();