summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java')
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java72
1 files changed, 28 insertions, 44 deletions
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java b/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java
index 52292131336..9e1c4cf0a04 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java
@@ -38,36 +38,33 @@ exception statement from your version. */
package gnu.java.security.key.dss;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PublicKey;
import java.security.interfaces.DSAPublicKey;
/**
- * <p>An object that embodies a DSS (Digital Signature Standard) public key.</p>
+ * An object that embodies a DSS (Digital Signature Standard) public key.
*
* @see #getEncoded
*/
-public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
+public class DSSPublicKey
+ extends DSSKey
+ implements PublicKey, DSAPublicKey
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
/**
- * <code>y = g<sup>x</sup> mod p</code> where <code>x</code> is the private
- * part of the DSA key.
+ * <code>y = g<sup>x</sup> mod p</code> where <code>x</code> is the
+ * private part of the DSA key.
*/
private final BigInteger y;
/** String representation of this key. Cached for speed. */
private transient String str;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Conveience constructor. Calls the constructor with 5 arguments passing
* {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
@@ -85,8 +82,8 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
}
/**
- * Constructs a new instance of <code>DSSPublicKey</code> given the designated
- * arguments.
+ * Constructs a new instance of <code>DSSPublicKey</code> given the
+ * designated arguments.
*
* @param preferredFormat the identifier of the preferred encoding format to
* use when externalizing this key.
@@ -102,13 +99,9 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.X509_ENCODING_ID
: preferredFormat,
p, q, g);
-
this.y = y;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* A class method that takes the output of the <code>encodePublicKey()</code>
* method of a DSS keypair codec object (an instance implementing
@@ -133,30 +126,22 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
catch (IllegalArgumentException ignored)
{
}
-
// try X.509 codec
return (DSSPublicKey) new DSSKeyPairX509Codec().decodePublicKey(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.interfaces.DSAPublicKey interface implementation ----------
-
public BigInteger getY()
{
return y;
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>Returns the encoded form of this public key according to the designated
- * format.</p>
+ * Returns the encoded form of this public key according to the designated
+ * format.
*
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @exception IllegalArgumentException if the format is not supported.
* @see DSSKeyPairRawCodec
*/
@@ -179,24 +164,22 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
+ * Returns <code>true</code> if the designated object is an instance of
* {@link DSAPublicKey} and has the same DSS (Digital Signature Standard)
- * parameter values as this one.</p>
+ * parameter values as this one.
*
* @param obj the other non-null DSS key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof DSAPublicKey))
- {
- return false;
- }
+ return false;
+
+ if (! (obj instanceof DSAPublicKey))
+ return false;
+
DSAPublicKey that = (DSAPublicKey) obj;
return super.equals(that) && y.equals(that.getY());
}
@@ -205,13 +188,14 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
- .append(super.toString()).append(",").append(ls)
- .append("y=0x").append(y.toString(16)).append(ls)
- .append(")").toString();
+ .append(super.toString()).append(",").append(ls)
+ .append("y=0x").append(y.toString(16)).append(ls)
+ .append(")")
+ .toString();
}
-
return str;
}
}