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 2023/09/09 13:59:51 UTC
[directory-fortress-core] branch master updated: FC-328 - Role Constraint validations broken
This is an automated email from the ASF dual-hosted git repository.
smckinney pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-fortress-core.git
The following commit(s) were added to refs/heads/master by this push:
new cdb46ee5 FC-328 - Role Constraint validations broken
cdb46ee5 is described below
commit cdb46ee5f97fc13d12074040ce6dfa221588b8d5
Author: Shawn McKinney <sm...@symas.com>
AuthorDate: Sat Sep 9 08:59:43 2023 -0500
FC-328 - Role Constraint validations broken
---
.../org/apache/directory/fortress/core/impl/AdminMgrImpl.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
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 eee6c5e3..b9c8d9fe 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
@@ -453,7 +453,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
*/
@Override
@AdminPermissionOperation
- public RoleConstraint addRoleConstraint( UserRole uRole, RoleConstraint roleConstraint )
+ public RoleConstraint addRoleConstraint( UserRole uRole, RoleConstraint roleConstraint )
throws SecurityException
{
String methodName = "addRoleConstraint";
@@ -461,13 +461,19 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
VUtil.assertNotNull( uRole.getName(), GlobalErrIds.ROLE_NM_NULL, CLS_NM + methodName );
VUtil.assertNotNull( roleConstraint, GlobalErrIds.ROLE_CONSTRAINT_NULL, CLS_NM + methodName );
setEntitySession( CLS_NM, methodName, uRole );
-
if ( roleConstraint.getType() == RoleConstraint.RCType.USER )
{
// This constraint type requires a global config parameter keyed by RC$tenant$role:constraint:
String propKey = Config.getInstance().getConstraintKey( uRole.getName(), contextId );
+ VUtil.assertNotNull( propKey, GlobalErrIds.ROLE_CONSTRAINT_NOT_ENABLED, CLS_NM + methodName );
String propValue = Config.getInstance().getProperty( propKey );
VUtil.assertNotNull( propValue, GlobalErrIds.ROLE_CONSTRAINT_NOT_ENABLED, CLS_NM + methodName );
+ String userKey = roleConstraint.getKey();
+ if ( !userKey.equalsIgnoreCase( propValue ))
+ {
+ String error = methodName + " invalid constraint name [" + userKey + "] not added for role [" + uRole.getName() + "] constraint key [" + propKey + "]";
+ throw new SecurityException( GlobalErrIds.ROLE_CONSTRAINT_NOT_ENABLED, error, null );
+ }
}
// Validate the user-role assignment exists: