directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1508543 - in /directory: apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/ shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/
Date Tue, 30 Jul 2013 17:36:19 GMT
Author: pamarcelot
Date: Tue Jul 30 17:36:19 2013
New Revision: 1508543

URL: http://svn.apache.org/r1508543
Log:
Added a new constructor with diagnostic message.
Used that new constructor in the handler to report better information to the user in the case
something went wrong.

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
    directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/PwdModifyResponseImpl.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java?rev=1508543&r1=1508542&r2=1508543&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
Tue Jul 30 17:36:19 2013
@@ -103,7 +103,7 @@ public class PwdModifyHandler implements
                 LOG.error( "Cannot find an entry for DN " + userDn );
                 // We can't find the entry in the DIT
                 requestor.getIoSession().write( new PwdModifyResponseImpl(
-                    req.getMessageId(), ResultCodeEnum.NO_SUCH_OBJECT ) );
+                    req.getMessageId(), ResultCodeEnum.NO_SUCH_OBJECT, "Cannot find an entry
for DN " + userDn ) );
 
                 return;
             }
@@ -112,8 +112,10 @@ public class PwdModifyHandler implements
         {
             LOG.error( "Cannot find an entry for DN " + userDn + ", exception : " + le.getMessage()
);
             // We can't find the entry in the DIT
-            requestor.getIoSession().write( new PwdModifyResponseImpl(
-                req.getMessageId(), ResultCodeEnum.NO_SUCH_OBJECT ) );
+            requestor.getIoSession().write(
+                new PwdModifyResponseImpl(
+                    req.getMessageId(), ResultCodeEnum.NO_SUCH_OBJECT, "Cannot find an entry
for DN " + userDn
+                        + ", exception : " + le.getMessage() ) );
 
             return;
         }
@@ -165,7 +167,8 @@ public class PwdModifyHandler implements
             LOG.error( "Cannot modify the password for user " + userDn + ", exception : "
+ le.getMessage() );
             // We can't modify the password
             requestor.getIoSession().write( new PwdModifyResponseImpl(
-                req.getMessageId(), ResultCodeEnum.INVALID_CREDENTIALS ) );
+                req.getMessageId(), ResultCodeEnum.INVALID_CREDENTIALS, "Cannot modify the
password for user "
+                    + userDn + ", exception : " + le.getMessage() ) );
 
             return;
         }
@@ -226,8 +229,10 @@ public class PwdModifyHandler implements
         {
             LOG.error( "Cannot modify the password for user " + principalDn + ", exception
: " + le.getMessage() );
             // We can't modify the password
-            requestor.getIoSession().write( new PwdModifyResponseImpl(
-                req.getMessageId(), ResultCodeEnum.INVALID_CREDENTIALS ) );
+            requestor.getIoSession().write(
+                new PwdModifyResponseImpl( req.getMessageId(), ResultCodeEnum.INVALID_CREDENTIALS,
+                    "Cannot modify the password for user "
+                        + principalDn + ", exception : " + le.getMessage() ) );
 
             return;
         }
@@ -258,8 +263,7 @@ public class PwdModifyHandler implements
                 LOG.error( "The user DN is invalid : " + userDn );
                 // The userIdentity is not a DN : return with an error code.
                 requestor.getIoSession().write( new PwdModifyResponseImpl(
-                    req.getMessageId(), ResultCodeEnum.INVALID_DN_SYNTAX ) );
-
+                    req.getMessageId(), ResultCodeEnum.INVALID_DN_SYNTAX, "The user DN is
invalid : " + userDn ) );
                 return;
             }
         }
@@ -284,7 +288,8 @@ public class PwdModifyHandler implements
                     // No : error
                     LOG.error( "Cannot access to another user's password to modify it" );
                     requestor.getIoSession().write( new PwdModifyResponseImpl(
-                        req.getMessageId(), ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS ) );
+                        req.getMessageId(), ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS,
+                        "Cannot access to another user's password to modify it" ) );
                 }
                 else
                 {
@@ -341,8 +346,10 @@ public class PwdModifyHandler implements
             catch ( LdapException le )
             {
                 // We can't modify the password
-                requestor.getIoSession().write( new PwdModifyResponseImpl(
-                    req.getMessageId(), ResultCodeEnum.INVALID_CREDENTIALS ) );
+                requestor.getIoSession().write(
+                    new PwdModifyResponseImpl(
+                        req.getMessageId(), ResultCodeEnum.UNWILLING_TO_PERFORM,
+                        "Cannot modify the password, exception : " + le.getMessage() ) );
 
                 return;
             }

Modified: directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/PwdModifyResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/PwdModifyResponseImpl.java?rev=1508543&r1=1508542&r2=1508543&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/PwdModifyResponseImpl.java
(original)
+++ directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/PwdModifyResponseImpl.java
Tue Jul 30 17:36:19 2013
@@ -20,7 +20,6 @@
 package org.apache.directory.api.ldap.extras.extended;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.util.Strings;
@@ -41,31 +40,31 @@ public class PwdModifyResponseImpl exten
     /** The generated password */
     private byte[] genPassword;
 
-
+    
     /**
      * Create a new instance for the PwdModify response
      * @param messageId The Message ID
      * @param rcode The result code
+     * @param diagnosticMessage The diagnostic message
      */
-    public PwdModifyResponseImpl( int messageId, ResultCodeEnum rcode )
+    public PwdModifyResponseImpl( int messageId, ResultCodeEnum rcode, String diagnosticMessage
)
     {
         super( messageId, EXTENSION_OID );
 
-        switch ( rcode )
-        {
-            case SUCCESS:
-                break;
-
-            case OPERATIONS_ERROR:
-                break;
+        super.getLdapResult().setMatchedDn( null );
+        super.getLdapResult().setResultCode( rcode );
+        super.getLdapResult().setDiagnosticMessage( diagnosticMessage );
+    }
 
-            case INSUFFICIENT_ACCESS_RIGHTS:
-                break;
 
-            default:
-                throw new IllegalArgumentException( I18n.err( I18n.ERR_04166, ResultCodeEnum.SUCCESS,
-                    ResultCodeEnum.OPERATIONS_ERROR, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS
) );
-        }
+    /**
+     * Create a new instance for the PwdModify response
+     * @param messageId The Message ID
+     * @param rcode The result code
+     */
+    public PwdModifyResponseImpl( int messageId, ResultCodeEnum rcode )
+    {
+        super( messageId, EXTENSION_OID );
 
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( rcode );



Mime
View raw message