首页 > 解决方案 > 如何创建实现 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?可能吗 ?

标签: javaspringspring-bootspring-security

解决方案


推荐阅读