@Override
public FeatureUser getCurrentUser() {
SecurityContext context = SecurityContextHolder.getContext();
Authentication authentication = context.getAuthentication();
// null if no authentication data is available for the current thread
if (authentication != null) {
String name = null;
// try to obtain the name of thie user
Object principal = authentication.getPrincipal();
if (principal instanceof UserDetails) {
UserDetails userDetails = (UserDetails) principal;
name = userDetails.getUsername();
} else {
name = principal.toString();
}
Set<String> authorities = AuthorityUtils.authorityListToSet(authentication.getAuthorities());
// check for the authority for feature admins
boolean featureAdmin = false;
if (featureAdminAuthority != null) {
featureAdmin = authorities.contains(featureAdminAuthority);