Repository: syncope Updated Branches: refs/heads/2_0_X debb51f64 -> f23fcf044 refs/heads/master 74ee038a4 -> 48b200244
Prevent exceptions when attempting to read own groups as admin Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/f23fcf04 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/f23fcf04 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/f23fcf04 Branch: refs/heads/2_0_X Commit: f23fcf044a3319aac438cf26ad702e7f0c513601 Parents: debb51f Author: Francesco Chicchiriccò <ilgro...@apache.org> Authored: Wed Aug 23 09:15:36 2017 +0200 Committer: Francesco Chicchiriccò <ilgro...@apache.org> Committed: Wed Aug 23 09:15:36 2017 +0200 ---------------------------------------------------------------------- .../main/java/org/apache/syncope/core/logic/GroupLogic.java | 9 +++++++++ 1 file changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/f23fcf04/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java index 898113d..12b7a22 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java @@ -21,11 +21,13 @@ package org.apache.syncope.core.logic; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import javax.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.IterableUtils; import org.apache.commons.collections4.Predicate; @@ -81,6 +83,9 @@ import org.springframework.transaction.annotation.Transactional; @Component public class GroupLogic extends AbstractAnyLogic<GroupTO, GroupPatch> { + @Resource(name = "adminUser") + protected String adminUser; + @Autowired protected AnySearchDAO searchDAO; @@ -137,6 +142,10 @@ public class GroupLogic extends AbstractAnyLogic<GroupTO, GroupPatch> { @PreAuthorize("isAuthenticated() and not(hasRole('" + StandardEntitlement.ANONYMOUS + "'))") @Transactional(readOnly = true) public List<GroupTO> own() { + if (adminUser.equals(AuthContextUtils.getUsername())) { + return Collections.emptyList(); + } + return CollectionUtils.collect( userDAO.findAllGroups(userDAO.findByUsername(AuthContextUtils.getUsername())), new Transformer<Group, GroupTO>() {