From 8c7962a3f7674a0b3aa9703ae7b12b4b3fda03bc Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 21 Dec 2015 11:53:17 +0200 Subject: [PATCH] fixes - spelling and security work --- .../org/baeldung/guava/GuavaCollectionTypesTest.java | 2 +- .../org/baeldung/security/MyUserDetailsService.java | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java index 2eb5141f8d..9c38afbcc2 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java @@ -149,7 +149,7 @@ public class GuavaCollectionTypesTest { } @Test - public void whenCalculatingSetSymetricDifference_thenCorrect() { + public void whenCalculatingSetSymmetricDifference_thenCorrect() { final Set first = ImmutableSet.of('a', 'b', 'c'); final Set second = ImmutableSet.of('b', 'c', 'd'); diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java index 567fa7717d..d4b77878be 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -1,13 +1,11 @@ package org.baeldung.security; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.baeldung.persistence.dao.RoleRepository; import org.baeldung.persistence.dao.UserRepository; import org.baeldung.persistence.model.Privilege; import org.baeldung.persistence.model.Role; @@ -28,9 +26,6 @@ public class MyUserDetailsService implements UserDetailsService { @Autowired private UserRepository userRepository; - @Autowired - private RoleRepository roleRepository; - @Autowired private LoginAttemptService loginAttemptService; @@ -53,7 +48,7 @@ public class MyUserDetailsService implements UserDetailsService { try { final User user = userRepository.findByEmail(email); if (user == null) { - return new org.springframework.security.core.userdetails.User(" ", " ", true, true, true, true, getAuthorities(Arrays.asList(roleRepository.findByName("ROLE_USER")))); + throw new UsernameNotFoundException("No user found with username: " + email); } return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword(), user.isEnabled(), true, true, true, getAuthorities(user.getRoles())); @@ -90,8 +85,9 @@ public class MyUserDetailsService implements UserDetailsService { private String getClientIP() { final String xfHeader = request.getHeader("X-Forwarded-For"); - if (xfHeader == null) + if (xfHeader == null) { return request.getRemoteAddr(); + } return xfHeader.split(",")[0]; } }