directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cp...@apache.org
Subject [19/43] directory-fortress-core git commit: changed rolePermissionAttribute to return sets isntead of permattribute
Date Thu, 06 Oct 2016 17:49:36 GMT
changed rolePermissionAttribute to return sets isntead of permattribute


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/d7fb80ba
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/d7fb80ba
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/d7fb80ba

Branch: refs/heads/master
Commit: d7fb80ba9ada60effd78ae0cc6858026ebf39cde
Parents: 8dd536c
Author: clp207 <clp207@psu.edu>
Authored: Fri Jan 29 11:29:50 2016 -0500
Committer: clp207 <clp207@psu.edu>
Committed: Wed Mar 30 15:44:22 2016 -0400

----------------------------------------------------------------------
 .../directory/fortress/core/AdminMgr.java       |  2 +-
 .../directory/fortress/core/GlobalErrIds.java   |  5 ++
 .../directory/fortress/core/ReviewMgr.java      |  4 +-
 .../directory/fortress/core/impl/PermDAO.java   | 65 ++++++++++++++++++++
 .../directory/fortress/core/impl/PermP.java     |  7 ++-
 .../fortress/core/impl/ReviewMgrImpl.java       | 19 ++++--
 .../directory/fortress/core/impl/UserDAO.java   |  6 +-
 .../fortress/core/model/ObjectFactory.java      |  7 +++
 .../core/model/PermissionAttributeSet.java      | 26 ++------
 .../fortress/core/rest/AdminMgrRestImpl.java    | 27 ++++++++
 .../fortress/core/rest/ReviewMgrRestImpl.java   |  4 +-
 11 files changed, 133 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/AdminMgr.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AdminMgr.java b/src/main/java/org/apache/directory/fortress/core/AdminMgr.java
index de3639a..93b6e18 100755
--- a/src/main/java/org/apache/directory/fortress/core/AdminMgr.java
+++ b/src/main/java/org/apache/directory/fortress/core/AdminMgr.java
@@ -453,7 +453,7 @@ public interface AdminMgr extends Manageable
     //TODO: add documentation
     RoleConstraint addRoleConstraint( UserRole uRole, RoleConstraint roleConstraint )
     	throws SecurityException;
-
+    
     //TODO: remove documentation
     void removeRoleConstraint( UserRole uRole, RoleConstraint roleConstraint )
     	throws SecurityException;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java b/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
index a170274..cbda366 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
@@ -665,6 +665,11 @@ public final class GlobalErrIds
      * The supplied Permission Attribute could not be added to ldap server.
      */
     public static final int PERM_ATTR_ADD_FAILED = 3034;
