for (Annotation annotation : method.getAnnotations())
{
if (annotation.annotationType().isAnnotationPresent(PermissionCheck.class))
{
PermissionCheck permissionCheck = annotation.annotationType().getAnnotation(
PermissionCheck.class);
Method valueMethod = null;
for (Method m : annotation.annotationType().getDeclaredMethods())
{
valueMethod = m;
break;
}
if (valueMethod != null)
{
if (restriction == null) restriction = new Restriction();
Object target = valueMethod.invoke(annotation);
if (!target.equals(void.class))
{
if (restriction == null) restriction = new Restriction();
restriction.addMethodRestriction(target,
getPermissionAction(permissionCheck, annotation));
}
}
}
if (annotation.annotationType().isAnnotationPresent(RoleCheck.class))
{
if (restriction == null) restriction = new Restriction();
restriction.addRoleRestriction(annotation.annotationType().getSimpleName().toLowerCase());
}
}
for (int i = 0; i < method.getParameterAnnotations().length; i++)
{
Annotation[] annotations = method.getParameterAnnotations()[i];
for (Annotation annotation : annotations)
{
if (annotation.annotationType().isAnnotationPresent(PermissionCheck.class))
{
PermissionCheck permissionCheck = annotation.annotationType().getAnnotation(
PermissionCheck.class);
if (restriction == null) restriction = new Restriction();
restriction.addParameterRestriction(i,
getPermissionAction(permissionCheck, annotation));
}