Skip to content

Commit

Permalink
Changed AdminOperation class name to MsOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
armstrongmsg committed Dec 21, 2020
1 parent 8d409b9 commit 9d223d4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/main/java/cloud/fogbow/ms/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,7 +28,7 @@ public void run(ApplicationArguments args) throws ConfigurationErrorException {
ServiceAsymmetricKeysHolder.getInstance().setPublicKeyFilePath(publicKeyFilePath);
ServiceAsymmetricKeysHolder.getInstance().setPrivateKeyFilePath(privateKeyFilePath);

AuthorizationPlugin<AdminOperation> authorizationPlugin = PluginInstantiator.getAuthorizationPlugin();
AuthorizationPlugin<MsOperation> authorizationPlugin = PluginInstantiator.getAuthorizationPlugin();
MembershipService membershipService = PluginInstantiator.getMembershipService();

ApplicationFacade.getInstance().setMembershipService(membershipService);
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/cloud/fogbow/ms/core/ApplicationFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -26,7 +26,7 @@ public class ApplicationFacade {

private static ApplicationFacade instance;
private MembershipService membershipService;
private AuthorizationPlugin<AdminOperation> authorizationPlugin;
private AuthorizationPlugin<MsOperation> authorizationPlugin;
private long onGoingRequests;
private boolean reloading;

Expand Down Expand Up @@ -90,7 +90,7 @@ public MembershipService getMembershipService() {
return membershipService;
}

public void setAuthorizationPlugin(AuthorizationPlugin<AdminOperation> authorizationPlugin) {
public void setAuthorizationPlugin(AuthorizationPlugin<MsOperation> authorizationPlugin) {
this.authorizationPlugin = authorizationPlugin;
}

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();
}
Expand Down Expand Up @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/cloud/fogbow/ms/core/PluginInstantiator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -19,7 +19,7 @@ public static MembershipService getMembershipService() throws ConfigurationError
}
}

public static AuthorizationPlugin<AdminOperation> getAuthorizationPlugin() throws ConfigurationErrorException {
public static AuthorizationPlugin<MsOperation> 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);
Expand All @@ -28,8 +28,8 @@ public static AuthorizationPlugin<AdminOperation> getAuthorizationPlugin() throw
}
}

public static AuthorizationPlugin<AdminOperation> getAuthorizationPlugin(String className) {
return (AuthorizationPlugin<AdminOperation>) PluginInstantiator.classFactory.createPluginInstance(className);
public static AuthorizationPlugin<MsOperation> getAuthorizationPlugin(String className) {
return (AuthorizationPlugin<MsOperation>) PluginInstantiator.classFactory.createPluginInstance(className);
}

public static MembershipService getMembershipService(String className) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import cloud.fogbow.ms.constants.Messages;
import cloud.fogbow.ms.core.PropertiesHolder;

public class AdminAuthorizationPlugin implements AuthorizationPlugin<AdminOperation> {
public class AdminAuthorizationPlugin implements AuthorizationPlugin<MsOperation> {

private static final String SEPARATOR = ",";
private Set<String> adminsIds;
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/cloud/fogbow/ms/core/ApplicationFacadeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -34,7 +34,7 @@ public class ApplicationFacadeTest {

private ApplicationFacade facade;
private MembershipService membershipService;
private AuthorizationPlugin<AdminOperation> authorizationPlugin;
private AuthorizationPlugin<MsOperation> authorizationPlugin;
private String member1 = "member1";
private String member2 = "member2";
private List<String> members = Arrays.asList(member1, member2);
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@PrepareForTest({PropertiesHolder.class})
public class AdminAuthorizationPluginTest {

private AuthorizationPlugin<AdminOperation> plugin;
private AuthorizationPlugin<MsOperation> plugin;
private final String userIdAdmin1 = "userIdAdmin1";
private final String userNameAdmin1 = "userNameAdmin1";
private final String userIdAdmin2 = "userIdAdmin2";
Expand All @@ -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();

Expand All @@ -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();

Expand Down

0 comments on commit 9d223d4

Please sign in to comment.