dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38142
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19474: Fixed authentication for pipeImporter
------------------------------------------------------------
revno: 19474
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-06-19 22:34:53 +0100
message:
Fixed authentication for pipeImporter
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/PipedImporter.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/PipedImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/PipedImporter.java 2015-06-19 14:55:47 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/PipedImporter.java 2015-06-19 21:34:53 +0000
@@ -32,9 +32,14 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.concurrent.Callable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dxf2.common.ImportOptions;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
/**
*
@@ -44,6 +49,8 @@
implements Callable<ImportSummary>
{
+ private static final Log log = LogFactory.getLog( PipedImporter.class );
+
public static final int PIPE_BUFFER_SIZE = 4096;
public static final int TOTAL_MINUTES_TO_WAIT = 5;
@@ -54,18 +61,23 @@
private final ImportOptions importOptions;
+ private Authentication authentication;
+
public PipedImporter( DataValueSetService dataValueSetService, ImportOptions importOptions, PipedOutputStream pipeOut )
throws IOException
{
this.dataValueSetService = dataValueSetService;
pipeIn = new PipedInputStream( pipeOut, PIPE_BUFFER_SIZE );
this.importOptions = importOptions;
+ this.authentication = SecurityContextHolder.getContext().getAuthentication();
}
@Override
public ImportSummary call() throws Exception
{
ImportSummary result = null;
+ SecurityContextHolder.getContext().setAuthentication( authentication );
+
try
{
result = dataValueSetService.saveDataValueSet( pipeIn, importOptions );