class SenderIntermediateCertFactory {

  public String create() throws GeneralSecurityException {
    try {
      String signedKey =
          new JSONObject()
              .put(PaymentMethodTokenConstants.JSON_KEY_VALUE_KEY, intermediateSigningKey)
              .put(PaymentMethodTokenConstants.JSON_KEY_EXPIRATION_KEY, Long.toString(expiration))
              .toString();
      byte[] toSignBytes =
          PaymentMethodTokenUtil.toLengthValue(
              // The order of the parameters matters.
              senderId, protocolVersion, signedKey);
      JSONArray signatures = new JSONArray();
      for (PublicKeySign signer : signers) {
        byte[] signature = signer.sign(toSignBytes);
        signatures.put(Base64.encode(signature));
      }
      return new JSONObject()
          .put(PaymentMethodTokenConstants.JSON_SIGNED_KEY_KEY, signedKey)
          .put(PaymentMethodTokenConstants.JSON_SIGNATURES_KEY, signatures)
          .toString();
    } catch (JSONException e) {
      throw new RuntimeException("Failed to perform JSON encoding", e);
    }
  }

  private  SenderIntermediateCertFactory(
      String protocolVersion,
      String senderId,
      List<ECPrivateKey> senderSigningKeys,
      String intermediateSigningKey,
      long expiration);

}