directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36747 - incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message
Date Mon, 23 Aug 2004 03:31:22 GMT
Author: akarasulu
Date: Sun Aug 22 20:31:22 2004
New Revision: 36747

Modified:
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindResponseImpl.java
Log:
Commit Changes ...

 o formatting: removed m_, a_ and spaces before ;
 o added equals() method
 o fixed some NullPointerExceptions 
 


Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindResponseImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindResponseImpl.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindResponseImpl.java
Sun Aug 22 20:31:22 2004
@@ -14,7 +14,9 @@
  *   limitations under the License.
  *
  */
-package org.apache.ldap.common.message ;
+package org.apache.ldap.common.message;
+
+import org.apache.commons.lang.ArrayUtils;
 
 
 /**
@@ -28,7 +30,7 @@
     extends AbstractResultResponse implements BindResponse
 {
     /** optional property holding SASL authentication response paramters */
-    private byte [] m_serverSaslCreds ;
+    private byte [] serverSaslCreds;
 
 
     // ------------------------------------------------------------------------
@@ -39,11 +41,11 @@
     /**
      * Creates a Lockable AddResponse as a reply to an AddRequest.
      *
-     * @param a_id the session unique message id
+     * @param id the session unique message id
      */
-    public BindResponseImpl( final int a_id )
+    public BindResponseImpl( final int id )
     {
-        super( a_id, TYPE ) ;
+        super( id, TYPE );
     }
 
 
@@ -61,7 +63,7 @@
      */
     public byte [] getServerSaslCreds()
     {
-        return m_serverSaslCreds ;
+        return serverSaslCreds;
     }
 
 
@@ -70,11 +72,82 @@
      * that are SASL mechanism specific.  Leave null if authentication mode is
      * simple.
      *
-     * @param a_serverSaslCreds the sasl auth. mech. specific credentials
+     * @param serverSaslCreds the sasl auth. mech. specific credentials
      */
-    public void setServerSaslCreds( byte [] a_serverSaslCreds )
+    public void setServerSaslCreds( byte [] serverSaslCreds )
     {
         lockCheck( "Attempt to alter serverSaslCreds on locked BindResponse!" );
-        m_serverSaslCreds = a_serverSaslCreds ;
+        this.serverSaslCreds = serverSaslCreds;
+    }
+
+
+    /**
+     * Checks to see if this BindResponse is equal to another BindResponse.
+     * The implementation and lockable properties are not factored into the
+     * evaluation of equality.  Only the messageId, saslCredentials and the
+     * LdapResults of this BindResponse PDU and the compared object are taken
+     * into account if that object also implements the BindResponse interface.
+     *
+     * @param obj the object to test for equality with this BindResponse
+     * @return true if obj equals this BindResponse false otherwise
+     */
+    public boolean equals( Object obj )
+    {
+        // quickly return true if obj is this one
+        if ( obj == this )
+        {
+            return true;
+        }
+
+        if ( ! ( obj instanceof BindResponse ) )
+        {
+            return false;
+        }
+
+        BindResponse response = ( BindResponse ) obj;
+
+        if ( getMessageId() != response.getMessageId() )
+        {
+            return false;
+        }
+
+        if ( getLdapResult() != null && response.getLdapResult() == null )
+        {
+            return false;
+        }
+
+        if ( getLdapResult() == null && response.getLdapResult() != null )
+        {
+            return false;
+        }
+
+        if ( getLdapResult() != null && response.getLdapResult() != null )
+        {
+            if ( ! getLdapResult().equals( response.getLdapResult() ) )
+            {
+                return false;
+            }
+        }
+
+        byte[] creds = response.getServerSaslCreds();
+        if ( serverSaslCreds == null && creds != null )
+        {
+            return false;
+        }
+
+        if ( creds == null && serverSaslCreds != null )
+        {
+            return false;
+        }
+
+        if ( creds != null && serverSaslCreds != null )
+        {
+            if ( ! ArrayUtils.isEquals( serverSaslCreds, creds ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
     }
 }

Mime
View raw message