directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject [2/2] directory-fortress-core git commit: added method to get all operations for a given perm object
Date Thu, 17 Dec 2015 23:34:28 GMT
added method to get all operations for a given perm object


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

Branch: refs/heads/master
Commit: 981ba0bf4e3f0a9c4aa3f4f8ada199c28e4e723f
Parents: 2d1dd56
Author: clp207 <clp207@psu.edu>
Authored: Thu Dec 17 10:30:33 2015 -0500
Committer: clp207 <clp207@psu.edu>
Committed: Thu Dec 17 10:30:33 2015 -0500

----------------------------------------------------------------------
 .../directory/fortress/core/ReviewMgr.java      | 11 +++++
 .../directory/fortress/core/impl/PermDAO.java   | 45 ++++++++++++++++++++
 .../directory/fortress/core/impl/PermP.java     | 12 ++++++
 .../fortress/core/impl/ReviewMgrImpl.java       |  9 ++++
 .../fortress/core/rest/ReviewMgrRestImpl.java   |  7 +++
 5 files changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/981ba0bf/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 fbc659b..5243d7b 100755
--- a/src/main/java/org/apache/directory/fortress/core/ReviewMgr.java
+++ b/src/main/java/org/apache/directory/fortress/core/ReviewMgr.java
@@ -120,6 +120,17 @@ public interface ReviewMgr extends Manageable
         throws SecurityException;
 
     /**
+     * Method returns Permission operations for the provided permission object
+     * 
+     * @param permObj entity contains the {@link PermObj#objName} of target record.
+     * @return List of type Permission for provided permission object
+     * @throws SecurityException
+     *          thrown in the event of system error.
+     */
+    List<Permission> findPermissions( PermObj permObj ) 
+    	throws SecurityException;
+    
+    /**
      * Method returns a list of Permissions that match any part of the permission object
or operation.
      * 
      * @param permission contains object and operation name search strings.

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/981ba0bf/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 874b0fa..74c025d 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
@@ -1117,6 +1117,51 @@ final class PermDAO extends ApacheDsDataProvider
         return permList;
     }
 
+    List<Permission> findPermissionOperations( PermObj permObj )
+            throws FinderException
+        {
+            List<Permission> permList = new ArrayList<>();
+            LdapConnection ld = null;
+            String permRoot = getRootDn( permObj.isAdmin(), permObj.getContextId() );
+
+            try
+            {
+                String permObjVal = encodeSafeText( permObj.getObjName(), GlobalIds.PERM_LEN
);
+                StringBuilder filterbuf = new StringBuilder();
+                filterbuf.append( GlobalIds.FILTER_PREFIX );
+                filterbuf.append( PERM_OP_OBJECT_CLASS_NAME );
+                filterbuf.append( ")(" );
+                filterbuf.append( GlobalIds.POBJ_NAME );
+                filterbuf.append( "=" );
+                filterbuf.append( permObjVal );
+                filterbuf.append(  "))" );
+                ld = getAdminConnection();
+                SearchCursor searchResults = search( ld, permRoot,
+                    SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false,
GlobalIds.BATCH_SIZE );
+                long sequence = 0;
+
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++,
permObj.isAdmin() ) );
+                }
+            }
+            catch ( LdapException e )
+            {
+                String error = "findPermissions caught LdapException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findPermissions caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+            }
+            finally
+            {
+                closeAdminConnection( ld );
+            }
+            return permList;
+        }
+    
     /**
      * Uses substring filters to allow any permission matching the passed in obj and op names.
      *

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/981ba0bf/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 361e243..3f21f9c 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
@@ -106,6 +106,18 @@ final class PermP
     {
         return pDao.findPermissions( permission );
     }
+    
+    /**
+     * Takes a permission object that contains an object name and returns permisison operations
for that object
+     * 
+     * @param permObj Contains full object name
+     * @return List of type Permission containing fully populated matching Permission entities.
+     * @throws SecurityException in the event of DAO search error.
+     */
+    List<Permission> searchOperations( PermObj permObj ) throws SecurityException
+    {
+        return pDao.findPermissionOperations( permObj );
+    }
 
     /**
      * Takes a Permission entity that contains full or partial object name and/or full or
partial operation name for search.

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/981ba0bf/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 5d65f1b..2aa8e02 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
@@ -149,6 +149,15 @@ public class ReviewMgrImpl extends Manageable implements ReviewMgr
         return permP.search( permission );
     }
 
+	@Override
+	public List<Permission> findPermissions(PermObj permObj)
+			throws SecurityException {
+        String methodName = "findPermissions";
+        assertContext( CLS_NM, methodName, permObj, GlobalErrIds.PERM_OPERATION_NULL );
+        checkAccess(CLS_NM, methodName);
+        return permP.searchOperations( permObj );
+	}
+    
     /**
      * Method returns a list of type Permission that match any part of either {@link Permission#objName}
or {@link Permission#opName} search strings.
      * This method differs from findPermissions in that any permission that matches any part
of the perm obj or any part of the perm op will be returned in result set (uses substring
string matching).

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/981ba0bf/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 b346ce4..a4ace60 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
@@ -1508,4 +1508,11 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
         }
         return retSet.getCardinality();
     }
+
+	@Override
+	public List<Permission> findPermissions(PermObj permObj)
+			throws SecurityException {
+		// TODO Auto-generated method stub
+		return null;
+	}
 }
\ No newline at end of file


Mime
View raw message