Creating a custom security adapter class
Implement the upload security adapter interface to customize file verification. The upload security adapter requires access to the following libraries:
*javax.servlet.http.HttpServletRequest
*javax.servlet.ServletContext
*com.actuate.iportal.security
To process a secure upload request from iHub Information Console client using an upload security adapter, the following methods are required:
*getErrorMessage( )
*isFileTypeAllowed( )
*verifyFile( )
For example, to prevent any file type except plain text (.txt) from being uploaded, implement txt as the only valid file type for isFileTypeAllowed, as in the following class:
package com.actuate.iportal.security;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
 
public class SecureUpload implements IUploadSecurityAdapter {
 
public boolean isFileTypeAllowed( HttpServletRequest request, String fileType ){
if ( fileType == null ) return false;
if ( fileType.toLowerCase().trim().equals("txt")) return true;
else return false;
}
 
public boolean verifyFile(HttpServletRequest request, String fileName, String dstFolder){
return true;
}
 
public String getErrorMessage(HttpServletRequest request){
String message = "Only plain text (.txt) files are permitted.";
return message;
}
}
When the upload security adapter requires file validation, iHub Information Console client copies the file temporarily into the directory specified by TEMP_FOLDER_LOCATION parameter in web.xml.
Deploying an upload security adapter
To deploy an upload security adapter, the iHub Information Console client application must have access to the class compressed into a JAR file. To meet this requirement, compile the class, compress it into a JAR, and move it into the <context root>\WEB‑INF\lib directory for your iHub Information Console client application. Then, add the name of the class as the value for the UPLOAD_SECURITY_ADAPTER parameter in <context root>\WEB‑INF
\web.xml. Finally, restart the application service running iHub Information Console client to activate this change.
How to deploy an upload security adapter to iHub Information Console client
1 Compile the Upload security application. Use a command similar to this one in a console window:
javac SecureUpload.java
2 Create a JAR file to contain the upload security application. Use a command similar to this one in a console window:
jar cvf SecureUpload.jar SecureUpload.class
3 Using Windows Explorer, copy SecureUpload.jar to this directory:
<your application context root>\WEB-INF\lib
4 Using a UTF-8 compliant code editor, open the following file:
<your application context root>\WEB-INF\web.xml
5 Navigate to the parameter name UPLOAD_SECURITY_ADAPTER.
6 Change the param-value parameter of the UPLOAD_SECURITY_ADAPTER to the fully qualified class name for the upload security adapter class. Use an entry similar to this one:
<param-name>UPLOAD_SECURITY_ADAPTER</param-name>
<param-value>SecureUpload</param-value>
7 Save and close web.xml.
8 Restart the application server running iHub Information Console client. For the default installation, restart the Actuate 11 Apache Tomcat for Visualization Platform Service.