Skip to Content
Author's profile photo Dan Cristian MARINESCU

How to add SSO authentication to BI 4.1 using Java filter

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:

/wp-content/uploads/2014/10/s1_562119.png

Enter the project name and pick the Tomcat runtime (same as your BI web server):

/wp-content/uploads/2014/10/s2_562120.png

Add a new class to your project

/wp-content/uploads/2014/10/s3_562136.png

Type the package name, class name and click on Add button

/wp-content/uploads/2014/10/s4_562137.png

Type filter and choose the interface javax.servlet.Filter

/wp-content/uploads/2014/10/s5_562139.png

Click on finish

/wp-content/uploads/2014/10/s6_562140.png

Copy the SDK libraries from the folder below to a project folder:

/wp-content/uploads/2014/10/s7_562141.png

Go to configure build path of your project and add the SDK files, using Add External JARs button:

/wp-content/uploads/2014/10/s9_562142.png

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:

/wp-content/uploads/2014/10/s10_562143.png

Export the project as JAR file:

/wp-content/uploads/2014/10/s11_562145.png

Select only source files, like below:

/wp-content/uploads/2014/10/s12_562146.png

Copy the jar file into the following folder:

/wp-content/uploads/2014/10/s13_562147.png

Modify the file web.xml from the folder to add the new SSO filter:

/wp-content/uploads/2014/10/s14_562151.png

Add the class name and the filter and filter-mapping xml nodes as following:

/wp-content/uploads/2014/10/s15_562152.png

Restart the tomcat server and the filter should be running!

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.