directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r290501 - in /directory/protocol-providers/ldap/trunk: project.xml src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
Date Tue, 20 Sep 2005 18:10:09 GMT
Author: akarasulu
Date: Tue Sep 20 11:10:04 2005
New Revision: 290501

URL: http://svn.apache.org/viewcvs?rev=290501&view=rev
Log:
changes ...

 o altered compare handler to use the newly introduced ApacheDS provider 
   specific compare() operation - this considerably cleans up the handler
 o fixed project pom so it references the latest jars


Modified:
    directory/protocol-providers/ldap/trunk/project.xml
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java

Modified: directory/protocol-providers/ldap/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/project.xml?rev=290501&r1=290500&r2=290501&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/project.xml (original)
+++ directory/protocol-providers/ldap/trunk/project.xml Tue Sep 20 11:10:04 2005
@@ -150,19 +150,19 @@
     <dependency>
       <groupId>directory-asn1</groupId>
       <artifactId>asn1-codec</artifactId>
-      <version>0.3.2</version>
+      <version>0.3.3-SNAPSHOT</version>
       <url>http://directory.apache.org/subprojects/asn1/ber-codec</url>
     </dependency>
     <dependency>
       <groupId>directory-shared</groupId>
       <artifactId>ldap-common</artifactId>
-      <version>0.9.2</version>
+      <version>0.9.3-SNAPSHOT</version>
       <url>http://directory.apache.org/subprojects/ldap/common</url>
     </dependency>
     <dependency>
       <groupId>directory</groupId>
       <artifactId>apacheds-core</artifactId>
-      <version>0.9.2</version>
+      <version>0.9.3-SNAPSHOT</version>
       <url>http://directory.apache.org/subprojects/apacheds</url>
     </dependency>
     <dependency>

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java?rev=290501&r1=290500&r2=290501&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
Tue Sep 20 11:10:04 2005
@@ -18,8 +18,6 @@
 
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.DirContext;
 
 import org.apache.ldap.common.exception.LdapException;
 import org.apache.ldap.common.message.CompareRequest;
@@ -28,9 +26,8 @@
 import org.apache.ldap.common.message.LdapResultImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.ExceptionUtils;
-import org.apache.ldap.common.schema.Normalizer;
-import org.apache.ldap.server.jndi.ContextFactoryService;
-import org.apache.ldap.server.schema.AttributeTypeRegistry;
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.server.jndi.ServerLdapContext;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
 import org.slf4j.Logger;
@@ -55,54 +52,15 @@
 
         try
         {
-            DirContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
-            Attribute attr = ctx.getAttributes( req.getName() ).get( req.getAttributeId()
);
-            AttributeTypeRegistry registry = ContextFactoryService.getInstance().
-                    getConfiguration().getGlobalRegistries().getAttributeTypeRegistry();
-
-            // complain if we do not recognize the attribute being compared
-            if ( ! registry.hasAttributeType( req.getAttributeId() ) )
-            {
-                resp.getLdapResult().setResultCode( ResultCodeEnum.UNDEFINEDATTRIBUTETYPE
);
-            }
-            // complain if the attribute being compared does not exist in the entry
-            else if ( attr == null )
-            {
-                resp.getLdapResult().setResultCode( ResultCodeEnum.NOSUCHATTRIBUTE );
-            }
-            // see first if simple match without normalization succeeds
-            else if ( attr.contains( req.getAssertionValue() ) )
+            ServerLdapContext ctx = ( ServerLdapContext ) SessionRegistry.getSingleton().getLdapContext(
session, null, true );
+            LdapName name = new LdapName( req.getName() );
+            if ( ctx.compare( name, req.getAttributeId(), req.getAssertionValue() ) )
             {
                 resp.getLdapResult().setResultCode( ResultCodeEnum.COMPARETRUE );
             }
-            // now must apply normalization to all values (attr and in request) to compare
             else
             {
-                /*
-                 * Get ahold of the normalizer for the attribute and normalize the request
-                 * assertion value for comparisons with normalized attribute values.  Loop
-                 * through all values looking for a match.
-                 */
-                Normalizer normalizer = registry.lookup( req.getAttributeId() ).getEquality().getNormalizer();
-                String reqVal = ( String ) normalizer.normalize( req.getAssertionValue()
);
-                boolean isCompareTrue = false;
-
-                for ( int ii = 0; ii < attr.size(); ii++ )
-                {
-                    String attrVal = ( String ) normalizer.normalize( attr.get( ii ) );
-                    if ( attrVal.equals( reqVal ) )
-                    {
-                        resp.getLdapResult().setResultCode( ResultCodeEnum.COMPARETRUE );
-                        isCompareTrue = true;
-                        break;
-                    }
-                }
-
-                // if no match was found then we set compare to false
-                if ( ! isCompareTrue )
-                {
-                    resp.getLdapResult().setResultCode( ResultCodeEnum.COMPAREFALSE );
-                }
+                resp.getLdapResult().setResultCode( ResultCodeEnum.COMPAREFALSE );
             }
         }
         catch ( NamingException e )



Mime
View raw message