can use @preauthorize on annotations?
in spring can use annotations component , dependson in annotations, this:
@target(elementtype.type) @component @dependson(coreinitializerconfig.role_initializer_id) public @interface webcomponent { } and works well. when try use preauthorize same way:
@target( { elementtype.type, elementtype.method }) @component @preauthorize("hasauthority('perm_read_settings')") public @interface settingsauthorized { } isnt working, tried in mvc controller pojo , in bean's method , didn't work, had put explicitly:
@controller @preauthorize("hasauthority('perm_read_settings')") public class settingscontroller { ... }
i solved problema adding @retention(retentionpolicy.runtime) recommended add @documented , @inherited final annotation, resulted:
@target( { elementtype.type, elementtype.method }) @component @retention(retentionpolicy.runtime) @inherited @documented @preauthorize("hasauthority('perm_read_settings')") public @interface settingsauthorized { }
Comments
Post a Comment