UserDeatilsService is another core interface in the Spring Security framework that is used to retrieve data related to the user. This obtained information is stored in UserDeatils, which represents the principal. We can get the user information as shown in the following lines of code:
if(appl_principal instance of UserDetails) { String username=((UserDeatils)app_principal).getUsername(); }
How will we get the information about which role the users are holding? GrantedAuthority is the answer.