directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1233925 [1/3] - in /directory/shared/trunk: dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/ dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ dsml/parser/src/test/java/org/apache/directory/shared/ds...
Date Fri, 20 Jan 2012 14:28:26 GMT
Author: pamarcelot
Date: Fri Jan 20 14:28:25 2012
New Revision: 1233925

URL: http://svn.apache.org/viewvc?rev=1233925&view=rev
Log:
Fix for DIRAPI-68 (Unable to bind on an Active Directory server using 'domain\userid').

Modified:
    directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
    directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BindRequestDsml.java
    directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
    directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/authRequest/AuthRequestTest.java
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitSaslBind.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreName.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/BindRequestDecorator.java
    directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindRequestPerfTest.java
    directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindRequestTest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/BindRequest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/BindRequestImpl.java
    directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/BindRequestImplTest.java

Modified: directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java?rev=1233925&r1=1233924&r2=1233925&view=diff
==============================================================================
--- directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
(original)
+++ directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
Fri Jan 20 14:28:25 2012
@@ -83,7 +83,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.SearchResultDone;
 import org.apache.directory.shared.ldap.model.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.model.message.SearchResultReference;
-import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.util.Strings;
 import org.dom4j.Element;
 import org.dom4j.Namespace;
@@ -123,7 +122,7 @@ public class Dsmlv2Engine
 
     /** The batch response. */
     protected BatchResponseDsml batchResponse = new BatchResponseDsml();
-    
+
     protected Dsmlv2Grammar grammar = new Dsmlv2Grammar();
 
     /** flag to indicate to generate the response in a SOAP envelope */
@@ -131,6 +130,7 @@ public class Dsmlv2Engine
 
     private static final Logger LOG = LoggerFactory.getLogger( Dsmlv2Engine.class );
 
