Call a private method in Spring @PreAuthorize

前端 未结 2 1117
一个人的身影
一个人的身影 2021-02-04 04:30

I am using Spring Security for permission checking on methods. I would like to call a private method to collect some data to send to hasPermission() method. Followi

2条回答
  •  悲&欢浪女
    2021-02-04 05:21

    Private methods cannot be called, but you can refer to "this component" through this.:

    @PreAuthorize("hasPermission(new Object[]{#arg3, /* HERE: */ this.localPublicMethod(#arg1,#arg2)}, 'canDoThis')")   
    public long publicMethod1(long arg1, long arg2, long arg3)
    {
    }
    
    public String localPublicMethod(long a1, long a2)
    {
    }
    

提交回复
热议问题