You can obtain the IP Address a user logged in using:
Code:
// Obtain the current Authentication. Depending on where you do this, you you might get it
// from the SecurityContext or an argument to a SS interface
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// authentication may be null
WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails();
String remoteAddress = details.getRemoteAddress();
If you want the current HttpServletRequest which contains the current IP information you can use Spring Web's RequestContextHolder. First plugin the RequestContextListener into your web.xml so that the RequestContextHolder is populated. Then you can access the current HttpServletRequest using
Code:
ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attrs.getRequest();