You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2014/10/21 01:06:36 UTC

[19/50] git commit: FC-137 - Add description to Permission entity

FC-137 - Add description to Permission entity


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

Branch: refs/heads/master
Commit: e65416cf9daf3d1b42d7431bd565eeccecde0500
Parents: 4974c32
Author: Shawn McKinney <sh...@jts.us>
Authored: Mon Jun 30 13:57:59 2014 -0500
Committer: Shawn McKinney <sh...@jts.us>
Committed: Mon Jun 30 13:57:59 2014 -0500

----------------------------------------------------------------------
 build.properties                                |  2 +-
 .../java/org/openldap/fortress/rbac/PermP.java  |  4 ++++
 .../org/openldap/fortress/rbac/Permission.java  | 21 ++++++++++++++++++++
 .../fortress/rbac/dao/apache/PermDAO.java       | 13 ++++++++++++
 .../fortress/rbac/dao/unboundid/PermDAO.java    | 12 +++++++++++
 .../openldap/fortress/rbac/PermTestData.java    |  1 +
 6 files changed, 52 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e65416cf/build.properties
----------------------------------------------------------------------
diff --git a/build.properties b/build.properties
index 0f4d3d1..438286e 100644
--- a/build.properties
+++ b/build.properties
@@ -160,7 +160,7 @@ openldap.root=/opt/symas
 slapd.dir=${openldap.root}/etc/openldap
 # to start debug mode:
 #slapd.start=${openldap.root}/lib/slapd -h ldap://${ldap.host}:${ldap.port} -f ${openldap.root}/etc/openldap/slapd.conf -F ${openldap.root}/etc/openldap -d -1
-pid.dir=/var/symas
+pid.dir=/var/openldap
 
 db.dir=${db.root}/dflt
 db.hist.dir=${db.root}/hist

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e65416cf/src/main/java/org/openldap/fortress/rbac/PermP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/fortress/rbac/PermP.java b/src/main/java/org/openldap/fortress/rbac/PermP.java
index 780d6d9..4108516 100755
--- a/src/main/java/org/openldap/fortress/rbac/PermP.java
+++ b/src/main/java/org/openldap/fortress/rbac/PermP.java
@@ -565,6 +565,10 @@ public final class PermP
         {
             VUtil.description( pOp.getType() );
         }
