use of org.togglz.core.user.UserProvider in project ORCID-Source by ORCID.
the class OrcidTogglzConfiguration method getUserProvider.
@Override
public UserProvider getUserProvider() {
return new UserProvider() {
@Override
public FeatureUser getCurrentUser() {
boolean isAdmin = false;
String userOrcid = null;
SecurityContext context = SecurityContextHolder.getContext();
if (context != null && context.getAuthentication() != null) {
Authentication authentication = context.getAuthentication();
if (authentication != null) {
Object principal = authentication.getPrincipal();
if (principal instanceof OrcidProfileUserDetails) {
OrcidProfileUserDetails userDetails = (OrcidProfileUserDetails) principal;
isAdmin = OrcidType.ADMIN.equals(userDetails.getOrcidType());
userOrcid = userDetails.getOrcid();
}
}
}
return new SimpleFeatureUser(userOrcid, isAdmin);
}
};
}
Aggregations