You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2018/10/02 17:24:33 UTC

directory-fortress-core git commit: FC-246 - fix NPE in addRoleConstraint when user not assigned to any roles

Repository: directory-fortress-core
Updated Branches:
  refs/heads/master b65e204e2 -> 510d6f257


FC-246 - fix NPE in addRoleConstraint when user not assigned to any roles


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/510d6f25
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/510d6f25
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/510d6f25

Branch: refs/heads/master
Commit: 510d6f257f7d93c2951f8b9e3884ad41048d30df
Parents: b65e204
Author: Shawn McKinney <sm...@apache.org>
Authored: Tue Oct 2 12:24:26 2018 -0500
Committer: Shawn McKinney <sm...@apache.org>
Committed: Tue Oct 2 12:24:26 2018 -0500

----------------------------------------------------------------------
 .../org/apache/directory/fortress/core/impl/AdminMgrImpl.java     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/510d6f25/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
index 4752c77..968a5c2 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
@@ -461,7 +461,8 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
         // Validate the user-role assignment exists:
         List<String> assignedRoles = userP.getAssignedRoles( new User( uRole.getUserId() ) );
         assertContext( CLS_NM, methodName, uRole, GlobalErrIds.URLE_NULL );
-        if ( ! assignedRoles.stream().anyMatch( uRole.getName()::equalsIgnoreCase) )
+        // Do not assign role constraint to user if not assigned the role itself.
+        if ( CollectionUtils.isEmpty( assignedRoles ) || !assignedRoles.stream().anyMatch( uRole.getName()::equalsIgnoreCase) )
         {
             String error =  methodName + " user [" + uRole.getUserId() + "] not assigned role [" + uRole.getName() + "]";
             LOG.error( error );