use of io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails in project gravitee-management-rest-api by gravitee-io.
the class AuthenticationFailureListener method onApplicationEvent.
@Override
public void onApplicationEvent(AbstractAuthenticationFailureEvent e) {
GraviteeAuthenticationDetails auth = (GraviteeAuthenticationDetails) e.getAuthentication().getDetails();
LOGGER.warn("Authentication failed event for: " + e.getAuthentication().getPrincipal() + " - IP: " + auth.getRemoteAddress());
}
use of io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails in project gravitee-management-rest-api by gravitee-io.
the class GraviteeAuthenticationDetailsTest method shouldGetCorrectIPWhenProxyRequest.
@Test
public void shouldGetCorrectIPWhenProxyRequest() {
when(httpServletRequest.getHeader("X-Forwarded-For")).thenReturn("CORRECT_IP,PROXY_IP");
when(httpServletRequest.getRemoteAddr()).thenReturn("PROXY_IP");
GraviteeAuthenticationDetails authenticationDetails = new GraviteeAuthenticationDetails(httpServletRequest);
assertEquals("CORRECT_IP", authenticationDetails.getRemoteAddress());
}
Aggregations