How can get and show username, email, ip etc. of User which got below result in${pageContext.request.userPrincipal}
?
org.springframework.security.authentication.UsernamePasswordAuthenticationToken@e40cde0e: Principal: User [username=admin, email=olga@vantalii.ru, password=1234, firstName=Olga, lastName=OZCAN, authorities=[Role [name=USER_ROLE, privileges=null]], accountNonExpired=true, accountNonLocked=true, credentialsNonExpired=true, enabled=true]; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@2cd90: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: B91578060B48D46CC606AF8281757727; Granted Authorities: Role [name=USER_ROLE, privileges=null]
You should use Spring Security JSP tags.
First declare the correct taglib:
and then use the following code to display for example the email of the current user.
You can substitute email for any property of your principal object (username, firstName, etc.).
More information about Spring Security JSP tags can be found in the documentation:
http://docs.spring.io/spring-security/site/docs/3.0.x/reference/taglibs.html