+
     /**
      * Creates a new instance of Dsmlv2Engine.
      * 
@@ -164,7 +164,7 @@ public class Dsmlv2Engine
         this.connection = connection;
     }
 
-    
+
     /**
      * Processes the file given and return the result of the operations
      * 
@@ -215,7 +215,7 @@ public class Dsmlv2Engine
      */
     public void processDSMLFile( File file, OutputStream respStream ) throws Exception
     {
-        parser = new Dsmlv2Parser(grammar);
+        parser = new Dsmlv2Parser( grammar );
         parser.setInputFile( file.getAbsolutePath() );
 
         processDSML( respStream );
@@ -244,12 +244,12 @@ public class Dsmlv2Engine
      */
     public void processDSML( InputStream inputStream, String inputEncoding, OutputStream
out ) throws Exception
     {
-        parser = new Dsmlv2Parser(grammar);
+        parser = new Dsmlv2Parser( grammar );
         parser.setInput( inputStream, inputEncoding );
         processDSML( out );
     }
 
-    
+
     /**
      * Processes the Request document
      * 
@@ -263,11 +263,11 @@ public class Dsmlv2Engine
             processDSML( byteOut );
             return new String( byteOut.toByteArray(), "UTF-8" );
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             LOG.error( "Failed to process the DSML", e );
         }
-        
+
         return null;
     }
 
@@ -282,7 +282,7 @@ public class Dsmlv2Engine
     protected void processDSML( OutputStream outStream ) throws IOException
     {
         BufferedWriter respWriter = null;
-       
+
         if ( outStream != null )
         {
             respWriter = new BufferedWriter( new OutputStreamWriter( outStream ) );
@@ -290,25 +290,25 @@ public class Dsmlv2Engine
             if ( generateSoapResp )
             {
                 respWriter.write( "<Envelope " );
-                
+
                 Namespace soapNs = new Namespace( null, "http://www.w3.org/2001/12/soap-envelope"
);
                 soapNs.write( respWriter );
 
                 respWriter.write( "><Body>" );
             }
-            
+
             respWriter.write( "<batchResponse " );
-            
+
             ParserUtils.DSML_NAMESPACE.write( respWriter );
-            
+
             respWriter.write( " " ); // a space to separate the namespace declarations
-            
+
             ParserUtils.XSD_NAMESPACE.write( respWriter );
-            
+
             respWriter.write( " " ); // a space to separate the namespace declarations
-            
+
             ParserUtils.XSI_NAMESPACE.write( respWriter );
-            
+
             respWriter.write( '>' ); // the end tag
         }
 
@@ -320,7 +320,7 @@ public class Dsmlv2Engine
         catch ( Exception e )
         {
             LOG.warn( "Failed to bind", e );
-            
+
             // Unable to connect to server
             // We create a new ErrorResponse and return the XML response.
             ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.COULD_NOT_CONNECT,
e
@@ -334,7 +334,7 @@ public class Dsmlv2Engine
             {
                 batchResponse.addResponse( errorResponse );
             }
-            
+
             return;
         }
 
@@ -360,7 +360,7 @@ public class Dsmlv2Engine
             {
                 batchResponse.addResponse( errorResponse );
             }
-            
+
             return;
         }
 
@@ -379,9 +379,9 @@ public class Dsmlv2Engine
         catch ( XmlPullParserException e )
         {
             LOG.warn( "Failed while getting next request", e );
-            
+
             int reqId = 0;
-            
+
             // We create a new ErrorResponse and return the XML response.
             ErrorResponse errorResponse = new ErrorResponse( reqId, ErrorResponseType.MALFORMED_REQUEST,
I18n.err(
                 I18n.ERR_03001, e.getLocalizedMessage(), e.getLineNumber(), e.getColumnNumber()
) );
@@ -394,7 +394,7 @@ public class Dsmlv2Engine
             {
                 batchResponse.addResponse( errorResponse );
             }
-            
+
             return;
         }
 
@@ -417,7 +417,7 @@ public class Dsmlv2Engine
                 {
                     batchResponse.addResponse( errorResponse );
                 }
-                
+
                 break;
             }
 
@@ -428,10 +428,11 @@ public class Dsmlv2Engine
             catch ( Exception e )
             {
                 LOG.warn( "Failed to process request", e );
-                
+
                 // We create a new ErrorResponse and return the XML response.
-                ErrorResponse errorResponse = new ErrorResponse( request.getDecorated().getMessageId(),
ErrorResponseType.GATEWAY_INTERNAL_ERROR, I18n.err(
-                    I18n.ERR_03003, e.getMessage() ) );
+                ErrorResponse errorResponse = new ErrorResponse( request.getDecorated().getMessageId(),
+                    ErrorResponseType.GATEWAY_INTERNAL_ERROR, I18n.err(
+                        I18n.ERR_03003, e.getMessage() ) );
                 if ( respWriter != null )
                 {
                     writeResponse( respWriter, errorResponse );
@@ -440,7 +441,7 @@ public class Dsmlv2Engine
                 {
                     batchResponse.addResponse( errorResponse );
                 }
-                
+
                 break;
             }
 
@@ -468,7 +469,7 @@ public class Dsmlv2Engine
                 {
                     batchResponse.addResponse( errorResponse );
                 }
-                
+
                 break;
             }
         }
@@ -476,7 +477,7 @@ public class Dsmlv2Engine
         if ( respWriter != null )
         {
             respWriter.write( "</batchResponse>" );
-            
+
             if ( generateSoapResp )
             {
                 respWriter.write( "</Body>" );
@@ -486,8 +487,8 @@ public class Dsmlv2Engine
             respWriter.flush();
         }
     }
-    
-    
+
+
     /**
      * write the response to the writer of the underlying output stream
      * @param respWriter
@@ -496,13 +497,13 @@ public class Dsmlv2Engine
      */
     protected void writeResponse( BufferedWriter respWriter, DsmlDecorator respDsml ) throws
IOException
     {
-        if( respWriter != null )
+        if ( respWriter != null )
         {
             Element xml = respDsml.toDsml( null );
             xml.write( respWriter );
         }
     }
-    
+
 
     /**
      * @return the generateSoapResp
@@ -521,7 +522,7 @@ public class Dsmlv2Engine
         this.generateSoapResp = generateSoapResp;
     }
 
-    
+
     /**
      * @return the batchResponse
      */
@@ -530,7 +531,7 @@ public class Dsmlv2Engine
         return batchResponse;
     }
 
-    
+
     /**
      * @return the connection
      */
@@ -539,13 +540,14 @@ public class Dsmlv2Engine
         return connection;
     }
 
-    
+
     /**
      * Processes a single request
      * 
      * @param request the request to process
      */
-    protected void processRequest( DsmlDecorator<? extends Request> request, BufferedWriter
respWriter  ) throws Exception
+    protected void processRequest( DsmlDecorator<? extends Request> request, BufferedWriter
respWriter )
+        throws Exception
     {
         ResultCodeEnum resultCode = null;
 
@@ -574,7 +576,8 @@ public class Dsmlv2Engine
             case COMPARE_REQUEST:
                 CompareResponse compareResponse = connection.compare( ( CompareRequest )
request );
                 resultCode = compareResponse.getLdapResult().getResultCode();
-                CompareResponseDsml compareResponseDsml = new CompareResponseDsml( connection.getCodecService(),
compareResponse );
+                CompareResponseDsml compareResponseDsml = new CompareResponseDsml( connection.getCodecService(),
+                    compareResponse );
                 writeResponse( respWriter, compareResponseDsml );
 
                 break;
@@ -590,7 +593,8 @@ public class Dsmlv2Engine
             case EXTENDED_REQUEST:
                 ExtendedResponse extendedResponse = connection.extended( ( ExtendedRequest<?>
) request );
                 resultCode = extendedResponse.getLdapResult().getResultCode();
-                ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml( connection.getCodecService(),
extendedResponse );
+                ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml( connection.getCodecService(),
+                    extendedResponse );
                 writeResponse( respWriter, extendedResponseDsml );
 
                 break;
@@ -598,41 +602,43 @@ public class Dsmlv2Engine
             case MODIFY_REQUEST:
                 ModifyResponse modifyResponse = connection.modify( ( ModifyRequest ) request
);
                 resultCode = modifyResponse.getLdapResult().getResultCode();
-                ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml( connection.getCodecService(),
modifyResponse );
+                ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml( connection.getCodecService(),
+                    modifyResponse );
                 writeResponse( respWriter, modifyResponseDsml );
-                
+
                 break;
 
             case MODIFYDN_REQUEST:
                 ModifyDnResponse modifyDnResponse = connection.modifyDn( ( ModifyDnRequest
) request );
                 resultCode = modifyDnResponse.getLdapResult().getResultCode();
-                ModDNResponseDsml modDNResponseDsml = new ModDNResponseDsml( connection.getCodecService(),
modifyDnResponse );
+                ModDNResponseDsml modDNResponseDsml = new ModDNResponseDsml( connection.getCodecService(),
+                    modifyDnResponse );
                 writeResponse( respWriter, modDNResponseDsml );
-                
+
                 break;
 
             case SEARCH_REQUEST:
                 SearchCursor searchResponses = connection.search( ( SearchRequest ) request
);
-                
+
                 SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService()
);
-                
+
                 if ( respWriter != null )
                 {
                     StringBuilder sb = new StringBuilder();
                     sb.append( "<searchResponse" );
-                    
+
                     if ( request.getDecorated().getMessageId() > 0 )
                     {
                         sb.append( " requestID=\"" );
                         sb.append( request.getDecorated().getMessageId() );
                         sb.append( '"' );
                     }
-                    
+
                     sb.append( '>' );
-                    
+
                     respWriter.write( sb.toString() );
                 }
