I'm trying to produce complex role model using custom annotation. I have service roles: ADMIN, EMPLOYEE, ACCOUNTANT And custom roles: 1_GET_DICTIONARIES, 2_WRITE_DICTIONARIES and so on...
I've read a good example of custom annotation:
@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("hasAuthority(#serviceRoles) " + || hasAuthority(#customerRoles")
public @interface IsAuthenticatedByServiceAndCustomRoles {
[]String serviceRoles;
[]String customRoles;
}
i need to annotate a controlelr with my annotation and pass two []String parameters to annotation, to be like this:
@IsAuthenticatedByServiceAndCustomRoles(
serviceRoles = ['ADMIN', 'EMPLOYEE'],
customRoles = "['1_GET_DICTIONARIES', '2_WRITE_DICTIONARIES']")
but i can't properly pass my params to spel expression... And the second problem, that i pass array to hasAuthority(), but it accepts single String role...
I don't understand how can i do this... Could anyone help me? please?