Program: 49297
Project: 49297
Buggy source:
/** 
 * @param entitlements a map of entitlements indexed by pool ids to generatethe certs of
 * @param productMap a map of respective products indexed by pool id
 * @throws IOException
 * @throws GeneralSecurityException
 * @return entitlementCerts the respective entitlement certs indexed by poolid
 */
private Map<String,EntitlementCertificate> generateEntitlementCerts(Consumer consumer,Map<String,Entitlement> entitlements,Map<String,Product> productMap,boolean thisIsUeberCert) throws GeneralSecurityException, IOException {
  log.info("String_Node_Str");
  KeyPair keyPair=keyPairCurator.getConsumerKeyPair(consumer);
  byte[] pemEncodedKeyPair=pki.getPemEncoded(keyPair.getPrivate());
  Map<String,CertificateSerial> serialMap=new HashMap<String,CertificateSerial>();
  for (  Entry<String,Entitlement> entry : entitlements.entrySet()) {
    serialMap.put(entry.getKey(),new CertificateSerial(entry.getValue().getEndDate()));
  }
  serialCurator.saveOrUpdateAll(serialMap);
  Map<String,EntitlementCertificate> entitlementCerts=new HashMap<String,EntitlementCertificate>();
  for (  Entry<String,Entitlement> entry : entitlements.entrySet()) {
    Entitlement entitlement=entry.getValue();
    CertificateSerial serial=serialMap.get(entry.getKey());
    Product product=productMap.get(entry.getKey());
    log.info("String_Node_Str",entitlement);
    Set<Product> products=new HashSet<Product>(entitlement.getPool().getProvidedProducts());
    products.addAll(getDerivedProductsForDistributor(entitlement));
    products.add(product);
    Map<String,EnvironmentContent> promotedContent=getPromotedContent(entitlement);
    String contentPrefix=getContentPrefix(entitlement,!thisIsUeberCert);
    log.info("String_Node_Str",product);
    log.debug("String_Node_Str",products);
    List<org.candlepin.model.dto.Product> productModels=v3extensionUtil.createProducts(product,products,contentPrefix,promotedContent,entitlement.getConsumer(),entitlement);
    X509Certificate x509Cert=createX509Certificate(entitlement,product,products,productModels,BigInteger.valueOf(serial.getId()),keyPair,!thisIsUeberCert);
    EntitlementCertificate cert=new EntitlementCertificate();
    cert.setSerial(serial);
    cert.setKeyAsBytes(pemEncodedKeyPair);
    log.info("String_Node_Str");
    String pem=new String(this.pki.getPemEncoded(x509Cert));
    if (shouldGenerateV3(entitlement)) {
      log.debug("String_Node_Str");
      byte[] payloadBytes=v3extensionUtil.createEntitlementDataPayload(product,productModels,entitlement,contentPrefix,promotedContent);
      String payload="String_Node_Str";
      payload+=Util.toBase64(payloadBytes);
      payload+="String_Node_Str";
      byte[] bytes=pki.getSHA256WithRSAHash(new ByteArrayInputStream(payloadBytes));
      String signature="String_Node_Str";
      signature+=Util.toBase64(bytes);
      signature+="String_Node_Str";
      pem+=payload + signature;
    }
    cert.setCert(pem);
    cert.setEntitlement(entitlement);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + serial.getId());
      log.debug("String_Node_Str" + cert.getKey());
      log.debug("String_Node_Str" + cert.getCert());
    }
    entitlement.getCertificates().add(cert);
    entitlementCerts.put(entry.getKey(),cert);
  }
  log.info("String_Node_Str");
  entCertCurator.saveOrUpdateAll(entitlementCerts.values());
  return entitlementCerts;
}

Fixed version (ground truth):
/** 
 * @param entitlements a map of entitlements indexed by pool ids to generatethe certs of
 * @param productMap a map of respective products indexed by pool id
 * @throws IOException
 * @throws GeneralSecurityException
 * @return entitlementCerts the respective entitlement certs indexed by poolid
 */
private Map<String,EntitlementCertificate> generateEntitlementCerts(Consumer consumer,Map<String,Entitlement> entitlements,Map<String,Product> productMap,boolean thisIsUeberCert) throws GeneralSecurityException, IOException {
  log.info("String_Node_Str");
  KeyPair keyPair=keyPairCurator.getConsumerKeyPair(consumer);
  byte[] pemEncodedKeyPair=pki.getPemEncoded(keyPair.getPrivate());
  Map<String,CertificateSerial> serialMap=new HashMap<String,CertificateSerial>();
  for (  Entry<String,Entitlement> entry : entitlements.entrySet()) {
    serialMap.put(entry.getKey(),new CertificateSerial(entry.getValue().getEndDate()));
  }
  serialCurator.saveOrUpdateAll(serialMap);
  Map<String,EntitlementCertificate> entitlementCerts=new HashMap<String,EntitlementCertificate>();
  for (  Entry<String,Entitlement> entry : entitlements.entrySet()) {
    Entitlement entitlement=entry.getValue();
    CertificateSerial serial=serialMap.get(entry.getKey());
    Product product=productMap.get(entry.getKey());
    log.info("String_Node_Str",entitlement);
    Set<Product> products=new HashSet<Product>(entitlement.getPool().getProvidedProducts());
    products.addAll(getDerivedProductsForDistributor(entitlement));
    products.add(product);
    Map<String,EnvironmentContent> promotedContent=getPromotedContent(entitlement);
    String contentPrefix=getContentPrefix(entitlement,!thisIsUeberCert);
    log.info("String_Node_Str",product);
    log.debug("String_Node_Str",products);
    List<org.candlepin.model.dto.Product> productModels=v3extensionUtil.createProducts(product,products,contentPrefix,promotedContent,entitlement.getConsumer(),entitlement);
    X509Certificate x509Cert=createX509Certificate(entitlement,product,products,productModels,BigInteger.valueOf(serial.getId()),keyPair,!thisIsUeberCert);
    EntitlementCertificate cert=new EntitlementCertificate();
    cert.setSerial(serial);
    cert.setKeyAsBytes(pemEncodedKeyPair);
    log.info("String_Node_Str");
    String pem=new String(this.pki.getPemEncoded(x509Cert));
    if (shouldGenerateV3(entitlement)) {
      log.debug("String_Node_Str");
      byte[] payloadBytes=v3extensionUtil.createEntitlementDataPayload(product,productModels,entitlement,contentPrefix,promotedContent);
      String payload="String_Node_Str";
      payload+=Util.toBase64(payloadBytes);
      payload+="String_Node_Str";
      byte[] bytes=pki.getSHA256WithRSAHash(new ByteArrayInputStream(payloadBytes));
      String signature="String_Node_Str";
      signature+=Util.toBase64(bytes);
      signature+="String_Node_Str";
      pem+=payload + signature;
    }
    cert.setCert(pem);
    cert.setEntitlement(entitlement);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + serial.getId());
      log.debug("String_Node_Str" + cert.getKey());
      log.debug("String_Node_Str" + cert.getCert());
    }
    entitlement.getCertificates().add(cert);
    entitlementCerts.put(entry.getKey(),cert);
  }
  log.info("String_Node_Str");
  entCertCurator.saveOrUpdateAll(entitlementCerts.values(),false);
  return entitlementCerts;
}