fixes - spelling and security work

This commit is contained in:
eugenp 2015-12-21 11:53:17 +02:00 committed by David Morley
parent cb083e23c8
commit 8c7962a3f7
2 changed files with 4 additions and 8 deletions

View File

@ -149,7 +149,7 @@ public class GuavaCollectionTypesTest {
}
@Test
public void whenCalculatingSetSymetricDifference_thenCorrect() {
public void whenCalculatingSetSymmetricDifference_thenCorrect() {
final Set<Character> first = ImmutableSet.of('a', 'b', 'c');
final Set<Character> second = ImmutableSet.of('b', 'c', 'd');

View File

@ -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];
}
}