seanjmullan commented on code in PR #476:
URL:
https://github.com/apache/santuario-xml-security-java/pull/476#discussion_r2096114319
##########
src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyValue.java:
##########
@@ -264,6 +264,22 @@ public boolean equals(Object obj) {
return false;
}
}
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ try {
+ if (getPublicKey() != null) {
+ RSAPublicKey rsaKey = (RSAPublicKey)getPublicKey();
+ result = 31 * result +
rsaKey.getPublicExponent().hashCode();
+ result = 31 * result + rsaKey.getModulus().hashCode();
+ }
+ } catch (KeyException ke) {
+ // no key available
Review Comment:
I would probably return `super.hashCode(`) here and also change line 264 to
return `super.equals()` so if the key can't be extracted only an exact match of
the same object will equal.
We should probably add equals/hashCode methods for the other *KeyValue
subclasses, though we could do that in another PR. Note that the XMLDSig API
does not require implementations to override equals/hashCode. However, it is
useful for testing purposes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]