return result;
  protected PublicKey engineGeneratePublic(KeySpec keySpec)      throws InvalidKeySpecException  {    if (keySpec instanceof DSAPublicKeySpec)      {        DSAPublicKeySpec spec = (DSAPublicKeySpec) keySpec;        BigInteger p = spec.getP();        BigInteger q = spec.getQ();        BigInteger g = spec.getG();        BigInteger y = spec.getY();        return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y);      }    if (keySpec instanceof X509EncodedKeySpec)      {        X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec;        byte[] encoded = spec.getEncoded();        PublicKey result;        try          {            result = new DSSKeyPairX509Codec().decodePublicKey(encoded);          }        catch (RuntimeException x)          {            InvalidKeySpecException y = new InvalidKeySpecException();            y.initCause(x);            throw y;          }      }    throw new InvalidKeySpecException("Unsupported (public) key specification");  }