@Test public void testHandle() { AuthorizationFailureEvent event=mock(AuthorizationFailureEvent.class); WebAuthenticationDetails details=mock(WebAuthenticationDetails.class); Authentication authentication=mock(Authentication.class); AuthenticatedUser user=mock(AuthenticatedUser.class); doReturn(authentication).when(event).getAuthentication(); doReturn(details).when(authentication).getDetails(); doReturn(IP_ADDRESS).when(details).getRemoteAddress(); doReturn(user).when(userContext).getCurrentUser(); doReturn(USER_NAME).when(user).getUsername(); authorizationFailureEventListener.handle(event); verify(eventService).raiseSecurityEvent(any(UnauthorizedAccessAttemptedEvent.class)); verify(userContext).getCurrentUser(); }
@Override public void handle(Object event) { WebAuthenticationDetails details = (WebAuthenticationDetails) ((AuthorizationFailureEvent) event) .getAuthentication().getDetails(); eventService.raiseSecurityEvent(new UnauthorizedAccessAttemptedEvent( details.getRemoteAddress(), userContext.getCurrentUser() .getUsername())); }
AuthorizationFailureEventListener extends EventListener { @Override public void handle(Object event) { WebAuthenticationDetails details = (WebAuthenticationDetails) ((AuthorizationFailureEvent) event) .getAuthentication().getDetails(); eventService.raiseSecurityEvent(new UnauthorizedAccessAttemptedEvent( details.getRemoteAddress(), userContext.getCurrentUser() .getUsername())); } }
AuthorizationFailureEventListener extends EventListener { @Override public void handle(Object event) { WebAuthenticationDetails details = (WebAuthenticationDetails) ((AuthorizationFailureEvent) event) .getAuthentication().getDetails(); eventService.raiseSecurityEvent(new UnauthorizedAccessAttemptedEvent( details.getRemoteAddress(), userContext.getCurrentUser() .getUsername())); } AuthorizationFailureEventListener(EventService eventService,
			UserContext userContext); }
AuthorizationFailureEventListener extends EventListener { @Override public void handle(Object event) { WebAuthenticationDetails details = (WebAuthenticationDetails) ((AuthorizationFailureEvent) event) .getAuthentication().getDetails(); eventService.raiseSecurityEvent(new UnauthorizedAccessAttemptedEvent( details.getRemoteAddress(), userContext.getCurrentUser() .getUsername())); } AuthorizationFailureEventListener(EventService eventService,
			UserContext userContext); @Override boolean canHandle(Object event); @Override void handle(Object event); }
AuthorizationFailureEventListener extends EventListener { @Override public void handle(Object event) { WebAuthenticationDetails details = (WebAuthenticationDetails) ((AuthorizationFailureEvent) event) .getAuthentication().getDetails(); eventService.raiseSecurityEvent(new UnauthorizedAccessAttemptedEvent( details.getRemoteAddress(), userContext.getCurrentUser() .getUsername())); } AuthorizationFailureEventListener(EventService eventService,
			UserContext userContext); @Override boolean canHandle(Object event); @Override void handle(Object event);  }