From 91554cb30eefd48e85ebb744aea0be7efff13e11 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Mon, 28 Nov 2016 19:59:22 +0700 Subject: permit all for /users and /messages; UserService on SimpleRememberMeService replaced by NullUserDetailsService --- .../juick/service/security/NullUserDetailsService.java | 16 ++++++++++++++++ .../juick/service/security/SimpleRememberMeServices.java | 5 ++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 juick-server/src/main/java/com/juick/service/security/NullUserDetailsService.java (limited to 'juick-server/src/main/java') diff --git a/juick-server/src/main/java/com/juick/service/security/NullUserDetailsService.java b/juick-server/src/main/java/com/juick/service/security/NullUserDetailsService.java new file mode 100644 index 000000000..49e9effc9 --- /dev/null +++ b/juick-server/src/main/java/com/juick/service/security/NullUserDetailsService.java @@ -0,0 +1,16 @@ +package com.juick.service.security; + +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; + +/** + * Created by aalexeev on 11/28/16. + */ +public class NullUserDetailsService implements UserDetailsService { + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + throw new UsernameNotFoundException( + "loadUserByUsername called for NullUserDetailsService, user " + username + "can not be found"); + } +} diff --git a/juick-server/src/main/java/com/juick/service/security/SimpleRememberMeServices.java b/juick-server/src/main/java/com/juick/service/security/SimpleRememberMeServices.java index d5d540051..2a28866cd 100644 --- a/juick-server/src/main/java/com/juick/service/security/SimpleRememberMeServices.java +++ b/juick-server/src/main/java/com/juick/service/security/SimpleRememberMeServices.java @@ -8,7 +8,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.core.env.Environment; import org.springframework.security.core.Authentication; import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.web.authentication.RememberMeServices; import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices; @@ -27,8 +26,8 @@ public class SimpleRememberMeServices extends AbstractRememberMeServices impleme private final UserService userService; public SimpleRememberMeServices( - final String key, final UserDetailsService userDetailsService, final UserService userService, final Environment environment) { - super(key, userDetailsService); + final String key, final UserService userService, final Environment environment) { + super(key, new NullUserDetailsService()); Assert.notNull(userService); Assert.notNull(environment); -- cgit v1.2.3