Skip to content

Commit

Permalink
updated role restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbw committed Jan 18, 2017
1 parent 94ccb01 commit 06713d5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package uk.ac.ox.it.ords.security.services;

import uk.ac.ox.it.ords.security.services.impl.RestrictionsServiceImpl;

public interface RestrictionsService {

public abstract int getMaximumUploadSize();
Expand All @@ -10,4 +12,15 @@ public interface RestrictionsService {

public abstract int getMqxiumumDatasetsPerDatabase();

public static class Factory{

static RestrictionsService provider;

public static RestrictionsService getInstance(){
if (provider == null) provider = new RestrictionsServiceImpl();
return provider;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,41 @@ public class RestrictionsServiceImpl implements RestrictionsService {

@Override
public int getMaximumUploadSize() {
if (SecurityUtils.getSubject().hasRole("PremiumUser")) return 25000;
if (SecurityUtils.getSubject().hasRole("StandardUser")) return 1000;
if (SecurityUtils.getSubject().hasRole("BasicUser")) return 16;
if (SecurityUtils.getSubject().hasRole("User")) return 1;
if (SecurityUtils.getSubject().hasRole("administrator")) return 25000;
if (SecurityUtils.getSubject().hasRole("premiumuser")) return 25000;
if (SecurityUtils.getSubject().hasRole("standarduser")) return 1000;
if (SecurityUtils.getSubject().hasRole("basicuser")) return 16;
if (SecurityUtils.getSubject().hasRole("user") || SecurityUtils.getSubject().hasRole("localuser")) return 1;
return 0;
}

@Override
public int getMaximumNumberOfLiveProjects() {
if (SecurityUtils.getSubject().hasRole("PremiumUser")) return 9999;
if (SecurityUtils.getSubject().hasRole("StandardUser")) return 9999;
if (SecurityUtils.getSubject().hasRole("BasicUser")) return 3;
if (SecurityUtils.getSubject().hasRole("User")) return 1;
if (SecurityUtils.getSubject().hasRole("administrator")) return 9999;
if (SecurityUtils.getSubject().hasRole("premiumuser")) return 9999;
if (SecurityUtils.getSubject().hasRole("standarduser")) return 9999;
if (SecurityUtils.getSubject().hasRole("basicuser")) return 3;
if (SecurityUtils.getSubject().hasRole("user") || SecurityUtils.getSubject().hasRole("localuser")) return 1;
return 0;
}

@Override
public int getMaximumDatabasesPerProject() {
if (SecurityUtils.getSubject().hasRole("PremiumUser")) return 9999;
if (SecurityUtils.getSubject().hasRole("StandardUser")) return 3;
if (SecurityUtils.getSubject().hasRole("BasicUser")) return 3;
if (SecurityUtils.getSubject().hasRole("User")) return 3;
if (SecurityUtils.getSubject().hasRole("administrator")) return 9999;
if (SecurityUtils.getSubject().hasRole("premiumuser")) return 9999;
if (SecurityUtils.getSubject().hasRole("standarduser")) return 3;
if (SecurityUtils.getSubject().hasRole("basicuser")) return 3;
if (SecurityUtils.getSubject().hasRole("user") || SecurityUtils.getSubject().hasRole("localuser")) return 3;
return 0;
}

@Override
public int getMqxiumumDatasetsPerDatabase() {
if (SecurityUtils.getSubject().hasRole("PremiumUser")) return 9999;
if (SecurityUtils.getSubject().hasRole("StandardUser")) return 9999;
if (SecurityUtils.getSubject().hasRole("BasicUser")) return 3;
if (SecurityUtils.getSubject().hasRole("User")) return 3;
if (SecurityUtils.getSubject().hasRole("administrator")) return 9999;
if (SecurityUtils.getSubject().hasRole("premiumuser")) return 9999;
if (SecurityUtils.getSubject().hasRole("standarduser")) return 9999;
if (SecurityUtils.getSubject().hasRole("basicuser")) return 3;
if (SecurityUtils.getSubject().hasRole("user") || SecurityUtils.getSubject().hasRole("localuser")) return 3;
return 0;
}

Expand Down

0 comments on commit 06713d5

Please sign in to comment.