diff --git a/src/main/java/info/bukova/isspst/security/AuthPopulator.java b/src/main/java/info/bukova/isspst/security/AuthPopulator.java index 21055a64..625635bb 100644 --- a/src/main/java/info/bukova/isspst/security/AuthPopulator.java +++ b/src/main/java/info/bukova/isspst/security/AuthPopulator.java @@ -5,9 +5,6 @@ import info.bukova.isspst.data.User; import info.bukova.isspst.services.users.LdapUserImporter; import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.UserService; - -import java.util.Collection; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ldap.core.DirContextOperations; @@ -15,6 +12,8 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator; +import java.util.Collection; + public class AuthPopulator implements LdapAuthoritiesPopulator { private UserService userService; @@ -30,7 +29,8 @@ public class AuthPopulator implements LdapAuthoritiesPopulator { public Collection getGrantedAuthorities( DirContextOperations userData, String login) { - User user = null; + User user; + try { user = (User) userService.loadUserByUsername(login); } catch (UsernameNotFoundException e) { diff --git a/src/main/java/info/bukova/isspst/services/users/AdUserCtxMapper.java b/src/main/java/info/bukova/isspst/services/users/AdUserCtxMapper.java index fc95a943..dc6a8a0b 100644 --- a/src/main/java/info/bukova/isspst/services/users/AdUserCtxMapper.java +++ b/src/main/java/info/bukova/isspst/services/users/AdUserCtxMapper.java @@ -3,9 +3,6 @@ package info.bukova.isspst.services.users; import info.bukova.isspst.Constants; import info.bukova.isspst.data.User; import info.bukova.isspst.security.AuthMethod; - -import java.util.Collection; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ldap.core.DirContextAdapter; @@ -16,6 +13,8 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider; import org.springframework.security.ldap.userdetails.UserDetailsContextMapper; +import java.util.Collection; + /** * Mapovač doménových uživatelů Active Directory na uživatele aplikace. Pokud uživatel není v aplikační databází, * importu je se tam pomoci {@link LdapUserImporter}. Tento objekt se předává do {@link ActiveDirectoryLdapAuthenticationProvider}. @@ -40,7 +39,8 @@ public class AdUserCtxMapper implements UserDetailsContextMapper { @Override public UserDetails mapUserFromContext(DirContextOperations userData, String username, Collection authorities) { - + username = username.toLowerCase(); + try { User user = (User) userService.loadUserByUsername(username); return user; diff --git a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java index 25faf30b..8b8a491f 100644 --- a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java @@ -7,15 +7,7 @@ import info.bukova.isspst.data.UserSettingsData; import info.bukova.isspst.security.AuthMethod; import info.bukova.isspst.services.AbstractService; import info.bukova.isspst.services.StringXmlMarshaller; -//import info.bukova.isspst.services.LazyLoader; - import info.bukova.isspst.services.workgroups.WorkgroupService; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.hibernate.LazyInitializationException; @@ -31,6 +23,13 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +//import info.bukova.isspst.services.LazyLoader; + public class UserServiceImpl extends AbstractService implements UserService { private PasswordEncoder encoder; @@ -220,6 +219,7 @@ public class UserServiceImpl extends AbstractService implements UserServic } @Override + @Transactional public void delete(User entity) { workgroupService.loadParents(entity);