Code example for Method

Methods: getAnnotation, isAnnotationPresent

0
 
      String[] rolesAllowed = null;
      boolean denyAll;
      boolean permitAll;
      RolesAllowed allowed = (RolesAllowed) declaring.getAnnotation(RolesAllowed.class);
      RolesAllowed methodAllowed = method.getAnnotation(RolesAllowed.class);
      if (methodAllowed != null) allowed = methodAllowed;
      if (allowed != null)
      { 
         rolesAllowed = allowed.value();
      } 
 
      denyAll = (declaring.isAnnotationPresent(DenyAll.class)
              && method.isAnnotationPresent(RolesAllowed.class) == false
              && method.isAnnotationPresent(PermitAll.class) == false) || method.isAnnotationPresent(DenyAll.class);
 
      permitAll = (declaring.isAnnotationPresent(PermitAll.class) == true
              && method.isAnnotationPresent(RolesAllowed.class) == false
              && method.isAnnotationPresent(DenyAll.class) == false) || method.isAnnotationPresent(PermitAll.class);
 
      if (rolesAllowed != null || denyAll || permitAll)
      { 
         RoleBasedSecurityFilter filter = new RoleBasedSecurityFilter(rolesAllowed, denyAll, permitAll);
         configurable.register(filter);