这个问题来自于一个完整的Java新手,所以请不要犹豫在你的答案中指出显而易见的或简单的事情!
我正在从Business的3.1迁移到4.1。迁移的一部分包括移动使用OpenDocument URL指向新环境的现有报告。
所需的行为是用户可以单击URL并直接进入他们的报表,而无需提示登录(带有报表URL的环境已经安全)。基于文档的OpenDocument特性,我需要添加一些java代码来获取登录令牌并将其作为OpenDocument的一部分传递(参见链接文档的第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有什么想法吗?我能向你提供更多的信息吗?
发布于 2014-02-20 18:27:50
我遗漏了两部分:在顶部声明类(我告诉过您我是新的)和使用response.sendredirect()而不是仅仅返回()。本文件提供了帮助,尽管我找到的每一份文档都假定您已经知道了足够多的知识来添加类和其他标记。
最后,我可以使用以下代码使一切正常工作:
<%@ 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目录中。
要使代码“接受”,我必须停止Tomcat服务,删除...tomcat\work\Catalina\localhost目录下的BOE文件夹,然后重新启动Tomcat服务,直到它重新填充工作目录中的所有文件(大约6分钟)。
为了访问自定义文件,我使用了URL http://myserver:8080/BOE/OpenDocument/opendoc/custom.jsp
希望这将有助于另一个完整的Java,他在创建一个Custom.JSP文件以自动登录尝试使用OpenDocument的用户时遇到了类似的问题,无论是与企业还是其他身份验证,而不提示登录屏幕。
发布于 2014-02-19 05:28:44
只要创建令牌的会话保持活动状态,登录令牌就能工作.从代码中可以看出,您正在调用sess.logoff,这使您的令牌变得无用。你需要移除这一行
发布于 2014-02-20 16:07:50
我在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);https://stackoverflow.com/questions/21858863
复制相似问题