directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r692922 - in /directory: apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/
Date Sun, 07 Sep 2008 19:23:46 GMT
Author: akarasulu
Date: Sun Sep  7 12:23:46 2008
New Revision: 692922

URL: http://svn.apache.org/viewvc?rev=692922&view=rev
Log:
DIRSERVER-1148: Adding the name of the result code enumeration to error messages for better
comprehension of result codes

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/NoticeOfDisconnect.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java?rev=692922&r1=692921&r2=692922&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
Sun Sep  7 12:23:46 2008
@@ -199,7 +199,7 @@
                 result.setResultCode( code );
             }
 
-            String msg = "Bind failed: " + e.getMessage();
+            String msg = code.toString() + ": Bind failed: " + e.getMessage();
 
             if ( LOG.isDebugEnabled() )
             {
@@ -211,7 +211,7 @@
             
             if ( e instanceof LdapAuthenticationException )
             {
-            	name = ((LdapAuthenticationException)e).getResolvedName();
+            	name = ( ( LdapAuthenticationException ) e ).getResolvedName();
             }
             
             if ( ( name != null )
@@ -310,7 +310,8 @@
         {
             LOG.error( se.getMessage() );
             result.setResultCode( ResultCodeEnum.INVALID_CREDENTIALS );
-            result.setErrorMessage( se.getMessage() );
+            result.setErrorMessage( ResultCodeEnum.INVALID_CREDENTIALS.toString() + ": "

+                + se.getMessage() );
             
             // Reinitialize the state to Anonymous and clear the sasl properties
             ldapSession.clearSaslProperties();
@@ -335,7 +336,8 @@
         // And send the response to the client
         LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
         bindResult.setResultCode( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
-        bindResult.setErrorMessage( bindRequest.getSaslMechanism() + " is not a supported
mechanism." );
+        bindResult.setErrorMessage( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED.toString() +
": " 
+            + bindRequest.getSaslMechanism() + " is not a supported mechanism." );
         
         // Write back the error
         ldapSession.getIoSession().write( bindRequest.getResultResponse() );
@@ -356,7 +358,11 @@
         
         if ( e != null )
         {
-            message = e.getMessage();
+            message = ResultCodeEnum.INVALID_CREDENTIALS + ": " + e.getMessage();
+        }
+        else
+        {
+            message = ResultCodeEnum.INVALID_CREDENTIALS.toString();
         }
         
         LOG.error( message );
@@ -483,7 +489,9 @@
             }
             catch ( Exception e )
             {
-                
+                // TODO - why is this exception being ignored?  Isn't this 
+                // really bad?
+                LOG.error( "Exception encountered while processing Sasl BindRequest", e );
             }
         }
     }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java?rev=692922&r1=692921&r2=692922&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
Sun Sep  7 12:23:46 2008
@@ -61,7 +61,8 @@
         {
             LdapResult result = req.getResultResponse().getLdapResult();
             result.setResultCode( ResultCodeEnum.OTHER );
-            result.setErrorMessage( "Extended operation handler for the specified EXTENSION_OID
(" + req.getOid()
+            result.setErrorMessage( ResultCodeEnum.OTHER  
+                + ": Extended operation handler for the specified EXTENSION_OID (" + req.getOid()
                 + ") has failed to process your request:\n" + ExceptionUtils.getStackTrace(
e ) );
             ExtendedResponse resp = ( ExtendedResponse ) req.getResultResponse();
             resp.setResponse( new byte[0] );

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java?rev=692922&r1=692921&r2=692922&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
Sun Sep  7 12:23:46 2008
@@ -779,18 +779,12 @@
      */
     public void handleException( LdapSession session, T req, Exception e )
     {
-        String msg = "failed for " + req + ": " + e.getMessage();
-        LOG.error( msg, e );
         LdapResult result = req.getResultResponse().getLdapResult();
 
-
-        if ( IS_DEBUG )
-        {
-            msg += ":\n" + ExceptionUtils.getStackTrace( e );
-        }
-
+        /*
+         * Set the result code or guess the best option.
+         */
         ResultCodeEnum code;
-
         if ( e instanceof LdapException )
         {
             code = ( ( LdapException ) e ).getResultCode();
@@ -799,8 +793,19 @@
         {
             code = ResultCodeEnum.getBestEstimate( e, req.getType() );
         }
-
         result.setResultCode( code );
+
+        /*
+         * Setup the error message to put into the request and put entire
+         * exception into the message if we are in debug mode.  Note we 
+         * embed the result code name into the message.
+         */
+        String msg = code.toString() + ": failed for " + req + ": " + e.getMessage();
+        LOG.error( msg, e );
+        if ( IS_DEBUG )
+        {
+            msg += ":\n" + ExceptionUtils.getStackTrace( e );
+        }
         result.setErrorMessage( msg );
 
         if ( e instanceof NamingException )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/NoticeOfDisconnect.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/NoticeOfDisconnect.java?rev=692922&r1=692921&r2=692922&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/NoticeOfDisconnect.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/NoticeOfDisconnect.java
Sun Sep  7 12:23:46 2008
@@ -116,7 +116,7 @@
     public static final NoticeOfDisconnect STRONGAUTHREQUIRED = new NoticeOfDisconnect( ResultCodeEnum.STRONG_AUTH_REQUIRED
);
 
 
-    private NoticeOfDisconnect(ResultCodeEnum rcode)
+    private NoticeOfDisconnect( ResultCodeEnum rcode )
     {
         super( 0, EXTENSION_OID );
 
@@ -136,7 +136,7 @@
                     + ", " + ResultCodeEnum.PROTOCOL_ERROR + ", " + ResultCodeEnum.STRONG_AUTH_REQUIRED
);
         }
         
-        super.getLdapResult().setErrorMessage( "The server will disconnect!" );
+        super.getLdapResult().setErrorMessage( rcode.toString() + ": The server will disconnect!"
);
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( rcode );
     }
@@ -146,6 +146,7 @@
     // ExtendedResponse Interface Method Implementations
     // ------------------------------------------------------------------------
 
+    
     /**
      * Gets the reponse OID specific encoded response values.
      * 



Mime
View raw message