public class AccessControl {
private UserAccessControl user;
+ private GeneralAccessControl general;
protected LoggerWrapper logger = new LoggerWrapper("Global.AccessControl");
protected MirPropertiesConfiguration configuration;
configuration = MirPropertiesConfiguration.instance();
user = new UserAccessControl(configuration.getVector("AccessControl.SuperUsers"));
+ general = new GeneralAccessControl();
}
catch (Throwable t) {
throw new RuntimeException(t.toString());
return user;
}
+ public GeneralAccessControl general() {
+ return general;
+ }
+
+ public class GeneralAccessControl {
+ public boolean mayDeleteArticles(EntityUsers aSubject) {
+ return configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1");
+ }
+
+ public void assertMayDeleteArticles(EntityUsers aSubject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayDeleteArticles(aSubject))
+ throw new AuthorizationExc("not allowed to delete articles");
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+ }
+
+ public boolean mayDeleteComments(EntityUsers aSubject) {
+ return configuration.getString("Mir.Localizer.Admin.AllowDeleteComment", "0").equals("1");
+ }
+
+ public void assertMayDeleteComments(EntityUsers aSubject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayDeleteArticles(aSubject))
+ throw new AuthorizationExc("not allowed to delete comments");
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+ }
+ }
+
public class UserAccessControl {
private List superusers;
catch (Throwable t) {
throw new AuthorizationFailure(t);
}
-
}
-
}
}