You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2006/06/02 20:56:57 UTC

svn commit: r411248 - /xml/security/trunk/src/org/apache/xml/security/keys/content/x509/XMLX509SKI.java

Author: mullan
Date: Fri Jun  2 11:56:57 2006
New Revision: 411248

URL: http://svn.apache.org/viewvc?rev=411248&view=rev
Log:
Fix findbugs bugs:
XMLX509SKI defines equals and uses Object.hashCode()
Possible null pointer dereference in equals()

Modified:
    xml/security/trunk/src/org/apache/xml/security/keys/content/x509/XMLX509SKI.java

Modified: xml/security/trunk/src/org/apache/xml/security/keys/content/x509/XMLX509SKI.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src/org/apache/xml/security/keys/content/x509/XMLX509SKI.java?rev=411248&r1=411247&r2=411248&view=diff
==============================================================================
--- xml/security/trunk/src/org/apache/xml/security/keys/content/x509/XMLX509SKI.java (original)
+++ xml/security/trunk/src/org/apache/xml/security/keys/content/x509/XMLX509SKI.java Fri Jun  2 11:56:57 2006
@@ -16,8 +16,6 @@
  */
 package org.apache.xml.security.keys.content.x509;
 
-
-
 import java.io.IOException;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
@@ -199,22 +197,30 @@
       }
    }
 
-   /** @inheritDoc */
-   public boolean equals(Object obj) {
-
-      if (!obj.getClass().getName().equals(this.getClass().getName())) {
-         return false;
-      }
+    /** @inheritDoc */
+    public boolean equals(Object obj) {
+	if (obj == null) {
+	    return false;
+	}
+        if (!this.getClass().getName().equals(obj.getClass().getName())) {
+            return false;
+        }
 
-      XMLX509SKI other = (XMLX509SKI) obj;
+        XMLX509SKI other = (XMLX509SKI) obj;
 
-      try {
-         return java.security.MessageDigest.isEqual(other.getSKIBytes(),
+        try {
+            return java.security.MessageDigest.isEqual(other.getSKIBytes(),
                                         this.getSKIBytes());
-      } catch (XMLSecurityException ex) {
-         return false;
-      }
-   }
+        } catch (XMLSecurityException ex) {
+            return false;
+        }
+    }
+
+    public int hashCode() {
+	// uncomment when JDK 1.4 is required
+	// assert false : "hashCode not designed";
+	return 92;
+    }
 
    /** @inheritDoc */
    public String getBaseLocalName() {