Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Retrieve User information in Spring Security

@Controller
public class GetUserWithCustomInterfaceController {
    @Autowired
    private IAuthenticationFacade authenticationFacade;

    @RequestMapping(value = "/username", method = RequestMethod.GET)
    @ResponseBody
    public String currentUserNameSimple() {
        Authentication authentication = authenticationFacade.getAuthentication();
        return authentication.getName();
    }
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #Retrieve #User #information #Spring #Security
ADD COMMENT
Topic
Name
4+4 =