Permalink
Browse files

#3296 added propagation of security context to XML and JSON function …

…calls
  • Loading branch information...
1 parent d12cca3 commit ead5380ee4723aca7e395876c48725779abf9ecb @ddossot ddossot committed Feb 10, 2014
Showing with 16 additions and 9 deletions.
  1. +16 −9 src/main/java/eu/openanalytics/rsb/component/JobProcessor.java
@@ -21,6 +21,8 @@
package eu.openanalytics.rsb.component;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -96,7 +98,7 @@
@Override
public AbstractResult<String> runOn(final RServi rServi) throws CoreException, IOException
{
- final String resultPayload = callFunctionOnR(rServi, job.getFunctionName(), job.getArgument());
+ final String resultPayload = callFunctionOnR(rServi, job);
return job.buildSuccessResult(resultPayload);
}
}, true);
@@ -109,7 +111,7 @@ public void process(final AbstractFunctionCallJob job) throws Exception
@Override
public AbstractResult<String> runOn(final RServi rServi) throws CoreException, IOException
{
- final String resultPayload = callFunctionOnR(rServi, job.getFunctionName(), job.getArgument());
+ final String resultPayload = callFunctionOnR(rServi, job);
return job.buildSuccessResult(resultPayload);
}
}, false);
@@ -315,17 +317,22 @@ void setRServiUriSelector(final RServiUriSelector rServiUriSelector)
return result;
}
- private static String callFunctionOnR(final RServi rServi,
- final String functionName,
- final String argument) throws CoreException
+ private String callFunctionOnR(final RServi rServi, final AbstractFunctionCallJob job)
+ throws CoreException
{
- // TODO #3296 propagate security context if needed
- final FunctionCall functionCall = rServi.createFunctionCall(functionName);
- functionCall.addChar(argument);
+ final FunctionCall functionCall = rServi.createFunctionCall(job.getFunctionName());
+ functionCall.addChar(job.getArgument());
+
+ if ((getConfiguration().isPropagateSecurityContext()) && (isNotBlank(job.getUserName())))
+ {
+ functionCall.addLogi("rsbSecure", true);
+ functionCall.addChar("rsbUserPrincipal", job.getUserName());
+ }
+
final RObject result = functionCall.evalData(null);
if (!RDataUtil.isSingleString(result))
{
- throw new RuntimeException("Unexpected return value for function: " + functionName);
+ throw new RuntimeException("Unexpected return value for function: " + job.getFunctionName());
}
return result.getData().getChar(0);

0 comments on commit ead5380

Please sign in to comment.