diff options
Diffstat (limited to 'gnu/java/security/key/rsa/GnuRSAKey.java')
| -rw-r--r-- | gnu/java/security/key/rsa/GnuRSAKey.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gnu/java/security/key/rsa/GnuRSAKey.java b/gnu/java/security/key/rsa/GnuRSAKey.java index 543ebdc56..8954f7574 100644 --- a/gnu/java/security/key/rsa/GnuRSAKey.java +++ b/gnu/java/security/key/rsa/GnuRSAKey.java @@ -48,6 +48,7 @@ import java.math.BigInteger; import java.security.AccessController; import java.security.Key; import java.security.interfaces.RSAKey; +import java.util.Objects; /** * A base asbtract class for both public and private RSA keys. @@ -90,22 +91,26 @@ public abstract class GnuRSAKey this.e = e; } + @Override public BigInteger getModulus() { return getN(); } + @Override public String getAlgorithm() { return "RSA"; } /** @deprecated see getEncoded(int). */ + @Override @Deprecated public byte[] getEncoded() { return getEncoded(defaultFormat); } + @Override public String getFormat() { return FormatUtil.getEncodingShortName(defaultFormat); @@ -149,6 +154,7 @@ public abstract class GnuRSAKey * @return <code>true</code> if the designated object is of the same type * and value as this one. */ + @Override public boolean equals(final Object obj) { if (obj == null) @@ -161,11 +167,24 @@ public abstract class GnuRSAKey return n.equals(that.getModulus()); } + /** + * Provides a hash code for this object using the RSA + * modulus. + * + * @return the hash code of this object. + */ + @Override + public int hashCode() + { + return Objects.hash(n); + } + + @Override public String toString() { if (str == null) { - String ls = (String) AccessController.doPrivileged + String ls = AccessController.doPrivileged (new GetPropertyAction("line.separator")); str = new CPStringBuilder(ls) .append("defaultFormat=").append(defaultFormat).append(",").append(ls) |
