Program: 105401
Project: 105401
Buggy source:
@Override @ActionEvent(eventType=EventTypes.EVENT_TEMPLATE_CREATE,eventDescription="String_Node_Str") public GetUploadParamsResponse registerTemplateForPostUpload(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException, MalformedURLException {
  TemplateAdapter adapter=getAdapter(HypervisorType.getType(cmd.getHypervisor()));
  TemplateProfile profile=adapter.prepare(cmd);
  List<TemplateOrVolumePostUploadCommand> payload=adapter.createTemplateForPostUpload(profile);
  if (CollectionUtils.isNotEmpty(payload)) {
    GetUploadParamsResponse response=new GetUploadParamsResponse();
    TemplateOrVolumePostUploadCommand firstCommand=payload.get(0);
    String ssvmUrlDomain=_configDao.getValue(Config.SecStorageSecureCopyCert.key());
    String url=ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain,firstCommand.getRemoteEndPoint(),firstCommand.getEntityUUID());
    response.setPostURL(new URL(url));
    TemplateDataStoreVO templateStore=_tmplStoreDao.findByTemplate(firstCommand.getEntityId(),DataStoreRole.getRole(firstCommand.getDataToRole()));
    if (templateStore != null) {
      templateStore.setExtractUrl(url);
      _tmplStoreDao.persist(templateStore);
    }
    response.setId(UUID.fromString(firstCommand.getEntityUUID()));
    int timeout=ImageStoreUploadMonitorImpl.getUploadOperationTimeout();
    DateTime currentDateTime=new DateTime(DateTimeZone.UTC);
    String expires=currentDateTime.plusMinutes(timeout).toString();
    response.setTimeout(expires);
    String key=_configDao.getValue(Config.SSVMPSK.key());
    Gson gson=new GsonBuilder().create();
    String jsonPayload=gson.toJson(firstCommand);
    response.setMetadata(EncryptionUtil.encodeData(jsonPayload,key));
    response.setSignature(EncryptionUtil.generateSignature(jsonPayload + url + expires,key));
    return response;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
@Override @ActionEvent(eventType=EventTypes.EVENT_TEMPLATE_CREATE,eventDescription="String_Node_Str") public GetUploadParamsResponse registerTemplateForPostUpload(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException, MalformedURLException {
  TemplateAdapter adapter=getAdapter(HypervisorType.getType(cmd.getHypervisor()));
  TemplateProfile profile=adapter.prepare(cmd);
  List<TemplateOrVolumePostUploadCommand> payload=adapter.createTemplateForPostUpload(profile);
  if (CollectionUtils.isNotEmpty(payload)) {
    GetUploadParamsResponse response=new GetUploadParamsResponse();
    TemplateOrVolumePostUploadCommand firstCommand=payload.get(0);
    String ssvmUrlDomain=_configDao.getValue(Config.SecStorageSecureCopyCert.key());
    String url=ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain,firstCommand.getRemoteEndPoint(),firstCommand.getEntityUUID());
    response.setPostURL(new URL(url));
    TemplateDataStoreVO templateStore=_tmplStoreDao.findByTemplate(firstCommand.getEntityId(),DataStoreRole.getRole(firstCommand.getDataToRole()));
    if (templateStore != null) {
      templateStore.setExtractUrl(url);
      _tmplStoreDao.persist(templateStore);
    }
    response.setId(UUID.fromString(firstCommand.getEntityUUID()));
    int timeout=ImageStoreUploadMonitorImpl.getUploadOperationTimeout();
    DateTime currentDateTime=new DateTime(DateTimeZone.UTC);
    String expires=currentDateTime.plusMinutes(timeout).toString();
    response.setTimeout(expires);
    String key=_configDao.getValue(Config.SSVMPSK.key());
    Gson gson=new GsonBuilder().create();
    String metadata=EncryptionUtil.encodeData(gson.toJson(firstCommand),key);
    response.setMetadata(metadata);
    response.setSignature(EncryptionUtil.generateSignature(metadata + url + expires,key));
    return response;
  }
 else {
    return null;
  }
}