protected void encodePayload() throws IOException {
      if (key instanceof DSSPublicKey) {
         properties.put("type", "RAW-DSS");
         IKeyPairCodec coder = KeyPairCodecFactory.getInstance("dss");
         payload = coder.encodePublicKey(key);
      } else if (key instanceof GnuRSAPublicKey) {
         properties.put("type", "RAW-RSA");
         IKeyPairCodec coder = KeyPairCodecFactory.getInstance("rsa");
         payload = coder.encodePublicKey(key);
      } else if (key instanceof GnuDHPublicKey) {
         properties.put("type", "RAW-DH");
         IKeyPairCodec coder = KeyPairCodecFactory.getInstance("dh");
         payload = coder.encodePublicKey(key);
      } else if (key.getFormat() != null && key.getFormat().equals("X.509")) {
         properties.put("type", "X.509");
         payload = key.getEncoded();
      } else {
         throw new IllegalArgumentException("cannot encode public key");
      }
   }