Skip to content

Commit c24e9c2

Browse files
authored
Adding hashcode to DOMKeyValue (#476)
1 parent 8ae55a1 commit c24e9c2

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyValue.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,23 @@ public boolean equals(Object obj) {
264264
return false;
265265
}
266266
}
267+
268+
@Override
269+
public int hashCode() {
270+
int result = 17;
271+
try {
272+
if (getPublicKey() != null) {
273+
RSAPublicKey rsaKey = (RSAPublicKey)getPublicKey();
274+
result = 31 * result + rsaKey.getPublicExponent().hashCode();
275+
result = 31 * result + rsaKey.getModulus().hashCode();
276+
}
277+
} catch (KeyException ke) {
278+
// no key available
279+
return super.hashCode();
280+
}
281+
return result;
282+
}
283+
267284
}
268285

269286
static final class DSA extends DOMKeyValue<DSAPublicKey> {

0 commit comments

Comments
 (0)