Commit 8113e8e8 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

fixed supports method of LDAP provider and ordered providers

parent 92ca8dee
......@@ -7,6 +7,7 @@ import lcsb.mapviewer.services.UserDTO;
import lcsb.mapviewer.services.interfaces.ILdapService;
import lcsb.mapviewer.services.interfaces.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
......@@ -18,6 +19,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@Order(2)
@Service
public class LdapAuthenticationProvider implements AuthenticationProvider {
......@@ -69,14 +71,7 @@ public class LdapAuthenticationProvider implements AuthenticationProvider {
@Override
public boolean supports(Class<?> authentication) {
if (authentication == null
|| authentication.getName().isEmpty()
|| !UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication)
|| authentication.getName().equals(Configuration.ANONYMOUS_LOGIN)) {
return false;
}
User user = userService.getUserByLogin(authentication.getName());
return user == null || user.isConnectedToLdap();
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
}
private void createLocalUser(Authentication authentication) {
......
package lcsb.mapviewer.web.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.Authentication;
......@@ -11,6 +12,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@Order(1)
@Service
public class LocalAuthenticationProvider implements AuthenticationProvider {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment