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 2022/07/27 22:15:27 UTC
[directory-site] branch master updated: + add/deletePermission
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-site.git
The following commit(s) were added to refs/heads/master by this push:
new b5556ea5 + add/deletePermission
b5556ea5 is described below
commit b5556ea5d210a1470b7d446716de61d6ee471f3b
Author: Shawn McKinney <sm...@symas.com>
AuthorDate: Wed Jul 27 17:15:20 2022 -0500
+ add/deletePermission
---
source/fortress/user-guide.md | 4 +-
.../fortress/user-guide/4-fortress-code-samples.md | 2 +
source/fortress/user-guide/4.12-delete-permobj.md | 4 +-
source/fortress/user-guide/4.13-add-permission.md | 82 ++++++++++++++++++++++
...delete-permobj.md => 4.14-delete-permission.md} | 41 ++++++-----
5 files changed, 111 insertions(+), 22 deletions(-)
diff --git a/source/fortress/user-guide.md b/source/fortress/user-guide.md
index a1fe6949..f070f333 100644
--- a/source/fortress/user-guide.md
+++ b/source/fortress/user-guide.md
@@ -33,11 +33,11 @@ This guide is primarily for people new to Fortress.
* [4.10 - Delete User](user-guide/4.10-delete-user.html)
* [4.11 - Add Permission Object](user-guide/4.11-add-permobj.html)
* [4.12 - Delete Permission Object](user-guide/4.12-delete-permobj.html)
+ * [4.13 - Add Permission](user-guide/4.13-add-permission.html)
+ * [4.14 - Delete Permission](user-guide/4.14-delete-permission.html)
* TODO (more code samples):
- * [4.13 - addPermission]
- * [4.14 - deletePermission]
* [4.15 - assignUser]
* [4.16 - deassignUser]
* [4.17 - grantPermission]
diff --git a/source/fortress/user-guide/4-fortress-code-samples.md b/source/fortress/user-guide/4-fortress-code-samples.md
index 376006a4..7168e2de 100644
--- a/source/fortress/user-guide/4-fortress-code-samples.md
+++ b/source/fortress/user-guide/4-fortress-code-samples.md
@@ -24,3 +24,5 @@ navNextText: 4.1 - Example Creating RBAC Session
* [4.10 - Delete User](4.10-delete-user.html)
* [4.11 - Add Permission Object](4.11-add-permobj.html)
* [4.12 - Delete Permission Object](4.12-delete-permobj.html)
+* [4.13 - Add Permission](4.13-add-permission.html)
+* [4.14 - Delete Permission](4.14-delete-permission.html)
diff --git a/source/fortress/user-guide/4.12-delete-permobj.md b/source/fortress/user-guide/4.12-delete-permobj.md
index 1fcf2216..c51c0c9e 100644
--- a/source/fortress/user-guide/4.12-delete-permobj.md
+++ b/source/fortress/user-guide/4.12-delete-permobj.md
@@ -4,6 +4,8 @@ navPrev: 4.11-add-permobj.html
navPrevText: 4.11 - Add Permission Object
navUp: 4-fortress-code-samples.html
navUpText: 4 - Fortress Code Samples
+navNext: 4.13-add-permission.html
+navNextText: 4.13 - Add Permission
---
# 4.8 - Delete Permission Object
@@ -60,7 +62,7 @@ public static void testDelPermObjects(String objName)
assertTrue(szLocation + " excep id check", se.getErrorId() == GlobalErrIds.PERM_OBJ_NOT_FOUND);
// pass
}
- LOG.info(szLocation + " permission object [" + TEST_PERM_OBJECT + "] success");
+ LOG.info(szLocation + " delete permission object [" + objName + "] success");
}
catch (SecurityException ex)
{
diff --git a/source/fortress/user-guide/4.13-add-permission.md b/source/fortress/user-guide/4.13-add-permission.md
new file mode 100644
index 00000000..33dd6a4b
--- /dev/null
+++ b/source/fortress/user-guide/4.13-add-permission.md
@@ -0,0 +1,82 @@
+---
+title: 4.13 - Add Permission
+navPrev: 4.12-delete-permobj.html
+navPrevText: 4.12 - Delete Permission Object
+navUp: 4-fortress-code-samples.html
+navUpText: 4 - Fortress Code Samples
+navNext: 4.14-delete-permission.html
+navNextText: 4.14 - Delete Permission
+---
+
+# 4.13 - Add Permission
+
+```java
+Permission addPermission(Permission perm) throws SecurityException
+```
+
+This method will add permission operation to an existing permission object.
+The perm operation entity may have Role or User associations.
+The target Permission} must not exist prior to calling.
+A Fortress Permission instance exists in a hierarchical, one-many relationship between its parent: (PermObj->Permission).
+
+required parameters:
+- Permission#objName - contains the name of existing object being targeted for the permission add
+- Permission#opName - contains the name of new permission operation being added
+
+optional parameters:
+- Permission#roles * - multi occurring attribute contains RBAC Roles that permission operation is being granted to
+- Permission#users * - multi occurring attribute contains Users that permission operation is being granted to
+- Permission#props * - multi-occurring property key and values are separated with a ':'. e.g. mykey1:myvalue1
+- Permission#type - any safe text
+
+Parameters:
+- perm - must contain the object, org.apache.directory.fortress.core.model.Permission#objName, and operation, Permission#opName, that identifies target along with optional other attributes.
+
+Returns:
+- copy of Permission entity
+
+Throws:
+- SecurityException - thrown in the event of perm object data or system error.
+
+## addPermission
+
+```java
+import org.apache.directory.fortress.core.AdminMgr;
+import org.apache.directory.fortress.core.AdminMgrFactory;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.ReviewMgr;
+import org.apache.directory.fortress.core.ReviewMgrFactory;
+import org.apache.directory.fortress.core.model.Permission;
+import org.apache.directory.fortress.core.SecurityException;
+
+@test
+public static void testAddPermission(String objName, String operation)
+{
+ String szLocation = ".testAddPermissions";
+ try
+ {
+ AdminMgr adminMgr = AdminMgrFactory.createInstance();
+ // The Permission entity is associated with PermObj (name) entity and is uniquely identified by Operation name:
+ Permission inPerm = new Permission(objName, operation);
+
+ // The Permission entity will be a child node of specified PermObject entity.
+ adminMgr.addPermission(inPerm);
+
+ // Instantiate the ReviewMgr implementation which is used to interrogate policy information.
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();
+
+ // now read the newly created Permission entity back.
+ Permission outPerm = reviewMgr.readPermission(inPerm);
+
+ // Do some validations.
+ assertNotNull(outPerm);
+ assertTrue(szLocation + " failed permission check", outPerm.equals(inPerm));
+ LOG.info(szLocation + " permission object [" + outPerm.getObjName() + "] operation name [" + outPerm.getOpName() + "] success");
+ }
+ catch (SecurityException ex)
+ {
+ LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
+ fail(ex.getMessage());
+ }
+}
+```
diff --git a/source/fortress/user-guide/4.12-delete-permobj.md b/source/fortress/user-guide/4.14-delete-permission.md
similarity index 51%
copy from source/fortress/user-guide/4.12-delete-permobj.md
copy to source/fortress/user-guide/4.14-delete-permission.md
index 1fcf2216..bb0f2ca9 100644
--- a/source/fortress/user-guide/4.12-delete-permobj.md
+++ b/source/fortress/user-guide/4.14-delete-permission.md
@@ -1,30 +1,32 @@
---
-title: 4.12 - Delete Permission Object
-navPrev: 4.11-add-permobj.html
-navPrevText: 4.11 - Add Permission Object
+title: 4.14 - Delete Permission
+navPrev: 4.13-add-permission.html
+navPrevText: 4.13 - Add Permission
navUp: 4-fortress-code-samples.html
navUpText: 4 - Fortress Code Samples
---
-# 4.8 - Delete Permission Object
+# 4.14 - Delete Permission
```java
-void deletePermObj(PermObj pObj) throws SecurityException
+void deletePermission(Permission perm) throws SecurityException
```
-This method will remove permission object to perms container in directory.
-This method will also remove in associated permission objects that are attached to this object.
+This method will remove permission operation entity from permission object.
+A Fortress permission is (object->operation).
+The perm operation must exist before making this call.
required parameters:
-- PermObj#objName - contains the name of existing object targeted for removal
+- Permission#objName - contains the name of existing object being targeted for the permission delete
+- Permission#opName - contains the name of existing permission operation being removed
Parameters:
-- pObj - must contain the PermObj#objName of object targeted for removal.
+- perm - must contain the object, Permission#objName, and operation, Permission#opName, that identifies target.
Throws:
- SecurityException - thrown in the event of perm object data or system error.
-## deletePermObj
+## deletePermission
```java
import org.apache.directory.fortress.core.AdminMgr;
@@ -32,35 +34,36 @@ import org.apache.directory.fortress.core.AdminMgrFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.ReviewMgr;
import org.apache.directory.fortress.core.ReviewMgrFactory;
-import org.apache.directory.fortress.core.model.PermObj;
+import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.SecurityException;
@test
-public static void testDelPermObjects(String objName)
+public static void testDelPermission(String objName)
{
- String szLocation = ".testDelPermObjects";
+ String szLocation = ".testDelPermission";
try
{
// Instantiate the AdminMgr implementation which is used to provision RBAC policies.
AdminMgr adminMgr = AdminMgrFactory.createInstance();
- // this will remove the object along with any operations associated with it:
- adminMgr.deletePermObj(new PermObj(deletePermObj));
+ // this will remove the permission:
+ Permission inPerm = new Permission(objName, operation);
+ adminMgr.deletePermission(inPerm);
// Instantiate the ReviewMgr implementation which is used to interrogate policy information.
ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();
try
{
// this should fail:
- reviewMgr.readPermObj(new PermObj(objName));
- fail(szLocation + " permission object delete failed");
+ reviewMgr.readPermission(new Permission(objName, operation));
+ fail(szLocation + " permission delete failed");
}
catch (SecurityException se)
{
- assertTrue(szLocation + " excep id check", se.getErrorId() == GlobalErrIds.PERM_OBJ_NOT_FOUND);
+ assertTrue(szLocation + " excep id check", se.getErrorId() == GlobalErrIds.PERM_OP_NOT_FOUND);
// pass
}
- LOG.info(szLocation + " permission object [" + TEST_PERM_OBJECT + "] success");
+ LOG.info(szLocation + " delete permission success");
}
catch (SecurityException ex)
{