Thanks for your answer… I put what I used to solve the question:
src/main/java/com/company/APPNAME/app/UserController.java
@RestController
@RequestMapping("/users")
public class UserController {
@Autowired
private DataManager dataManager;
@Autowired
private EntitySerialization entitySerialization;
@Autowired
private CurrentAuthentication currentAuthentication;
@PostMapping("/details")
public String loadAll() {
UserDetails currentUser = currentAuthentication.getUser();
User u = dataManager.load(User.class).query("select u from User u where u.username = ?1 ",currentUser.getUsername()).fetchPlan("user-full").one();
Authentication authentication = currentAuthentication.getAuthentication();
Locale locale = currentAuthentication.getLocale();
TimeZone timeZone = currentAuthentication.getTimeZone();
JSONObject jo = new JSONObject();
jo.put("User", u);
jo.put("Authentication", authentication);
jo.put("Roles", getRoleNames(authentication).split(","));
return entitySerialization.toJson(jo,
null,
EntitySerializationOption.DO_NOT_SERIALIZE_DENIED_PROPERTY);
}
private String getRoleNames(Authentication authentication) {
GrantedAuthority grantedAuthority;
return authentication.getAuthorities().stream()
.map(GrantedAuthority::getAuthority)
.collect(Collectors.joining(","));
}
}