You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by cp...@apache.org on 2016/04/22 13:58:05 UTC

[1/2] directory-fortress-core git commit: FC-168 added property to allow userPassword field to not be created when new user created

Repository: directory-fortress-core
Updated Branches:
  refs/heads/master 492a4a12b -> 615915f78


FC-168 added property to allow userPassword field to not be created when new user created


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

Branch: refs/heads/master
Commit: 649906fd7a35a24b3741e1838ed7a9f4257152f7
Parents: 492a4a1
Author: clp207 <cl...@psu.edu>
Authored: Thu Apr 21 16:33:46 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Thu Apr 21 16:33:46 2016 -0400

----------------------------------------------------------------------
 config/fortress.properties.src                  |  6 +++-
 .../directory/fortress/core/GlobalIds.java      |  5 +++
 .../directory/fortress/core/impl/UserDAO.java   | 34 +++++++++++---------
 3 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/649906fd/config/fortress.properties.src
----------------------------------------------------------------------
diff --git a/config/fortress.properties.src b/config/fortress.properties.src
index 291e61a..e5b56c5 100755
--- a/config/fortress.properties.src
+++ b/config/fortress.properties.src
@@ -103,4 +103,8 @@ GroupTest=org.apache.directory.fortress.core.group.GroupAntTest
 #policymgr.implementation=org.apache.directory.fortress.core.rest.PwPolicyMgrOtherImpl
 #delegated.accessmgr.implementation=org.apache.directory.fortress.core.rest.DelAccessMgrOtherImpl
 #auditmgr.implementation=org.apache.directory.fortress.core.rest.AuditMgrOtherImpl
-#configmgr.implementation=org.apache.directory.fortress.core.rest.ConfigMgrOtherImpl
\ No newline at end of file
+#configmgr.implementation=org.apache.directory.fortress.core.rest.ConfigMgrOtherImpl
+
+# Default behaviour when creating a user with no password is to set userPassword set to an empty string. 
+#The Fortress API will not allow auth binding if password is empty string or null, but enabling this property will cause the userPassword field to not be created. 
+#user.creation.field.password.disable=false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/649906fd/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
index 51bb710..53fd52b 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
@@ -528,4 +528,9 @@ public final class GlobalIds
      */
     public static final String ALL = "all";
     public static final String NULL = "null";
+    
+    /**
+     * When this property is set to true in fortress.properties, the userPassword field on newly created users will not be created.
+     */
+    public static final String USER_CREATION_PASSWORD_FIELD = "user.creation.field.password.disable";
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/649906fd/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 eed8bb4..451df64 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
@@ -49,10 +49,21 @@ import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
 import org.apache.directory.api.ldap.model.message.BindResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.fortress.core.CreateException;
+import org.apache.directory.fortress.core.FinderException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.PasswordException;
+import org.apache.directory.fortress.core.RemoveException;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.UpdateException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
 import org.apache.directory.fortress.core.model.Address;
 import org.apache.directory.fortress.core.model.AdminRole;
 import org.apache.directory.fortress.core.model.ConstraintUtil;
+import org.apache.directory.fortress.core.model.ObjectFactory;
 import org.apache.directory.fortress.core.model.OrgUnit;
+import org.apache.directory.fortress.core.model.PropUtil;
 import org.apache.directory.fortress.core.model.PwMessage;
 import org.apache.directory.fortress.core.model.Role;
 import org.apache.directory.fortress.core.model.Session;
@@ -60,21 +71,10 @@ import org.apache.directory.fortress.core.model.User;
 import org.apache.directory.fortress.core.model.UserAdminRole;
 import org.apache.directory.fortress.core.model.UserRole;
 import org.apache.directory.fortress.core.model.Warning;
-import org.apache.directory.fortress.core.model.PropUtil;
+import org.apache.directory.fortress.core.util.Config;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.CreateException;
-import org.apache.directory.fortress.core.FinderException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
-import org.apache.directory.fortress.core.PasswordException;
-import org.apache.directory.fortress.core.RemoveException;
-import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.UpdateException;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
 
 
 /**
@@ -432,10 +432,12 @@ final class UserDAO extends LdapDataProvider
 
             myEntry.add( SchemaConstants.SN_AT, entity.getSn() );
 
-            // guard against npe
-            myEntry.add( SchemaConstants.USER_PASSWORD_AT, ArrayUtils.isNotEmpty( entity.getPassword() ) ? new
-                String( entity.getPassword() ) : new String( new char[]
-                    {} ) );
+            if( !Config.getBoolean( GlobalIds.USER_CREATION_PASSWORD_FIELD, false ) ) {
+	            myEntry.add( SchemaConstants.USER_PASSWORD_AT, ArrayUtils.isNotEmpty( entity.getPassword() ) ? new
+	                String( entity.getPassword() ) : new String( new char[]
+	                    {} ) );
+            }
+            
             myEntry.add( SchemaConstants.DISPLAY_NAME_AT, entity.getCn() );
 
             if ( StringUtils.isNotEmpty( entity.getTitle() ) )


[2/2] directory-fortress-core git commit: FC-168 fixed logic to still set userPassword if provided

Posted by cp...@apache.org.
FC-168 fixed logic to still set userPassword if provided


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

Branch: refs/heads/master
Commit: 615915f78a84cb6eb2ab164c592deaf4367a917e
Parents: 649906f
Author: clp207 <cl...@psu.edu>
Authored: Fri Apr 22 07:56:25 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Fri Apr 22 07:56:25 2016 -0400

----------------------------------------------------------------------
 .../org/apache/directory/fortress/core/impl/UserDAO.java    | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/615915f7/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 451df64..dad0914 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
@@ -432,10 +432,11 @@ final class UserDAO extends LdapDataProvider
 
             myEntry.add( SchemaConstants.SN_AT, entity.getSn() );
 
-            if( !Config.getBoolean( GlobalIds.USER_CREATION_PASSWORD_FIELD, false ) ) {
-	            myEntry.add( SchemaConstants.USER_PASSWORD_AT, ArrayUtils.isNotEmpty( entity.getPassword() ) ? new
-	                String( entity.getPassword() ) : new String( new char[]
-	                    {} ) );
+            if( ArrayUtils.isNotEmpty( entity.getPassword() )){
+                myEntry.add( SchemaConstants.USER_PASSWORD_AT, new String( entity.getPassword() ) );
+            }
+            else if( !Config.getBoolean( GlobalIds.USER_CREATION_PASSWORD_FIELD, false ) ) {
+	            myEntry.add( SchemaConstants.USER_PASSWORD_AT, new String( new char[]{} ) );
             }
             
             myEntry.add( SchemaConstants.DISPLAY_NAME_AT, entity.getCn() );