public class ExampleController {
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/about_me", method = RequestMethod.GET)
public ModelAndView aboutMe(Principal principal) throws Exception {
CloudsealUserDetails userDetails = (CloudsealUserDetails) ((Authentication) principal).getPrincipal();
StringBuilder builder = new StringBuilder();
builder.append("<p>\n");
Map<String, Object> props = BeanUtils.describe(userDetails);
props.remove("attributes");
props.remove("roles");
props.remove("class");
props.remove("authorities");
props.remove("accountNonExpired");
props.remove("accountNonLocked");
props.remove("credentialsNonExpired");
List<String> keys = asSortedList(props.keySet());
Iterator<String> iterator = keys.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
builder.append("<strong>" + key + ":</strong> " + props.get(key) + "<br />" + "\n");
}
builder.append("</p>\n");
builder.append("<p>\n");
builder.append("<strong>roles:</strong> ");
for (GrantedAuthority role : userDetails.getAuthorities()) {
builder.append(role.getAuthority() + " ");
}
builder.append("</p>\n");
ModelAndView mav = new ModelAndView("protected/about_me");