Search in sources :

Example 1 with AllowedRoles

use of org.togetherjava.tjbot.logwatcher.accesscontrol.AllowedRoles in project TJ-Bot by Together-Java.

the class MainLayout method checkAccess.

private boolean checkAccess(MenuItemInfo menuItemInfo) {
    final Class<? extends Component> view = menuItemInfo.view;
    final AllowedRoles annotation = view.getAnnotation(AllowedRoles.class);
    if (annotation == null) {
        logger.warn("Class {} not properly secured with Annotation", view);
        return false;
    }
    final Set<Role> roles = Set.of(annotation.roles());
    return !Sets.intersection(this.authenticatedUser.getRoles(), roles).isEmpty();
}
Also used : Role(org.togetherjava.tjbot.logwatcher.accesscontrol.Role) AllowedRoles(org.togetherjava.tjbot.logwatcher.accesscontrol.AllowedRoles)

Aggregations

AllowedRoles (org.togetherjava.tjbot.logwatcher.accesscontrol.AllowedRoles)1 Role (org.togetherjava.tjbot.logwatcher.accesscontrol.Role)1