I have a concern when it comes to GrantedAuthority objects in a Spring Security application. I'm looking for a good way to handle things. First of all I'm trying to describe my concern, if there are any factual errors do not hesitate to point them out, I'll only be greatful.
Spring Security uses GrantedAuthority instances to act as tokens of authorization in different parts of the application.
By default a GrantedAuthority may present itself as a String. When methods are secured using *@Secured("ROLE_NAME")*, or URL's are secured using the Spring XML configuration or when the HttpServletRequest request is checked programmatically as in *if(request.isUserInRole("ROLE_NAME")) {..}* it's always the String that you are using to specify the authority which is checked for.
I'm wondering about the implications of using static strings in several places of the application. If a role name is changed the developer has to hunt down all the old strings and update them. There will be no compile time error if a String is missed, only a problem at runtime.
What is the best way according to you when it comes to handling GrantedAuthority objects in a Spring Security application? What pros and cons does your solution have?