53 public class DSAKeyFactory extends KeyFactorySpi {
54
55 // package private for DSAKeyPairGenerator
56 static final boolean SERIAL_INTEROP;
57 private static final String SERIAL_PROP = "sun.security.key.serial.interop";
58
59 static {
60
61 /**
62 * Check to see if we need to maintain interoperability for serialized
63 * keys between JDK 5.0 -> JDK 1.4. In other words, determine whether
64 * a key object serialized in JDK 5.0 must be deserializable in
65 * JDK 1.4.
66 *
67 * If true, then we generate sun.security.provider.DSAPublicKey.
68 * If false, then we generate sun.security.provider.DSAPublicKeyImpl.
69 *
70 * By default this is false.
71 * This incompatibility was introduced by 4532506.
72 */
73 String prop = AccessController.doPrivileged
74 (new GetPropertyAction(SERIAL_PROP, null));
75 SERIAL_INTEROP = "true".equalsIgnoreCase(prop);
76 }
77
78 /**
79 * Generates a public key object from the provided key specification
80 * (key material).
81 *
82 * @param keySpec the specification (key material) of the public key
83 *
84 * @return the public key
85 *
86 * @exception InvalidKeySpecException if the given key specification
87 * is inappropriate for this key factory to produce a public key.
88 */
89 protected PublicKey engineGeneratePublic(KeySpec keySpec)
90 throws InvalidKeySpecException {
91 try {
92 if (keySpec instanceof DSAPublicKeySpec) {
93 DSAPublicKeySpec dsaPubKeySpec = (DSAPublicKeySpec)keySpec;
94 if (SERIAL_INTEROP) {
|
53 public class DSAKeyFactory extends KeyFactorySpi {
54
55 // package private for DSAKeyPairGenerator
56 static final boolean SERIAL_INTEROP;
57 private static final String SERIAL_PROP = "sun.security.key.serial.interop";
58
59 static {
60
61 /**
62 * Check to see if we need to maintain interoperability for serialized
63 * keys between JDK 5.0 -> JDK 1.4. In other words, determine whether
64 * a key object serialized in JDK 5.0 must be deserializable in
65 * JDK 1.4.
66 *
67 * If true, then we generate sun.security.provider.DSAPublicKey.
68 * If false, then we generate sun.security.provider.DSAPublicKeyImpl.
69 *
70 * By default this is false.
71 * This incompatibility was introduced by 4532506.
72 */
73 String prop = GetPropertyAction.getProperty(SERIAL_PROP);
74 SERIAL_INTEROP = "true".equalsIgnoreCase(prop);
75 }
76
77 /**
78 * Generates a public key object from the provided key specification
79 * (key material).
80 *
81 * @param keySpec the specification (key material) of the public key
82 *
83 * @return the public key
84 *
85 * @exception InvalidKeySpecException if the given key specification
86 * is inappropriate for this key factory to produce a public key.
87 */
88 protected PublicKey engineGeneratePublic(KeySpec keySpec)
89 throws InvalidKeySpecException {
90 try {
91 if (keySpec instanceof DSAPublicKeySpec) {
92 DSAPublicKeySpec dsaPubKeySpec = (DSAPublicKeySpec)keySpec;
93 if (SERIAL_INTEROP) {
|