Business Objects 4.1 OpenDocument edit with Enterprise Login

AHiggins picture AHiggins · Feb 18, 2014 · Viewed 7.7k times · Source

This question comes from a complete Java newbie, so please don't hesitate to point out obvious or simple things in your answers!

I am working on a migration from Business Objects' 3.1 to 4.1. Part of that migration involves moving existing reports that use OpenDocument URLs to point to the new environment.

The desired behavior is that the users can click the URL and go straight to their report, without being prompted for a login (the environment with the report URLs is already secure). Based on documentation of the OpenDocument feature, I need to add some java code to get a login token and pass it as part of the URL (see section 4.2, page 14 of the linked document). I tried using the java code in the document, adding the appropriate server/user/passwords, to create a file called "custom.jsp" with the following code:

String openDocumentToken() throws SDKException, UnsupportedEncodingException
{
IEnterpriseSession sess = CrystalEnterprise.getSessionMgr().logon("user","pword","cms name:6400","secEnterprise");
String token = sess.getLogonTokenMgr().createLogonToken ("",120,100);
String tokenEncode = URLEncoder.encode  (token,"UTF-8");
sess.logoff();
return( "http://xxx.xxxxxxxxx.com:8080/BOE/OpenDocument/opendoc/openDocument.jsp?iDocID=ATeBlMbXn.xCuSaEElUEGI0&sIDType=CUID&token=" + tokenEncode);
}

However, I still get prompted for a login when I try to access the report under

http://<server>/BOE/OpenDocument/opendoc/custom.jsp

Any ideas? Can I provide any further information to you?

Answer

AHiggins picture AHiggins · Feb 20, 2014

I was missing two pieces: declaring the classes at the top (I told you I was new) and using response.sendredirect() instead of just return(). This document helped, though every document I was able to find assumed that you already knew enough to add in the classes and other tags.

I was able to get everything working, finally, using the following code:

<%@ taglib prefix="rs" uri="http://www.businessobjects.com/resource/rs" %>
<rs:doctype />

<!--
©2010 - 2013 SAP AG or an SAP affiliate company.  All rights reserved.

SAP and other SAP products and services mentioned herein as well as their respective    logos are trademarks or registered trademarks of SAP AG in Germany and other countries.  Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.
-->

<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ page import="com.businessobjects.bip.core.web.context.SessionHelper" %>
<%@ page import="com.businessobjects.bip.core.web.logon.LogonConstants" %>
<%@ page import="com.businessobjects.bip.core.web.utils.Encoder" %>
<%@ page import="com.businessobjects.opendoc.HandleOpenDocParams" %>
<%@ page import="com.businessobjects.opendoc.OpenDocBean" %>
<%@ page import="com.businessobjects.opendoc.OpenDocConstants"%>
<%@ page import="com.businessobjects.opendoc.OpenDocShare"%>
<%@ page import="com.businessobjects.opendoc.OpenDocUtils" %>
<%@ page import="com.businessobjects.swd.shared.actioncache.CafActionProperty" %>
<%@ page import="com.businessobjects.swd.shared.actioncache.ICafAction" %>
<%@ page import="com.businessobjects.webutil.ApplicationUtils" %>
<%@ page import="com.businessobjects.webutil.clientaction.ActionData" %>
<%@ page import="com.businessobjects.webutil.clientaction.ActionHelper" %>
<%@ page import="com.businessobjects.webutil.clientaction.ClientActionException" %>
<%@ page import="com.businessobjects.webutil.PlatformConstants"%>


<%@ page import="com.sap.security.core.server.csi.util.URLEncoder" %>
<%@ page import="com.sap.security.core.server.csi.XSSEncoder" %>
<%@ page import="com.businessobjects.servletbridge.customconfig.ConfigReader"%>
<%@ page import="java.io.IOException" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.businessobjects.swd.security.SecurityUtils"%>
<%@ page import="com.businessobjects.swd.security.SecurityUtils.ProcessingException"%>
<%@ page import="com.businessobjects.webutil.PlatformConstants"%>

<%@ page import="com.crystaldecisions.sdk.framework.*" %> 
<%@ page import="com.businessobjects.foundation.exception.*" %> 
<%@ page import="com.crystaldecisions.sdk.exception.*" %>


<%@ taglib uri='/WEB-INF/fmt.tld' prefix='fmt'%>
<%@ taglib uri='/WEB-INF/c.tld' prefix='c'%>
<%@ taglib uri='/WEB-INF/c-rt.tld' prefix='c_rt'%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="cwl" uri="http://www.businessobjects.com/jsf/bip.core.web.logon"%>

<jsp:useBean id="openDocBean" class="com.businessobjects.opendoc.OpenDocBean"     scope="request"/>



<html>
<head>
    <title>This is Custom</title>        
</head>
<body>
<%
{

                IEnterpriseSession sess = CrystalEnterprise.getSessionMgr().logon("user","pwd","server:6400","secEnterprise");

            String token = sess.getLogonTokenMgr().createLogonToken("",120,100);

            String tokenEncode = URLEncoder.encode(token,"UTF-8");

            response.sendRedirect("http://<server>/BOE/OpenDocument/opendoc/openDocument.jsp?" + request.getQueryString() + "&token=" + tokenEncode);

} 

%>


    </body>
</html>

I was able to run this with a hardcoded CUID with only the following three classes specified in the beginning of the document:

<%@ page import="com.crystaldecisions.sdk.framework.*" %> 
<%@ page import="com.businessobjects.foundation.exception.*" %> 
<%@ page import="com.crystaldecisions.sdk.exception.*" %>

However, when I combined the login section with the request.GetQueryString() function, I just added the three classes to the list that I already knew was working with that function. You could probably write this with only a few classes.

The custom.jsp file was placed in the directory ...\tomcat\webapps\BOE\WEB-INF\eclipse\plugins\webpath.OpenDocument\web\opendoc

To get the code to 'take', I had to stop the Tomcat service, delete the BOE folder under the ...tomcat\work\Catalina\localhost directory, then restart the Tomcat service and wait until it repopulated all the files in the Work directory (about six minutes).

To access my custom file, I used the URL http://myserver:8080/BOE/OpenDocument/opendoc/custom.jsp

Hopefully that will help another complete Java newbie who has a similar questions regarding creating a Custom.JSP file to automatically sign in users trying to use OpenDocument, either with Enterprise or other authentication, without prompting for a login screen.