You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/08/23 07:19:16 UTC
[1/2] syncope git commit: Prevent exceptions when attempting to read
own groups as admin
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ò <il...@apache.org>
Authored: Wed Aug 23 09:15:36 2017 +0200
Committer: Francesco Chicchiriccò <il...@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>() {
[2/2] syncope git commit: Prevent exceptions when attempting to read
own groups as admin
Posted by il...@apache.org.
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/48b20024
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/48b20024
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/48b20024
Branch: refs/heads/master
Commit: 48b2002444d6f9bfaf88a4b609e45ca494517499
Parents: 74ee038
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Aug 23 09:15:36 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Aug 23 09:19:06 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/48b20024/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 efdab59..c4ccc53 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
@@ -20,12 +20,14 @@ package org.apache.syncope.core.logic;
import java.lang.reflect.Method;
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 java.util.stream.Collectors;
+import javax.annotation.Resource;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
@@ -77,6 +79,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;
@@ -129,6 +134,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 userDAO.findAllGroups(userDAO.findByUsername(AuthContextUtils.getUsername())).stream().
map(group -> binder.getGroupTO(group, true)).collect(Collectors.toList());
}