我可以将自定义注释参数传递给Spring EL表达式吗?

时间:2015-11-18 15:35:49

标签: java spring spring-security

我有自定义注释,例如:

@AllowedForUserWithID
public myFunction (int userID) {       
}

@PreAuthorize(CustomPermissionEvaluator.isUserWithID(principal, #userID))
public @interface AllowedForUserWithID {
}

public static boolean isUserWithID(UserDetails user, Integer userID) {
}

这些工作正常,我可以使用'#'获取方法参数。

但是,我的目标是注释如下:

@RequiresPermission(feature=SecurityFeature.SETTINGS, rights=AccessRights.WRITE)
public myFunction() {
}

@PreAuthorize(CustomPermissionEvaluator.hasAccessPermission(principal, feature, rights))
public @interface RequiresPermission {
    SecurityFeature feature();
    AccessRights rights();
}

public static boolean hasAccessPermission(UserDetails user, SecurityFeature feature, AccessRights rights) {
}

是否可以通过这种方式将参数传递给表达式?

0 个答案:

没有答案