Creating a custom security adapter class
Extend the iPortal security adapter class to customize authentication. The iPortal security adapter requires access to the following libraries:
*javax.servlet.http.*
*com.actuate.iportal.security.iPortalSecurityAdapter
iPortalSecurityAdapter provides a set of empty methods. Extend this class and override any of the methods to provide custom IPSE authentication. To establish a secure session with using a custom security adapter, the following methods are required:
*A constructor
*authenticate()
*getPassword()
*getUserName()
The login module of the Java Components call methods in the custom security class to perform authentication and to retrieve login credentials. The authenticate( ) method returns a boolean value to indicate whether the login credentials provided are acceptable. The getter methods return the authenticated credentials. Each user name and password must correspond to an authentic user account. For example, to support a URL that authenticates using a single parameter, code, override authenticate( ) to retrieve the parameter from the HttpServletRequest and set the user name, password, and home folder as in the following class:
import javax.servlet.http.*;
import com.actuate.iportal.security.iPortalSecurityAdapter;
public class SecurityCode extends com.actuate.iportal.security.iPortalSecurityAdapter {
private String userName = null;
private String password = null;
public SecurityCode( ) {}
public boolean authenticate( HttpServletRequest httpservletrequest) {
String param = httpservletrequest.getParameter("code");
boolean secured = true;
if ("12345".equalsIgnoreCase( param )) {
userName = "user1";
password = "user1";
} else if ("abc".equalsIgnoreCase( param )) {
userName = "BasicUser";
password = "";
} else {
secured = false;
}
return secured;
}
public String getUserName() { return userName; }
public String getPassword() { return password; }
public String getUserHomeFolder() { return userName; }
public byte[] getExtendedCredentials() { return null; }
public boolean isEnterprise() { return false; }
}
Users or pages attempting to authenticate a session with a Java Components application that implements the security adapter above must use URL parameters defined in the authenticate method. Because Java Components have no native security, a custom adapter becomes the sole security module.
How to build the IPSE application
1 Compile the IPSE application. Use a command similar to this one in a console window:
javac SecurityCode.java
2 Create a JAR file to contain the IPSE application. Use a command similar to this one in a console window:
jar cvf SecurityCode.jar SecurityCode.class
3 Using Windows Explorer, copy SecurityCode.jar to this directory:
<your application context root>\WEB-INF\lib
How to deploy the IPSE application
1 Using a UTF-8 compliant code editor, open the following file:
<your application context root>\WEB-INF\web.xml
2 Navigate to the parameter name SECURITY_ADAPTER_CLASS.
3 Change the param-value parameter of the SECURITY_ADAPTER_CLASS to the fully qualified class name of your security manager class. Use an entry similar to this one:
<param-name>SECURITY_ADAPTER_CLASS</param-name>
<param-value>SecurityCode</param-value>
4 Save and close web.xml.
5 To have Actuate Java Components read the new security class from the web.xml file, restart the application server or servlet container.