Search in sources :

Example 6 with GraviteeAuthenticationDetails

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());
}
Also used : GraviteeAuthenticationDetails(io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails)

Example 7 with GraviteeAuthenticationDetails

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());
}
Also used : GraviteeAuthenticationDetails(io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails) Test(org.junit.Test)

Aggregations

GraviteeAuthenticationDetails (io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails)7 Test (org.junit.Test)6 HashMap (java.util.HashMap)1 HttpSession (javax.servlet.http.HttpSession)1 WebAuthenticationDetails (org.springframework.security.web.authentication.WebAuthenticationDetails)1