Program: 105400
Project: 105400
Buggy source:
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_VOLUME_UPLOAD,eventDescription="String_Node_Str",async=true) public GetUploadParamsResponse uploadVolume(GetUploadParamsForVolumeCmd cmd) throws ResourceAllocationException, MalformedURLException {
  Account caller=CallContext.current().getCallingAccount();
  long ownerId=cmd.getEntityOwnerId();
  Account owner=_entityMgr.findById(Account.class,ownerId);
  Long zoneId=cmd.getZoneId();
  String volumeName=cmd.getName();
  String format=cmd.getFormat();
  Long diskOfferingId=cmd.getDiskOfferingId();
  String imageStoreUuid=cmd.getImageStoreUuid();
  DataStore store=_tmpltMgr.getImageStore(imageStoreUuid,zoneId);
  validateVolume(caller,ownerId,zoneId,volumeName,null,format,diskOfferingId);
  VolumeVO volume=persistVolume(owner,zoneId,volumeName,null,cmd.getFormat(),diskOfferingId,Volume.State.NotUploaded);
  VolumeInfo vol=volFactory.getVolume(volume.getId());
  RegisterVolumePayload payload=new RegisterVolumePayload(null,cmd.getChecksum(),cmd.getFormat());
  vol.addPayload(payload);
  Pair<EndPoint,DataObject> pair=volService.registerVolumeForPostUpload(vol,store);
  EndPoint ep=pair.first();
  DataObject dataObject=pair.second();
  GetUploadParamsResponse response=new GetUploadParamsResponse();
  String ssvmUrlDomain=_configDao.getValue(Config.SecStorageSecureCopyCert.key());
  String url=ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain,ep.getPublicAddr(),vol.getUuid());
  response.setPostURL(new URL(url));
  VolumeDataStoreVO volumeStore=_volumeStoreDao.findByVolume(volume.getId());
  if (volumeStore != null) {
    volumeStore.setExtractUrl(url);
    _volumeStoreDao.persist(volumeStore);
  }
  response.setId(UUID.fromString(vol.getUuid()));
  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());
  TemplateOrVolumePostUploadCommand command=new TemplateOrVolumePostUploadCommand(vol.getId(),vol.getUuid(),volumeStore.getInstallPath(),volumeStore.getChecksum(),vol.getType().toString(),vol.getName(),vol.getFormat().toString(),dataObject.getDataStore().getUri(),dataObject.getDataStore().getRole().toString());
  command.setLocalPath(volumeStore.getLocalDownloadPath());
  Gson gson=new GsonBuilder().create();
  String jsonPayload=gson.toJson(command);
  response.setMetadata(EncryptionUtil.encodeData(jsonPayload,key));
  response.setSignature(EncryptionUtil.generateSignature(jsonPayload + url + expires,key));
  return response;
}

Fixed version (ground truth):
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_VOLUME_UPLOAD,eventDescription="String_Node_Str",async=true) public GetUploadParamsResponse uploadVolume(GetUploadParamsForVolumeCmd cmd) throws ResourceAllocationException, MalformedURLException {
  Account caller=CallContext.current().getCallingAccount();
  long ownerId=cmd.getEntityOwnerId();
  Account owner=_entityMgr.findById(Account.class,ownerId);
  Long zoneId=cmd.getZoneId();
  String volumeName=cmd.getName();
  String format=cmd.getFormat();
  Long diskOfferingId=cmd.getDiskOfferingId();
  String imageStoreUuid=cmd.getImageStoreUuid();
  DataStore store=_tmpltMgr.getImageStore(imageStoreUuid,zoneId);
  validateVolume(caller,ownerId,zoneId,volumeName,null,format,diskOfferingId);
  VolumeVO volume=persistVolume(owner,zoneId,volumeName,null,cmd.getFormat(),diskOfferingId,Volume.State.NotUploaded);
  VolumeInfo vol=volFactory.getVolume(volume.getId());
  RegisterVolumePayload payload=new RegisterVolumePayload(null,cmd.getChecksum(),cmd.getFormat());
  vol.addPayload(payload);
  Pair<EndPoint,DataObject> pair=volService.registerVolumeForPostUpload(vol,store);
  EndPoint ep=pair.first();
  DataObject dataObject=pair.second();
  GetUploadParamsResponse response=new GetUploadParamsResponse();
  String ssvmUrlDomain=_configDao.getValue(Config.SecStorageSecureCopyCert.key());
  String url=ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain,ep.getPublicAddr(),vol.getUuid());
  response.setPostURL(new URL(url));
  VolumeDataStoreVO volumeStore=_volumeStoreDao.findByVolume(volume.getId());
  if (volumeStore != null) {
    volumeStore.setExtractUrl(url);
    _volumeStoreDao.persist(volumeStore);
  }
  response.setId(UUID.fromString(vol.getUuid()));
  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());
  TemplateOrVolumePostUploadCommand command=new TemplateOrVolumePostUploadCommand(vol.getId(),vol.getUuid(),volumeStore.getInstallPath(),volumeStore.getChecksum(),vol.getType().toString(),vol.getName(),vol.getFormat().toString(),dataObject.getDataStore().getUri(),dataObject.getDataStore().getRole().toString());
  command.setLocalPath(volumeStore.getLocalDownloadPath());
  Gson gson=new GsonBuilder().create();
  String metadata=EncryptionUtil.encodeData(gson.toJson(command),key);
  response.setMetadata(metadata);
  response.setSignature(EncryptionUtil.generateSignature(metadata + url + expires,key));
  return response;
}