2014-02-18 61 views
0

這個問題來自一個完整的Java新手,所以請不要猶豫,在您的答案中指出明顯或簡單的事情!Business Objects 4.1 OpenDocument使用企業登錄編輯

我正在從Business Objects的3.1遷移到4.1。部分遷移涉及移動使用OpenDocument URL的現有報告以指向新環境。

期望的行爲是用戶可以單擊URL並直接轉到他們的報告,而不會提示您進行登錄(報告URL的環境已經安全)。基於OpenDocument功能的documentation,我需要添加一些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 

任何想法嗎?我可以向您提供更多信息嗎?

+0

你在做什麼與返回的網址?只需創建一個點擊鏈接,轉發或重定向瀏覽器? – shrub34

回答

2

我錯過了兩個部分:頂部聲明的類(我告訴你,我是新的),並使用response.sendRedirect是(),而不是隻返回( )。 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

要獲取該代碼「拿走」,我不得不停止Tomcat服務時,...tomcat\work\Catalina\localhost目錄下刪除BOE文件夾,然後重新啓動Tomcat服務並等待,直到它重新填充工作目錄中的所有文件(大約六分鐘)。

要訪問我的自定義文件,我使用的URL http://myserver:8080/BOE/OpenDocument/opendoc/custom.jsp

希望這將有助於另一個完整的Java新手,誰擁有有關創建Custom.JSP文件,在用戶試圖使用OpenDocument的自動登錄了類似的問題,無論是與企業或其他身份驗證,而不會提示登錄屏幕。

+0

此外,我必須在'response.sendredirect()'行之前添加'sess.logoff()'行。對JSP的初始調用會創建一個會話,然後爲第二個會話檢索一個令牌。 'sess.logoff()'代碼然後退出初始調用,而令令牌會話保持活動狀態。 – AHiggins

0

只要從中創建標記的會話保持活動狀態,登錄標記就會工作...從代碼中可以看出,您正在調用sess.logoff,這會導致令牌無用。你需要刪除該行

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