+    /**
+     * The supplied Permission Attribute Set could not be found on ldap server.
+     */
+    public static final int PERM_ATTRIBUTE_SET_NOT_FOUND = 3035;
+    
     
     /**
      * 4000's - Password Policy Entity

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/ReviewMgr.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ReviewMgr.java b/src/main/java/org/apache/directory/fortress/core/ReviewMgr.java
index 7205a86..0a4f15a 100755
--- a/src/main/java/org/apache/directory/fortress/core/ReviewMgr.java
+++ b/src/main/java/org/apache/directory/fortress/core/ReviewMgr.java
@@ -26,7 +26,7 @@ import java.util.Set;
 import org.apache.directory.fortress.core.model.OrgUnit;
 import org.apache.directory.fortress.core.model.PermObj;
 import org.apache.directory.fortress.core.model.Permission;
-import org.apache.directory.fortress.core.model.PermissionAttribute;
+import org.apache.directory.fortress.core.model.PermissionAttributeSet;
 import org.apache.directory.fortress.core.model.Role;
 import org.apache.directory.fortress.core.model.SDSet;
 import org.apache.directory.fortress.core.model.User;
@@ -441,7 +441,7 @@ public interface ReviewMgr extends Manageable
         throws SecurityException;
 
     //TODO: add documentation
-    Set<PermissionAttribute> rolePermissionAttributes( Role role, boolean noInhertiance
)
+    List<PermissionAttributeSet> rolePermissionAttributeSets( Role role, boolean noInhertiance
)
     	throws SecurityException;
     
     /**

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
index a8f5373..8e58bf7 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
@@ -208,6 +208,11 @@ final class PermDAO extends ApacheDsDataProvider
             GlobalIds.PROPS
     };
     
+    private static final String[] PERMISION_ATTRIBUTE_SET_ATRS =
+        {
+            GlobalIds.FT_IID, GlobalIds.FT_PERMISSION_ATTRIBUTE, SchemaConstants.DESCRIPTION_AT,
SchemaConstants.CN_AT
+    };
+    
     /**
      * @param entity
      * @return
@@ -973,6 +978,42 @@ final class PermDAO extends ApacheDsDataProvider
 
         return entity;
     }
+    
+    PermissionAttributeSet getPermAttributeSet( PermissionAttributeSet permAttributeSet )
+    		throws FinderException
+    {
+    	PermissionAttributeSet entity = null;
+    	LdapConnection ld = null;
+    	String dn = getPASetDn(permAttributeSet.getName(), permAttributeSet.getContextId());
+
+    	try
+    	{
+    		ld = getAdminConnection();
+    		Entry findEntry = read( ld, dn, PERMISION_ATTRIBUTE_SET_ATRS );
+    		if ( findEntry == null )
+    		{
+    			String warning = "getPermAttributeSet no entry found dn [" + dn + "]";
+    			throw new FinderException( GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, warning );
+    		}
+    		entity = unloadPASetLdapEntry( findEntry, 0 );
+    	}
+    	catch ( LdapNoSuchObjectException e )
+    	{
+    		String warning = "getPermAttributeSet COULD NOT FIND ENTRY for dn [" + dn + "]";
+    		throw new FinderException( GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, warning );
+    	}
+    	catch ( LdapException e )
+    	{
+    		String error = "getPermAttributeSet dn [" + dn + "] caught LdapException=" + e.getMessage();
+    		throw new FinderException( GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, error, e );
+    	}
+    	finally
+    	{
+    		closeAdminConnection( ld );
+    	}
+
+    	return entity;
+    }
 
 
     /**
@@ -1216,6 +1257,30 @@ final class PermDAO extends ApacheDsDataProvider
         return entity;
     }
     
+    private PermissionAttributeSet unloadPASetLdapEntry( Entry le, long sequence )
+    		throws LdapInvalidAttributeValueException
+    {
+    	PermissionAttributeSet entity = new ObjectFactory().createPermAttributeSet();
+    	entity.setSequenceId( sequence );
+    	entity.setName( getAttribute( le, SchemaConstants.CN_AT ) );
+    	entity.setDn( le.getDn().getName() );
+    	entity.setInternalId( getAttribute( le, GlobalIds.FT_IID ) );
+    	entity.setDescription( getAttribute( le, SchemaConstants.DESCRIPTION_AT ) );
+    	
+    	List<String> ftPAs = getAttributes( le, GlobalIds.FT_PERMISSION_ATTRIBUTE );
+    	
+    	if(ftPAs != null){
+    		for(String ftPARaw : ftPAs){
+    			PermissionAttribute permAttribute = new ObjectFactory().createPermissionAttribute();
+                permAttribute.load( ftPARaw );
+                
+                entity.getAttributes().add(permAttribute);
+    		}
+    	}
+    	
+    	return entity;
+    }
+    
     /**
      * @param permission
      * @return

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermP.java b/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
index 4284c47..871ffbf 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
@@ -336,7 +336,12 @@ final class PermP
     {
         return pDao.getPerm( permObj );
     }
-
+    
+    //TODO: add documentation
+    PermissionAttributeSet read( PermissionAttributeSet permAttributeSet ) throws SecurityException
+    {
+        return pDao.getPermAttributeSet( permAttributeSet );
+    }
 
     /**
      * Adds a new Permission Object entity to directory.  The Permission Object entity input
will be validated to ensure that:

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
index 463572c..8f4e6bb 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
@@ -21,8 +21,10 @@ package org.apache.directory.fortress.core.impl;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.collections.CollectionUtils;
@@ -32,7 +34,7 @@ import org.apache.directory.fortress.core.SecurityException;
 import org.apache.directory.fortress.core.model.OrgUnit;
 import org.apache.directory.fortress.core.model.PermObj;
 import org.apache.directory.fortress.core.model.Permission;
-import org.apache.directory.fortress.core.model.PermissionAttribute;
+import org.apache.directory.fortress.core.model.PermissionAttributeSet;
 import org.apache.directory.fortress.core.model.Role;
 import org.apache.directory.fortress.core.model.SDSet;
 import org.apache.directory.fortress.core.model.User;
@@ -409,18 +411,23 @@ public class ReviewMgrImpl extends Manageable implements ReviewMgr,
Serializable
      * {@inheritDoc}
      */
     @Override
-    public Set<PermissionAttribute> rolePermissionAttributes( Role role, boolean noInhertiance
)
+    public List<PermissionAttributeSet> rolePermissionAttributeSets( Role role, boolean
noInhertiance )    
     	throws SecurityException
     {
-    	Set<PermissionAttribute> permAttributes = new HashSet<PermissionAttribute>();
+    	Map<String, PermissionAttributeSet> permAttributeSets = new HashMap<String,
PermissionAttributeSet>();
     	
+    	//look through all permissions in the role
     	List<Permission> permissions = this.rolePermissions(role, noInhertiance);
     	for(Permission perm : permissions){
-    		//TODO: need to get ftPA entries now...
-    		//permAttributes.addAll(perm.getAttributes());
+    		if(perm.getPaSetName() != null && !perm.getPaSetName().isEmpty()){
+    			if(!permAttributeSets.containsKey(perm.getPaSetName())){
+    				PermissionAttributeSet permAttributeSet = permP.read(new PermissionAttributeSet(perm.getPaSetName()));
+    				permAttributeSets.put(perm.getPaSetName(), permAttributeSet);
+    			}
+    		}    		
     	}
     	
-    	return permAttributes;
+    	return new ArrayList<PermissionAttributeSet>(permAttributeSets.values());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
index 47da5ac..871362f 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
@@ -1840,8 +1840,6 @@ final class UserDAO extends ApacheDsDataProvider
 
             ld = getAdminConnection();
             modify( ld, userDn, mods, uRole );
-            
-            //TODO: make sure not adding same RC twice
         }
         catch ( LdapException e )
         {
@@ -1871,9 +1869,7 @@ final class UserDAO extends ApacheDsDataProvider
             		szRoleConstraint ) );
 
             ld = getAdminConnection();
