public static String getRoleType() { MyUser myUser = getMyUser(); if (myUser != null && myUser.getId() != null) { return myUser.getRole().getBasicType(); } else { return ""; } }
public static User getUser() { SecurityContext securityContext = SecurityContextHolder.getContext(); Authentication authentication = securityContext.getAuthentication(); MyUser myUser = (MyUser) authentication.getPrincipal(); User user = new User(); user.setId(myUser.getId()); user.setName(myUser.getName()); user.setUsername(myUser.getUsername()); return user; }