DuracloudAuthProvider extends DaoAuthenticationProvider { @Override protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { super.additionalAuthenticationChecks(userDetails, authentication); DuracloudUserDetails dcUserDetails = (DuracloudUserDetails) userDetails; String userIpLimits = dcUserDetails.getIpLimits(); if (null != userIpLimits && !userIpLimits.equals("")) { WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails(); String requestIp = details.getRemoteAddress(); String[] ipLimits = userIpLimits.split(";"); for (String ipLimit : ipLimits) { if (ipInRange(requestIp, ipLimit)) { log.debug("Allowing authentication check to continue for user " + dcUserDetails.getUsername() + " because their IP " + requestIp + " exists in a valid range " + ipLimit); return; } } log.debug("Denying authentication request for user " + dcUserDetails.getUsername() + " because their IP " + requestIp + " does not match any valid ranges " + userIpLimits); throw new InsufficientAuthenticationException( "Originating IP for authentication request" + requestIp + " is not in an accepted range."); } else { log.debug("Allowing authentication check to continue for user " + dcUserDetails.getUsername() + " because no IP limits are defined"); return; } } DuracloudAuthProvider(DuracloudUserDetailsService userDetailsService,
                                 Object passwordEncoder);   }
@Test public void testAdditionalAuthenticationChecks() { assertTrue(testIpAuthChecks("1.2.3.4")); assertTrue(testIpAuthChecks("1.2.5.7")); assertFalse(testIpAuthChecks("1.2.3.5")); assertFalse(testIpAuthChecks("1.2.7.8")); }