Get java annotation attribute value on Spring SpEL expression -
i need implement authorization expression on multiple controllers. have decided create personalized annotation facilitates use. problem authorization expression requires parameter (an id) can obtained in different ways in each controller.
i put annotation:
@target({elementtype.method, elementtype.type}) @retention(retentionpolicy.runtime) @documented @preauthorize("@authorizationservice.hasadminrole() || ( @authorizationservice.hasparentrole() && @authorizationservice.isyourson(#son) )") public @interface onlyaccessforadminorparentoftheson { string son() default ""; }
the problem not know how value of "son" attribute of annotation use in spel authorization expression.
the notation use follows:
@onlyaccessforadminorparentoftheson(son = "#id") @onlyaccessforadminorparentoftheson(son = "#socialmedia.son")
someone knows how can fix this. in advance.
Comments
Post a Comment