-            modify( ld, userDn, mods, uRole );
-            
-            //TODO: make sure not adding same RC twice
+            modify( ld, userDn, mods, uRole );            
         }
         catch ( LdapException e )
         {

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java b/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
index f98f9d6..7b27a87 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
@@ -443,6 +443,13 @@ public class ObjectFactory
         return new PermObj();
     }
 
+    /**
+     * Create an instance of {@link PermissionAttributeSet}
+     */
+    public PermissionAttributeSet createPermAttributeSet()
+    {
+        return new PermissionAttributeSet();
+    }
 
     /**
      * Create an instance of {@link Permission}

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/model/PermissionAttributeSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/PermissionAttributeSet.java
b/src/main/java/org/apache/directory/fortress/core/model/PermissionAttributeSet.java
index 070c278..3bf25d1 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/PermissionAttributeSet.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/PermissionAttributeSet.java
@@ -70,6 +70,10 @@ public class PermissionAttributeSet extends FortEntity {
     {
         this.attributes = attributes;
     }
+    
+    public void setInternalId(String internalId){
+    	this.internalId = internalId;
+    }
 
 	public String getInternalId() {
 		return internalId;
@@ -95,27 +99,5 @@ public class PermissionAttributeSet extends FortEntity {
 	public void setDn(String dn) {
 		this.dn = dn;
 	}
-    
-    /*
-    private Set<PermissionAttribute> unloadPermissionAttributes( Entry entry )
-    {
-        Set<PermissionAttribute> permAttributes = null;
-        List<String> ftPAs = getAttributes( entry, GlobalIds.FT_PERMISSION_ATTRIBUTE
);
-
-        if ( ftPAs != null )
-        {
-        	permAttributes = new HashSet<PermissionAttribute>();
-
-            for ( String raw : ftPAs )
-            {
-                PermissionAttribute permAttribute = new ObjectFactory().createPermissionAttribute();
-                permAttribute.load( raw );
-                permAttributes.add( permAttribute );
-            }
-        }
-
-        return permAttributes;
-    }
-    */
 
 }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
index eaa25be..9d50730 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
@@ -29,6 +29,7 @@ import org.apache.directory.fortress.core.model.FortResponse;
 import org.apache.directory.fortress.core.model.PermGrant;
 import org.apache.directory.fortress.core.model.PermObj;
 import org.apache.directory.fortress.core.model.Permission;
+import org.apache.directory.fortress.core.model.PermissionAttribute;
 import org.apache.directory.fortress.core.model.PermissionAttributeSet;
 import org.apache.directory.fortress.core.model.Role;
 import org.apache.directory.fortress.core.model.RoleConstraint;
@@ -1265,4 +1266,30 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
 		// TODO Auto-generated method stub
 		return null;
 	}
+
+
+	@Override
+	public void deletePermissionAttributeSet(
+			PermissionAttributeSet permAttributeSet) throws SecurityException {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+	@Override
+	public PermissionAttribute addPermissionAttributeToSet(
+			PermissionAttribute permAttribute, String attributeSetName)
+			throws SecurityException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+	@Override
+	public void removePermissionAttributeFromSet(
+			PermissionAttribute permAttribute, String attributeSetName)
+			throws SecurityException {
+		// TODO Auto-generated method stub
+		
+	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d7fb80ba/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
b/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
index 77d8c01..32dfa0b 100755
--- a/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
@@ -33,7 +33,7 @@ import org.apache.directory.fortress.core.model.FortResponse;
 import org.apache.directory.fortress.core.model.OrgUnit;
 import org.apache.directory.fortress.core.model.PermObj;
 import org.apache.directory.fortress.core.model.Permission;
-import org.apache.directory.fortress.core.model.PermissionAttribute;
+import org.apache.directory.fortress.core.model.PermissionAttributeSet;
 import org.apache.directory.fortress.core.model.Role;
 import org.apache.directory.fortress.core.model.SDSet;
 import org.apache.directory.fortress.core.model.User;
@@ -761,7 +761,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
     }
 
 	@Override
-	public Set<PermissionAttribute> rolePermissionAttributes(Role role,
+	public List<PermissionAttributeSet> rolePermissionAttributeSets(Role role,
 			boolean noInhertiance) throws SecurityException {
 		// TODO Auto-generated method stub
 		return null;


Mime
View raw message