-                
+
                 while ( searchResponses.next() )
                 {
                     Response searchResponse = searchResponses.get();
@@ -643,7 +649,8 @@ public class Dsmlv2Engine
 
                         SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml(
                             connection.getCodecService(), searchResultEntry );
-                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
searchResultEntryDsml );
+                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
+                            searchResultEntryDsml );
 
                         if ( respWriter != null )
                         {
@@ -660,7 +667,8 @@ public class Dsmlv2Engine
 
                         SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml(
                             connection.getCodecService(), searchResultReference );
-                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
searchResultReferenceDsml );
+                        searchResponseDsml = new SearchResponseDsml( connection.getCodecService(),
+                            searchResultReferenceDsml );
 
                         if ( respWriter != null )
                         {
@@ -678,12 +686,12 @@ public class Dsmlv2Engine
                 if ( srDone != null )
                 {
                     resultCode = srDone.getLdapResult().getResultCode();
-                    
+
                     SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(),
srDone );
-                    
+
                     if ( respWriter != null )
                     {
-                        writeResponse( respWriter, srdDsml);
+                        writeResponse( respWriter, srdDsml );
                         respWriter.write( "</searchResponse>" );
                     }
                     else
@@ -692,7 +700,7 @@ public class Dsmlv2Engine
                         batchResponse.addResponse( searchResponseDsml );
                     }
                 }
-                
+
                 break;
 
             case UNBIND_REQUEST:
@@ -764,16 +772,16 @@ public class Dsmlv2Engine
         {
             return;
         }
-        
+
         if ( connection == null )
         {
             throw new IOException( I18n.err( I18n.ERR_03101_MISSING_CONNECTION_TO ) );
         }
-        
+
         BindRequest bindRequest = new BindRequestImpl();
         bindRequest.setSimple( true );
-        bindRequest.setCredentials( Strings.getBytesUtf8(password) );
-        bindRequest.setName( new Dn( user ) );
+        bindRequest.setCredentials( Strings.getBytesUtf8( password ) );
+        bindRequest.setName( user );
         bindRequest.setVersion3( true );
         bindRequest.setMessageId( messageId );
 

Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BindRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BindRequestDsml.java?rev=1233925&r1=1233924&r2=1233925&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BindRequestDsml.java
(original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BindRequestDsml.java
Fri Jan 20 14:28:25 2012
@@ -78,10 +78,21 @@ public class BindRequestDsml 
 
         BindRequest request = ( BindRequest ) getDecorated();
 
-        // AbandonID
-        String name = request.getName().getName();
-        if ( ( name != null ) && ( !"".equals( name ) ) )
+        // Principal
+        Dn dn = request.getDn();
+
+        if ( !Dn.isNullOrEmpty( dn ) )
+        {
+            // A DN has been provided
+
+            element.addAttribute( "principal", dn.getName() );
+        }
+        else
         {
+            // No DN has been provided, let's use the name as a string instead
+
+            String name = request.getName();
+
             element.addAttribute( "principal", name );
         }
 
@@ -161,7 +172,7 @@ public class BindRequestDsml 
     /**
      * {@inheritDoc}
      */
-    public Dn getName()
+    public String getName()
     {
         return getDecorated().getName();
     }
@@ -170,7 +181,7 @@ public class BindRequestDsml 
     /**
      * {@inheritDoc}
      */
-    public BindRequest setName( Dn name )
+    public BindRequest setName( String name )
     {
         getDecorated().setName( name );
 
@@ -181,6 +192,26 @@ public class BindRequestDsml 
     /**
      * {@inheritDoc}
      */
+    public Dn getDn()
+    {
+        return getDecorated().getDn();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public BindRequest setDn( Dn dn )
+    {
+        getDecorated().setDn( dn );
+
+        return this;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean isVersion3()
     {
         return getDecorated().isVersion3();



Mime
View raw message