directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r328677 - /directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/
Date Wed, 26 Oct 2005 17:02:23 GMT
Author: elecharny
Date: Wed Oct 26 10:02:10 2005
New Revision: 328677

URL: http://svn.apache.org/viewcvs?rev=328677&view=rev
Log:
Modified the Handler in order to avoid to feed the matchedDN in 
cases where it's not allowed by the RFC

Modified:
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
    directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java
Wed Oct 26 10:02:10 2005
@@ -83,14 +83,18 @@
             resp.getLdapResult().setResultCode( code );
             resp.getLdapResult().setErrorMessage( msg );
             
-            if ( ( e.getResolvedName() != null ) &&
-                 ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
-                   ( code == ResultCodeEnum.ALIASPROBLEM ) ||
-                   ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
-                   ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+            if ( e instanceof NamingException )
             {
-                resp.getLdapResult().setMatchedDn(
-                        e.getResolvedName().toString() );
+            	NamingException ne = (NamingException)e;
+            	
+                if ( ( ne.getResolvedName() != null ) &&
+                        ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                          ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                          ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                          ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+                {
+                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                }
             }
 
             session.write( resp );

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
Wed Oct 26 10:02:10 2005
@@ -26,7 +26,6 @@
 import javax.naming.spi.InitialContextFactory;
 
 import org.apache.asn1new.util.StringUtils;
-import org.apache.asn1new.util.StringUtilsTest;
 import org.apache.ldap.common.exception.LdapException;
 import org.apache.ldap.common.message.BindRequest;
 import org.apache.ldap.common.message.BindResponse;
@@ -44,8 +43,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
-
 /**
  * A single reply handler for {@link org.apache.ldap.common.message.BindRequest}s.
  *
@@ -144,13 +141,18 @@
                 msg += "\n\nBindRequest = \n" + req.toString();
             }
 
-            if ( ( e.getResolvedName() != null ) &&
-                    ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
-                      ( code == ResultCodeEnum.ALIASPROBLEM ) ||
-                      ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
-                      ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+            if ( e instanceof NamingException )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+            	NamingException ne = (NamingException)e;
+            	
+                if ( ( ne.getResolvedName() != null ) &&
+                        ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                          ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                          ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                          ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+                {
+                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                }
             }
             
             result.setErrorMessage( msg );

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
Wed Oct 26 10:02:10 2005
@@ -44,7 +44,7 @@
  */
 public class CompareHandler implements MessageHandler
 {
-    private static final Logger LOG = LoggerFactory.getLogger( CompareHandler.class );
+    private static final Logger log = LoggerFactory.getLogger( CompareHandler.class );
 
     public void messageReceived( ProtocolSession session, Object request )
     {
@@ -57,6 +57,7 @@
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
             ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
             LdapName name = new LdapName( req.getName() );
+            
             if ( newCtx.compare( name, req.getAttributeId(), req.getAssertionValue() ) )
             {
                 resp.getLdapResult().setResultCode( ResultCodeEnum.COMPARETRUE );
@@ -70,12 +71,13 @@
         {
             String msg = "failed to compare entry " + req.getName();
 
-            if ( LOG.isDebugEnabled() )
+            if ( log.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
             }
 
             ResultCodeEnum code;
+            
             if ( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode() ;
@@ -90,9 +92,15 @@
 
             if ( e instanceof NamingException )
             {
-                if ( ( ( NamingException ) e ).getResolvedName() != null )
+            	NamingException ne = (NamingException)e;
+            	
+                if ( ( ne.getResolvedName() != null ) &&
+                        ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                          ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                          ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                          ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
                 {
-                    resp.getLdapResult().setMatchedDn( ( ( NamingException ) e ).getResolvedName().toString()
);
+                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
                 }
             }
 

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
Wed Oct 26 10:02:10 2005
@@ -78,9 +78,18 @@
             resp.getLdapResult().setResultCode( code );
             resp.getLdapResult().setErrorMessage( msg );
 
-            if( e.getResolvedName() != null )
+            if ( e instanceof NamingException )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+            	NamingException ne = (NamingException)e;
+            	
+                if ( ( ne.getResolvedName() != null ) &&
+                        ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                          ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                          ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                          ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+                {
+                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                }
             }
 
             session.write( resp );
@@ -88,7 +97,6 @@
         }
 
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-        resp.getLdapResult().setMatchedDn( req.getName() );
         session.write( resp );
     }
 }

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
Wed Oct 26 10:02:10 2005
@@ -75,6 +75,7 @@
         ExtendedResponse res = new ExtendedResponseImpl( req.getMessageId() );
 
         ExtendedOperationHandler handler = ( ExtendedOperationHandler ) handlers.get( req.getOid()
);
+        
         if( handler == null )
         {
             res.setLdapResult( new LdapResultImpl( res ) );

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
Wed Oct 26 10:02:10 2005
@@ -91,6 +91,7 @@
             }
 
             ResultCodeEnum code;
+            
             if ( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode() ;
@@ -103,9 +104,18 @@
             resp.getLdapResult().setResultCode( code );
             resp.getLdapResult().setErrorMessage( msg );
 
-            if ( e.getResolvedName() != null )
+            if ( e instanceof NamingException )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+            	NamingException ne = (NamingException)e;
+            	
+                if ( ( ne.getResolvedName() != null ) &&
+                        ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                          ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                          ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                          ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+                {
+                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                }
             }
 
             session.write( resp );
@@ -113,7 +123,6 @@
         }
 
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-        resp.getLdapResult().setMatchedDn( req.getName() );
         session.write( resp );
     }
 }

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
Wed Oct 26 10:02:10 2005
@@ -81,9 +81,18 @@
             resp.getLdapResult().setResultCode( code );
             resp.getLdapResult().setErrorMessage( msg );
 
-            if ( e.getResolvedName() != null )
+            if ( e instanceof NamingException )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+            	NamingException ne = (NamingException)e;
+            	
+                if ( ( ne.getResolvedName() != null ) &&
+                        ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                          ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                          ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                          ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+                {
+                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                }
             }
 
             session.write( resp );
@@ -91,7 +100,6 @@
         }
 
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-        resp.getLdapResult().setMatchedDn( req.getName() );
         session.write( resp );
         return;
     }

Modified: directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java?rev=328677&r1=328676&r2=328677&view=diff
==============================================================================
--- directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
(original)
+++ directory/protocol-providers/ldap/branches/protocol-ldap-utf8/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
Wed Oct 26 10:02:10 2005
@@ -1,5 +1,4 @@
 /*
- *   Copyright 2004 The Apache Software Foundation
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -113,7 +112,6 @@
                 SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId()
);
                 resp.setLdapResult( new LdapResultImpl( resp ) );
                 resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-                resp.getLdapResult().setMatchedDn( req.getBase() );
                 Iterator it = Collections.singleton( resp ).iterator();
 
                 while( it.hasNext() )
@@ -134,28 +132,33 @@
             }
 
             SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId() );
-            ResultCodeEnum rc = null;
+            ResultCodeEnum code = null;
 
             if( e instanceof LdapException )
             {
-                rc = ( ( LdapException ) e ).getResultCode();
+                code = ( ( LdapException ) e ).getResultCode();
             }
             else
             {
-                rc = ResultCodeEnum.getBestEstimate( e, req.getType() );
+                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
             }
 
             resp.setLdapResult( new LdapResultImpl( resp ) );
-            resp.getLdapResult().setResultCode( rc );
+            resp.getLdapResult().setResultCode( code );
             resp.getLdapResult().setErrorMessage( msg );
 
-            if( e.getResolvedName() != null )
+            if ( e instanceof NamingException )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
-            }
-            else
-            {
-                resp.getLdapResult().setMatchedDn( "" );
+            	NamingException ne = (NamingException)e;
+            	
+                if ( ( ne.getResolvedName() != null ) &&
+                        ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                          ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                          ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                          ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+                {
+                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                }
             }
 
             Iterator it = Collections.singleton( resp ).iterator();
@@ -179,30 +182,35 @@
 
         SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId() );
 
-        ResultCodeEnum rc = null;
+        ResultCodeEnum code = null;
 
         if( e instanceof LdapException )
         {
-            rc = ( ( LdapException ) e ).getResultCode();
+        	code = ( ( LdapException ) e ).getResultCode();
         }
         else
         {
-            rc = ResultCodeEnum.getBestEstimate( e, req.getType() );
+        	code = ResultCodeEnum.getBestEstimate( e, req.getType() );
         }
 
         resp.setLdapResult( new LdapResultImpl( resp ) );
 
-        resp.getLdapResult().setResultCode( rc );
+        resp.getLdapResult().setResultCode( code );
 
         resp.getLdapResult().setErrorMessage( msg );
 
-        if( e.getResolvedName() != null )
+        if ( e instanceof NamingException )
         {
-            resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
-        }
-        else
-        {
-            resp.getLdapResult().setMatchedDn( "" );
+        	NamingException ne = (NamingException)e;
+        	
+            if ( ( ne.getResolvedName() != null ) &&
+                    ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
+                      ( code == ResultCodeEnum.ALIASPROBLEM ) ||
+                      ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
+                      ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
+            {
+                resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+            }
         }
 
         return resp;
@@ -363,8 +371,6 @@
                     respDone.setLdapResult( new LdapResultImpl( respDone ) );
 
                     respDone.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-
-                    respDone.getLdapResult().setMatchedDn( req.getBase() );
 
                     prefetched = null;
 



Mime
View raw message