directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject [1/2] directory-fortress-core git commit: FC-130 - Add permission search that uses substring filters
Date Tue, 15 Dec 2015 23:26:11 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master 43ec6a415 -> 2d1dd560b


 FC-130 -  Add permission search that uses substring filters


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

Branch: refs/heads/master
Commit: 2d1dd560bcb747473fc1520a116576f1877c0a02
Parents: 005b4f3
Author: Shawn McKinney <smckinney@apache.org>
Authored: Tue Dec 15 04:20:43 2015 -0600
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Tue Dec 15 04:20:43 2015 -0600

----------------------------------------------------------------------
 .../directory/fortress/core/impl/PermDAO.java   | 14 ++++--
 .../directory/fortress/core/impl/PermP.java     |  9 +++-
 .../fortress/core/impl/ReviewMgrImpl.java       | 20 ++++++--
 .../directory/fortress/core/rest/HttpIds.java   |  1 +
 .../fortress/core/rest/ReviewMgrRestImpl.java   | 48 +++++++++++++++++---
 5 files changed, 78 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/2d1dd560/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 6d273fa..874b0fa 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
@@ -1116,7 +1116,15 @@ final class PermDAO extends ApacheDsDataProvider
         }
         return permList;
     }
-    
+
+    /**
+     * Uses substring filters to allow any permission matching the passed in obj and op names.
+     *
+     * @param permission
+     * @return
+     * @throws org.apache.directory.fortress.core.FinderException
+     *
+     */
     List<Permission> findAnyPermissions( Permission permission )
             throws FinderException
         {
@@ -1161,12 +1169,12 @@ final class PermDAO extends ApacheDsDataProvider
             }
             catch ( LdapException e )
             {
-                String error = "findPermissions caught LdapException=" + e.getMessage();
+                String error = "findAnyPermissions caught LdapException=" + e.getMessage();
                 throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
             catch ( CursorException e )
             {
-                String error = "findPermissions caught CursorException=" + e.getMessage();
+                String error = "findAnyPermissions caught CursorException=" + e.getMessage();
                 throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
             finally

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/2d1dd560/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 2ff39a6..361e243 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,7 +106,14 @@ final class PermP
     {
         return pDao.findPermissions( permission );
     }
-    
+
+    /**
+     * Takes a Permission entity that contains full or partial object name and/or full or
partial operation name for search.
+     *
+     * @param permission contains all or partial object name and/or all or partial operation
name.
+     * @return List of type Permission containing fully populated matching Permission entities.
+     * @throws SecurityException in the event of DAO search error.
+     */
     List<Permission> searchAny( Permission permission ) throws SecurityException
     {
         return pDao.findAnyPermissions( permission );

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/2d1dd560/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 b827549..5d65f1b 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
@@ -130,8 +130,8 @@ public class ReviewMgrImpl extends Manageable implements ReviewMgr
      * Method returns a list of type Permission that match the perm object search string.
      * <h4>optional parameters</h4>
      * <ul>
-     * <li>{@link Permission#objName} - contains one or more characters of existing
object being targeted</li>
-     * <li>{@link Permission#opName} - contains one or more characters of existing
permission operation</li>
+     * <li>{@link Permission#objName} - contains one or more characters of existing
object being targeted in leading characters.</li>
+     * <li>{@link Permission#opName} - contains one or more characters of existing
permission operation in leading characters.</li>
      * </ul>
      *
      * @param permission contains object and operation name search strings.  Each contains
1 or more leading chars that correspond to object or op name.
@@ -149,11 +149,25 @@ public class ReviewMgrImpl extends Manageable implements ReviewMgr
         return permP.search( permission );
     }
 
+    /**
+     * 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).
+     * <h4>optional parameters</h4>
+     * <ul>
+     * <li>{@link Permission#objName} - contains one or more characters of existing
object being targeted</li>
+     * <li>{@link Permission#opName} - contains one or more characters of existing
permission operation</li>
+     * </ul>
+     *
+     * @param permission contains object and operation name search strings.  Each contains
1 or more leading chars that correspond to object or op name.
+     * @return List of type Permission.  Fortress permissions are object->operation mappings.
 The permissions may contain
+     *         assigned user, role or group entities as well.
+     * @throws SecurityException thrown in the event of system error.
+     */
     @Override
     public List<Permission> findAnyPermissions(Permission permission)
         throws SecurityException
     {
-        String methodName = "findPermissions";
+        String methodName = "findAnyPermissions";
         assertContext( CLS_NM, methodName, permission, GlobalErrIds.PERM_OPERATION_NULL );
         checkAccess(CLS_NM, methodName);
         return permP.searchAny( permission );

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/2d1dd560/src/main/java/org/apache/directory/fortress/core/rest/HttpIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/HttpIds.java b/src/main/java/org/apache/directory/fortress/core/rest/HttpIds.java
index 66c65f2..7de9cad 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/HttpIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/HttpIds.java
@@ -79,6 +79,7 @@ public class HttpIds
     public static final String PERM_ADD = "permAdd";
     public static final String PERM_DELETE = "permDelete";
     public static final String PERM_SEARCH = "permSearch";
+    public static final String PERM_SEARCH_ANY = "permSearchAny";
     public static final String PERM_ROLES = "permRoles";
     public static final String PERM_USERS = "permUsers";
     public static final String PERM_ROLES_AUTHZED = "permRolesAuthzed";

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/2d1dd560/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 05e34fb..b346ce4 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
@@ -197,6 +197,47 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
     }
 
     /**
+     * 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).
+     * <h4>optional parameters</h4>
+     * <ul>
+     * <li>{@link Permission#objName} - contains one or more characters of existing
object being targeted</li>
+     * <li>{@link Permission#opName} - contains one or more characters of existing
permission operation</li>
+     * </ul>
+     *
+     * @param permission contains object and operation name search strings.  Each contains
1 or more leading chars that correspond to object or op name.
+     * @return List of type Permission.  Fortress permissions are object->operation mappings.
 The permissions may contain
+     *         assigned user, role or group entities as well.
+     * @throws SecurityException thrown in the event of system error.
+     */
+    @Override
+    public List<Permission> findAnyPermissions(Permission permission)
+        throws SecurityException
+    {
+        VUtil.assertNotNull(permission, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".findAnyPermissions");
+        List<Permission> retPerms;
+        FortRequest request = new FortRequest();
+        request.setContextId(this.contextId);
+        request.setEntity(permission);
+        if (this.adminSess != null)
+        {
+            request.setSession(adminSess);
+        }
+        String szRequest = RestUtils.marshal(request);
+        String szResponse = RestUtils.post(szRequest, HttpIds.PERM_SEARCH_ANY);
+        FortResponse response = RestUtils.unmarshall(szResponse);
+        if (response.getErrorCode() == 0)
+        {
+            retPerms = response.getEntities();
+        }
+        else
+        {
+            throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
+        }
+        return retPerms;
+    }
+
+    /**
      * Method returns a list of type PermObj that match the perm object search string.
      * <h4>optional parameters</h4>
      * <ul>
@@ -1467,11 +1508,4 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
         }
         return retSet.getCardinality();
     }
-
-	@Override
-	public List<Permission> findAnyPermissions(Permission permission)
-			throws SecurityException {
-		// TODO Auto-generated method stub
-		return null;
-	}
 }
\ No newline at end of file


Mime
View raw message