public static Collection<String> collectRoles(Method method) { List<String> roles = new ArrayList<>(); roles.addAll(collectRoles(method.getAnnotation(RequireRoles.class))); if (method.isAnnotationPresent(RequireRole.class)) { roles.add(method.getAnnotation(RequireRole.class).value()); } roles.addAll(collectRoles(method.getDeclaringClass().getAnnotation(RequireRoles.class))); if (method.getDeclaringClass().isAnnotationPresent(RequireRole.class)) { roles.add(method.getDeclaringClass().getAnnotation(RequireRole.class).value()); } return roles; }
protected void checkRequireRoles(Account account, Method method) { Collection<String> roles = SecurityUtil.collectRoles(method); if (!roles.isEmpty()) { account.checkRoles(roles); } }
protected void checkRequireRoles(Account account, Method method) { Collection<String> roles = SecurityUtil.collectRoles(method); if (!roles.isEmpty()) { account.checkRoles(roles); } }
public static Collection<String> collectRoles(Method method) { List<String> roles = new ArrayList<>(); roles.addAll(collectRoles(method.getAnnotation(RequireRoles.class))); if (method.isAnnotationPresent(RequireRole.class)) { roles.add(method.getAnnotation(RequireRole.class).value()); } roles.addAll(collectRoles(method.getDeclaringClass().getAnnotation(RequireRoles.class))); if (method.getDeclaringClass().isAnnotationPresent(RequireRole.class)) { roles.add(method.getDeclaringClass().getAnnotation(RequireRole.class).value()); } return roles; }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Collection<String> roles = SecurityUtil.collectRoles(invocation.getMethod()); Account account = getAccount(); account.checkRoles(roles); return invocation.proceed(); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Collection<String> roles = SecurityUtil.collectRoles(invocation.getMethod()); Account account = getAccount(); account.checkRoles(roles); return invocation.proceed(); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Collection<String> roles = SecurityUtil.collectRoles(invocation.getMethod()); Account account = getAccount(); account.checkRoles(roles); return invocation.proceed(); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Collection<String> roles = SecurityUtil.collectRoles(invocation.getMethod()); Account account = getAccount(); account.checkRoles(roles); return invocation.proceed(); }