Java Business Objects 4.1使用企业登录进行OpenDocument编辑

Java Business Objects 4.1使用企业登录进行OpenDocument编辑,java,business-objects,business-objects-sdk,Java,Business Objects,Business Objects Sdk,这个问题来自一个完全的Java新手,所以请不要犹豫,在您的答案中指出明显或简单的事情 我正在进行从Business Objects的3.1到4.1的迁移。迁移的一部分涉及移动使用OpenDocument URL指向新环境的现有报告 所需的行为是,用户可以单击URL并直接转到他们的报告,而无需提示登录(具有报告URL的环境已经是安全的)。基于OpenDocument特性的一部分,我需要添加一些java代码来获取登录令牌并将其作为URL的一部分传递(请参阅链接文档第14页第4.2节)。我尝试使用文档

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

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

所需的行为是,用户可以单击URL并直接转到他们的报告,而无需提示登录(具有报告URL的环境已经是安全的)。基于OpenDocument特性的一部分,我需要添加一些java代码来获取登录令牌并将其作为URL的一部分传递(请参阅链接文档第14页第4.2节)。我尝试使用文档中的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
http:///BOE/OpenDocument/opendoc/custom.jsp

有什么想法吗?我可以向您提供更多信息吗?

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

我已经在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);

我缺少两个部分:在顶部声明类(我告诉过你我是新的)和使用response.sendredirect()而不是return()。虽然我能找到的每个文档都假设您已经知道了足够多的知识,可以添加类和其他标记,但这很有帮助

最后,通过使用以下代码,我能够让一切正常工作:

<%@ 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运行此操作,该CUID仅包含文档开头指定的以下三个类:

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

但是,当我将login部分与
request.GetQueryString()函数结合使用时,我只是将这三个类添加到了我已经知道正在使用该函数的列表中。您可能只需要几个类就可以编写这篇文章

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

为了让代码“take”,我必须停止Tomcat服务,删除
…Tomcat\work\Catalina\localhost
目录下的BOE文件夹,然后重新启动Tomcat服务,等待它重新填充工作目录中的所有文件(大约六分钟)

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


希望这将帮助另一个完整的Java新手,他对创建Custom.JSP文件有类似的疑问,可以自动登录尝试使用OpenDocument的用户,无论是企业身份验证还是其他身份验证,而不需要提示登录屏幕

你对返回的URL做什么?只是创建一个要单击的链接,转发或重定向浏览器?此外,我还必须在
response.sendredirect()
行之前添加
sess.logoff()
行。对JSP的初始调用创建一个会话,然后该会话为第二个会话检索令牌。
sess.logoff()
代码随后注销初始调用,同时使令牌会话保持活动状态。