From d1ccaf530d1dd91fe6bb2ccb30d2ac51e8f52145 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Tue, 18 Aug 2015 22:21:05 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99i=20napojov=C3=A1n=C3=AD=20u=C5=BEivatel?= =?UTF-8?q?e=20z=20AD=20se=20login=20p=C5=99evede=20na=20mal=C3=A1=20p?= =?UTF-8?q?=C3=ADsmena.=20Opravena=20chyba=20p=C5=99i=20maz=C3=A1n=C3=AD?= =?UTF-8?q?=20u=C5=BEivatele.=20closes=20#237?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukova/isspst/security/AuthPopulator.java | 8 ++++---- .../isspst/services/users/AdUserCtxMapper.java | 8 ++++---- .../isspst/services/users/UserServiceImpl.java | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) 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);