diff options
Diffstat (limited to 'juick-spring-www/src')
-rw-r--r-- | juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java index 3753a4aa..95a94642 100644 --- a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java +++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java @@ -1,8 +1,7 @@ package com.juick.www.configuration; import com.juick.service.UserService; -import com.juick.server.security.entities.JuickUser; -import org.apache.commons.lang3.StringUtils; +import com.juick.service.security.JuickUserDetailsService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; @@ -10,7 +9,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; import javax.annotation.Resource; @@ -32,17 +30,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Bean("userDetailsService") @Override public UserDetailsService userDetailsServiceBean() throws Exception { - return username -> { - if (StringUtils.isBlank(username)) - throw new UsernameNotFoundException("Invalid user name " + username); - - com.juick.User user = userService.getUserByName(username); - - if (user != null) - return new JuickUser(user); - - throw new UsernameNotFoundException("The username " + username + " is not found"); - }; + return new JuickUserDetailsService(userService); } @Override |