java - 如何创建实现 PreAuthorize 的接口注释,该注释使用来自接口的值
问题描述
我创建了自己的实现@PreAuthorize
注释的灵活权限接口
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("@securityService.hasPermission(authentication.principal, " + "@HasUserPermission.firstType(), " + "@HasUserPermission.secondType()")
public @interface HasUserPermission {
String firstType() default "";
String secondType() default "";
}
我希望这hasPermission
将使用firstType()
和的secondType()
值@interface
来调用“hasPermission”,但不要什么都不做,而且我没有为我的问题找到任何解决方案或想法。我怎样才能通过firstType()
和secondType()
到@PreAuthorize
?可能吗 ?
解决方案
推荐阅读
- javascript - 使用 w3schools 中可用的代码块为 asp 链接中的活动链接着色
- android - 有人可以解释一下我在这个滚动功能上做错了什么吗?
- ios - UIDatePicker:在选择日期时,它会跳转到任何随机日期
- javascript - 如何在主页中激活 Woocommerce 过滤器脚本
- reactjs - 如何仅在提交表单后而不是在用户输入 antd 时显示错误或验证消息?
- python - 在数据框中找到均值的更有效方法?
- ansible - 如何使用 ansible playbook 更改 Sonatype Nexus 的管理员密码
- .net - 我如何使用我的演示用户和密码通过链接自动登录?
- reactjs - 尝试正确输入提供程序
- swiftui - 如何在 SwiftUI 中使用 UIMotionEffect?