public static PublicKeyEntry decode(DataInputStream in)
      throws IOException
   {
      PublicKeyEntry entry = new PublicKeyEntry();
      entry.defaultDecode(in);
      String type = entry.properties.get("type");
      if (type == null) {
         throw new MalformedKeyringException("no key type");
      }
      if (type.equalsIgnoreCase("RAW-DSS")) {
         IKeyPairCodec coder = KeyPairCodecFactory.getInstance("dss");
         entry.key = coder.decodePublicKey(entry.payload);
      } else if (type.equalsIgnoreCase("RAW-RSA")) {
         IKeyPairCodec coder = KeyPairCodecFactory.getInstance("rsa");
         entry.key = coder.decodePublicKey(entry.payload);
      } else if (type.equalsIgnoreCase("RAW-DH")) {
         IKeyPairCodec coder = KeyPairCodecFactory.getInstance("dh");
         entry.key = coder.decodePublicKey(entry.payload);
      } else if (type.equalsIgnoreCase("X.509")) {
         try {
            KeyFactory kf = KeyFactory.getInstance("RSA");
            entry.key = kf.generatePublic(new X509EncodedKeySpec(entry.payload));
         } catch (Exception x) {
         }
         if (entry.key == null) {
            try {
               KeyFactory kf = KeyFactory.getInstance("DSA");
               entry.key = kf.generatePublic(new X509EncodedKeySpec(entry.payload));
            } catch (Exception x) {
            }
            if (entry.key == null) {
               throw new MalformedKeyringException("could not decode X.509 key");
            }
         }
      } else {
         throw new MalformedKeyringException("unsupported public key type: " + type);
      }
      return entry;
   }