One of the frequent questions from our customers is how to create a customized SSO enterprise authentication for BI LaunchPad and for Open Document queries. One of the most easiest way is to use servlet filter in Tomcat. You can find below the steps needed to create, develop and deploy the SSO filter:
Create a new project in Eclipse:
Enter the project name and pick the Tomcat runtime (same as your BI web server):
Add a new class to your project
Type the package name, class name and click on Add button
Type filter and choose the interface javax.servlet.Filter
Click on finish
Copy the SDK libraries from the folder below to a project folder:
Go to configure build path of your project and add the SDK files, using Add External JARs button:
Copy and paste the code below into the SSOFilter.java file:
package com.xxx.yyy.aaa;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SSOFilter implements Filter {
private static FilterConfig filterConfig = null;
public SSOFilter() {}
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
HttpServletRequest servletRequest = (HttpServletRequest)request;
HttpServletResponse servletResponse = (HttpServletResponse)response;
String userName = "test";
String password = "password";
String requestURL = servletRequest.getRequestURL().toString();
try
{
if (requestURL.contains("openDocument.jsp") && servletRequest.getParameter("token")==null) {
servletResponse.sendRedirect(requestURL+"?iDocID="+servletRequest.getParameter("iDocID")+"&sIDType="+
servletRequest.getParameter("sIDType")+"&token="+createEncodedToken(userName, password));
} else if (requestURL.contains("BOE/BI") && !(requestURL.contains("start"))) {
((HttpServletResponse) response).sendRedirect(requestURL+"/logon/start.do?ivsLogonToken="+createEncodedToken(userName, password));
} else {
chain.doFilter(request, response);
}
} catch (SDKException e) {
chain.doFilter(request, response);
} catch (UnsupportedEncodingException e) {
chain.doFilter(request, response);
}
}
@Override
public void init(FilterConfig config) throws ServletException {
// TODO Auto-generated method stub
setFilterConfig(config);
}
public String createEncodedToken(String userName, String password) throws SDKException, UnsupportedEncodingException {
IEnterpriseSession enterpriseSession = CrystalEnterprise.getSessionMgr().logon(userName, password, "localhost", "secEnterprise");
return URLEncoder.encode(enterpriseSession.getLogonTokenMgr().createWCAToken("", 750, 9999), "UTF-8");
}
private void setFilterConfig(FilterConfig config)
{
filterConfig = config;
}
private static FilterConfig getFilterConfig()
{
return filterConfig;
}
}
It should look like the following:
Export the project as JAR file:
Select only source files, like below:
Copy the jar file into the following folder:
Modify the file web.xml from the folder to add the new SSO filter:
Add the class name and the filter and filter-mapping xml nodes as following:
Restart the tomcat server and the filter should be running!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
25 | |
21 | |
12 | |
9 | |
9 | |
8 | |
8 | |
8 | |
7 |