public abstract class JSONSecureScreen extends JSONScreen
Typically you would extend this class and override the doOutput() method to use TurbineJsonRpc to register the POJOs that will provide the functions you are making available via JSON-RPC. Use JSONScreen if you do not need the user to be logged in prior to executing the functions you provide.
Here is an example from a superclass:
public void doOutput(PipelineData data) throws Exception
{
User user = data.getUser();
MySecureJsonFunctions myFunctions
= new MySecureJsonFunctions(user.getName());
// Session specific
TurbineJsonRpc.registerObject(data.getSession(), "myFunctions", myFunctions);
// Global
//TurbineJsonRpc.registerObjectGlobal("testGlobal", testObject);
super.doOutput(data);
}
The class MyFunctions would be something like:
public class MySecureJsonFunctions
{
private final String name;
public MySecureJsonFunctions(String name)
{
this.name = name;
}
private String getName(String clientParameter)
{
return "Client " + clientParameter + " says Hello World to " + name;
}
}
BUFFER_SIZE, JSONRPC_CONTENT_TYPE, jsonRpcService
CACHE_SIZE_DEFAULT, CACHE_SIZE_KEY, NAME, PREFIX
Constructor and Description |
---|
JSONSecureScreen() |
Modifier and Type | Method and Description |
---|---|
protected void |
doOutput(PipelineData pipelineData)
This method overrides the method in JSONScreen to perform a security
check prior to producing the output.
|
protected abstract boolean |
isAuthorized(PipelineData pipelineData)
Override this method to perform the necessary security checks.
|
getContentType
public JSONSecureScreen()
protected void doOutput(PipelineData pipelineData) throws Exception
doOutput
in class JSONScreen
pipelineData
- Turbine information.Exception
- a generic exception.protected abstract boolean isAuthorized(PipelineData pipelineData) throws Exception
pipelineData
- Turbine information.true
if the user is authorized to access the screen.Exception
- A generic exception.Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.