IBM Aspera HST Admin Manual page 86

High-speed transfer server
Table of Contents

Advertisement

{
"error" : {
"code" : "1022",
"message" : "The file fails validation"
}
}
Custom Code for Including and Excluding Files
Administrators can include or exclude files by enabling whitelisting, blacklisting, or another method of their own
design. You can do this by creating custom code in the programming language of your choice, using a web server that
runs a REST service. (HST Server users have the option to use the web server associated with that installation).
The following is an example of custom code that creates a file blacklist, using a Java servlet deployed on an Apache
web server. Note that this code uses the servlet name SimpleValidator, which was defined in web.xml above.
package aspera.validation;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
@WebServlet(name = "SimpleValidator")
public class SimpleValidator extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
StringBuilder fileRequestJSON = new StringBuilder();
BufferedReader reader = request.getReader();
String line = "";
Gson gson = new Gson();
System.out.println("Got Validation request...");
while (line != null) {
line = reader.readLine();
if (!(line == null)) {
fileRequestJSON.append(line).append("\n");
}
}
ValidationInput validationInput =
gson.fromJson(fileRequestJSON.toString(), ValidationInput.class);
System.out.println("FileData JSON: " + fileRequestJSON.toString());
if (validationInput.file != null &&
validationInput.file.endsWith(".sh")
|| validationInput.file.endsWith(".exe")) {
JsonObject innerObject = new JsonObject();
innerObject.addProperty("message", "Cannot transfer executable
file!!");
innerObject.addProperty("code", 1);
JsonObject jsonObject = new JsonObject();
jsonObject.add("error", innerObject);
| Configure the Server from the Command Line | 86

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents