Skip to content

Commit

Permalink
fixed multiparts posts with file uploads (csrf problem in some cases)
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Nov 30, 2017
1 parent c85bfd0 commit a4ad917
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Expand Up @@ -82,7 +82,8 @@
PropertyPlaceholderAutoConfiguration.class,
SecurityAutoConfiguration.class,
SecurityFilterAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class
ServerPropertiesAutoConfiguration.class,
MultipartAutoConfiguration.class
})
@SpringBootConfiguration
public class MidPointSpringApplication extends SpringBootServletInitializer {
Expand Down
Expand Up @@ -117,6 +117,7 @@ protected ImportOptionsType load() {

private void initLayout() {
Form mainForm = new com.evolveum.midpoint.web.component.form.Form(ID_MAIN_FORM);
mainForm.setMultiPart(true);
add(mainForm);

ImportOptionsPanel importOptions = new ImportOptionsPanel(ID_IMPORT_OPTIONS, optionsModel, fullProcessingModel);
Expand Down Expand Up @@ -308,7 +309,8 @@ private InputDescription getInputDescription(boolean editor) throws Exception {
// Save file

newFile.createNewFile();
uploadedFile.writeTo(newFile);

FileUtils.copyInputStreamToFile(uploadedFile.getInputStream(), newFile);

String language = getPrismContext().detectLanguage(newFile);
return new InputDescription(new FileInputStream(newFile), language);
Expand Down
Expand Up @@ -224,7 +224,7 @@ private void importReportFromFilePerformed(AjaxRequestTarget target) {
// Save file
// Task task = createSimpleTask(OPERATION_IMPORT_FILE);
newFile.createNewFile();
uploadedFile.writeTo(newFile);
FileUtils.copyInputStreamToFile(uploadedFile.getInputStream(), newFile);

InputStreamReader reader = new InputStreamReader(new FileInputStream(newFile), "utf-8");
// reader.
Expand Down

0 comments on commit a4ad917

Please sign in to comment.