+        if ( VUtil.isNotNullOrEmpty( pOp.getDescription() ) )
+        {
+            VUtil.description( pOp.getDescription() );
+        }
         // Validate Role Grants:
         if ( VUtil.isNotNullOrEmpty( pOp.getRoles() ) )
         {

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e65416cf/src/main/java/org/openldap/fortress/rbac/Permission.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/fortress/rbac/Permission.java b/src/main/java/org/openldap/fortress/rbac/Permission.java
index 5bd7269..8898d5f 100755
--- a/src/main/java/org/openldap/fortress/rbac/Permission.java
+++ b/src/main/java/org/openldap/fortress/rbac/Permission.java
@@ -207,6 +207,7 @@ import org.openldap.fortress.rbac.dao.UserDAO;
         "objName",
         "opName",
         "objId",
+        "description",
         "abstractName",
         "internalId",
         "type",
@@ -227,6 +228,7 @@ public class Permission extends FortEntity
     private String abstractName;
     private String type;
     private String dn;
+    private String description;
     @XmlElement(nillable = true)
     private Props props = new Props();
     //private Properties props;
@@ -578,6 +580,25 @@ public class Permission extends FortEntity
     }
 
     /**
+     * Return the description field on this entity.  The description is often used as a human readable label for the permission.
+     * @return String containing the description.
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+    /**
+     * Set the optional description field on this entity.  The description is used as a human readable label for the permission.
+     *
+     * @param description String contains the description.
+     */
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    /**
       * Gets the value of the Props property.  This method is used by Fortress and En Masse and should not be called by external programs.
       *
       * @return

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e65416cf/src/main/java/org/openldap/fortress/rbac/dao/apache/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/fortress/rbac/dao/apache/PermDAO.java b/src/main/java/org/openldap/fortress/rbac/dao/apache/PermDAO.java
index 3fa6704..a2a1261 100755
--- a/src/main/java/org/openldap/fortress/rbac/dao/apache/PermDAO.java
+++ b/src/main/java/org/openldap/fortress/rbac/dao/apache/PermDAO.java
@@ -380,6 +380,12 @@ public final class PermDAO extends ApacheDsDataProvider implements org.openldap.
             // create the internal id:
             entry.add( GlobalIds.FT_IID, entity.getInternalId() );
 
+            // description is optional:
+            if ( VUtil.isNotNullOrEmpty( entity.getDescription() ) )
+            {
+                entry.add( GlobalIds.DESC, entity.getDescription() );
+            }
+
             // the abstract name is the human readable identifier:
             entry.add( PERM_NAME, entity.getAbstractName() );
 
@@ -453,6 +459,12 @@ public final class PermDAO extends ApacheDsDataProvider implements org.openldap.
                     ModificationOperation.REPLACE_ATTRIBUTE, PERM_NAME, entity.getAbstractName() ) );
             }
 
+            if ( VUtil.isNotNullOrEmpty( entity.getDescription() ) )
+            {
+                mods.add( new DefaultModification(
+                    ModificationOperation.REPLACE_ATTRIBUTE, GlobalIds.DESC, entity.getDescription() ) );
+            }
+
             if ( VUtil.isNotNullOrEmpty( entity.getType() ) )
             {
 
@@ -997,6 +1009,7 @@ public final class PermDAO extends ApacheDsDataProvider implements org.openldap.
         entity.setRoles( getAttributeSet( le, ROLES ) );
         entity.setUsers( getAttributeSet( le, USERS ) );
         entity.setType( getAttribute( le, TYPE ) );
+        entity.setDescription( getAttribute( le, GlobalIds.DESC ) );
         entity.addProperties( AttrHelper.getProperties( getAttributes( le, GlobalIds.PROPS ) ) );
         entity.setAdmin( isAdmin );
 

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e65416cf/src/main/java/org/openldap/fortress/rbac/dao/unboundid/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/fortress/rbac/dao/unboundid/PermDAO.java b/src/main/java/org/openldap/fortress/rbac/dao/unboundid/PermDAO.java
index 10f47a5..0fbff79 100755
--- a/src/main/java/org/openldap/fortress/rbac/dao/unboundid/PermDAO.java
+++ b/src/main/java/org/openldap/fortress/rbac/dao/unboundid/PermDAO.java
@@ -367,6 +367,11 @@ public final class PermDAO extends UnboundIdDataProvider implements org.openldap
             {
                 attrs.add( createAttribute( POBJ_ID, entity.getObjId() ) );
             }
+            // description is optional:
+            if ( VUtil.isNotNullOrEmpty( entity.getDescription() ) )
+            {
+                attrs.add( createAttribute( GlobalIds.DESC, entity.getDescription() ) );
+            }
             // type is optional:
             if ( VUtil.isNotNullOrEmpty( entity.getType() ) )
             {
@@ -418,6 +423,12 @@ public final class PermDAO extends UnboundIdDataProvider implements org.openldap
         try
         {
             LDAPModificationSet mods = new LDAPModificationSet();
+            if ( VUtil.isNotNullOrEmpty( entity.getDescription() ) )
+            {
+                LDAPAttribute desc = new LDAPAttribute( GlobalIds.DESC,
+                    entity.getDescription() );
+                mods.add( LDAPModification.REPLACE, desc );
+            }
             if ( VUtil.isNotNullOrEmpty( entity.getAbstractName() ) )
             {
                 // the abstract name is the human readable identifier:
@@ -947,6 +958,7 @@ public final class PermDAO extends UnboundIdDataProvider implements org.openldap
         entity.setObjName( getAttribute( le, GlobalIds.POBJ_NAME ) );
         entity.setObjId( getAttribute( le, POBJ_ID ) );
         entity.setOpName( getAttribute( le, GlobalIds.POP_NAME ) );
+        entity.setDescription( getAttribute( le, GlobalIds.DESC ) );
         entity.setInternalId( getAttribute( le, GlobalIds.FT_IID ) );
         entity.setRoles( getAttributeSet( le, ROLES ) );
         entity.setUsers( getAttributeSet( le, USERS ) );

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e65416cf/src/test/java/org/openldap/fortress/rbac/PermTestData.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/openldap/fortress/rbac/PermTestData.java b/src/test/java/org/openldap/fortress/rbac/PermTestData.java
index 82684ae..ae5ae83 100755
--- a/src/test/java/org/openldap/fortress/rbac/PermTestData.java
+++ b/src/test/java/org/openldap/fortress/rbac/PermTestData.java
@@ -2776,6 +2776,7 @@ public class PermTestData extends TestCase
         pOp.setObjName( objName );
         pOp.setObjId( getObjId( op ) );
         pOp.setOpName( getName( op ) );
+        pOp.setDescription( getDescription( op ) );
         //pOp.setAbstractName(pOp.getObjName() + "." + pOp.getOpName());
         pOp.setType( getType( op ) );
         pOp.setAdmin( isOpAdmin( op ) );