From bc23d2d2125d2086847397e85335f29a70668f6b Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Mon, 28 Nov 2016 13:39:04 +0700 Subject: remember-me authorization with test; a statndard DaoAuthentication provider used --- .../com/juick/www/configuration/WebSecurityConfig.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'juick-spring-www/src/main/java/com/juick/www/configuration') 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 -- cgit v1.2.3