使用Enterprise Login编辑Business Objects 4.1 OpenDocument

时间:2014-02-18 15:56:06

标签: java business-objects business-objects-sdk

这个问题来自一个完整的Java新手,所以请不要犹豫,在你的答案中指出明显或简单的事情!

我正在从Business Objects 3.1到4.1进行迁移。部分迁移涉及将使用OpenDocument URL的现有报告移动到指向新环境。

所需的行为是,用户可以单击该URL并直接转到其报告,而不会被提示进行登录(报告URL的环境已经安全)。基于OpenDocument功能的documentation,我需要添加一些java代码来获取登录令牌并将其作为URL的一部分传递(请参阅链接文档的第4.2节,第14页)。我尝试使用文档中的java代码,添加适当的服务器/用户/密码,使用以下代码创建名为“custom.jsp”的文件:

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);
}

但是,当我尝试访问

下的报告时,仍然会提示我登录
http://<server>/BOE/OpenDocument/opendoc/custom.jsp

有什么想法吗?我可以向您提供任何进一步的信息吗?

3 个答案:

答案 0 :(得分:2)

我错过了两个部分:声明顶部的类(我告诉你我是新的)并使用response.sendredirect()而不是return()。 This document有所帮助,尽管我能找到的每个文档都假定您已经足够知道添加类和其他标记。

最后,我能够使用以下代码完成所有工作:

<%@ 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>

我能够使用硬编码的CUID运行它,只有在文档开头指定的以下三个类:

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

但是,当我将登录部分与request.GetQueryString()函数结合使用时,我只是将这三个类添加到我已经知道正在使用该函数的列表中。你可能只用几个类写这个。

custom.jsp文件放在目录中 ...\tomcat\webapps\BOE\WEB-INF\eclipse\plugins\webpath.OpenDocument\web\opendoc

要获取代码'take',我必须停止Tomcat服务,删除...tomcat\work\Catalina\localhost目录下的BOE文件夹,然后重新启动Tomcat服务并等待它重新填充Work目录中的所有文件(大约六分钟)。

要访问我的自定义文件,我使用了网址http://myserver:8080/BOE/OpenDocument/opendoc/custom.jsp

希望这将有助于另一个完整的Java新手,他们在创建Custom.JSP文件方面有类似的问题,可以自动登录尝试使用OpenDocument的用户,无论是使用Enterprise还是其他身份验证,都不会提示登录屏幕。

答案 1 :(得分:0)

只要创建令牌的会话保持活动状态,登录令牌就会起作用...从您的代码中可以看出,您正在调用sess.logoff,这会使您的令牌无效。您需要删除该行

答案 2 :(得分:0)

我在R4下完成了一组类似的代码。

String openDocumentToken() throws SDKException, UnsupportedEncodingException
{
    IEnterpriseSession sess = CrystalEnterprise.getSessionMgr().logon(USER, PASS, CMS, AUTH);
    String activeToken = sess.getLogonTokenMgr().createLogonToken(machinesLoginValidFrom, minutesValid, numberOfLogins);
    sess.logoff();

    String tokenEncode = URLEncoder.encode(activeToken, "UTF-8");
    return tokenEncode;
}

在我的JSP中:

// redirect
String token = openDocumentToken();
String redirectLocation = "http://" + OPEN_DOC_SERVER_PORT + "/BOE/OpenDocument/opendoc/openDocument.jsp?token="+token;
Enumeration paramNames = request.getParameterNames();
while(paramNames.hasMoreElements())
{
    String paramName = paramNames.nextElement().toString();
    String[] values = request.getParameterValues(paramName);

    for(String val: values)
    {
        redirectLocation += ("&" + paramName + "=" + URLEncoder.encode(val, "UTF-8"));
    }
}

System.out.println("Redirect: " + redirectLocation);
response.sendRedirect(redirectLocation);