cancel
Showing results for 
Search instead for 
Did you mean: 

Open Document using logon token

former_member316829
Participant
0 Kudos

I generated a logon token which is something like below using RESTful API code :

"BLRABAIO13.ao.aogrp.local:6400@{3&2=10096,U3&2v=BLRABAIO13.ao.aogrp.local:6400,UP&66=60,U3&68=secEnterprise:AOABCDEFGH,UP&S9=6198,U3&qe=100,U3&vz=nT9hgPwbgn6ERZv2k68P8Tlnl._kNwfTpev026KCbWk,UP}"

Using this i am trying to access a document on the BI server, like

http://blrabaio13:8080/BOE/OpenDocument/opendoc/openDocument.jsp?iDocID=AY.sKzGgXcpMge9B1xMPOlU&sIDT...

"BLRABAIO13.ao.aogrp.local:6400@{3&2=10096,U3&2v=BLRABAIO13.ao.aogrp.local:6400,UP&66=60,U3&68=secEnterprise:AOABCDEFGH,UP&S9=6198,U3&qe=100,U3&vz=nT9hgPwbgn6ERZv2k68P8Tlnl._kNwfTpev026KCbWk,UP}"

However it still asks for credentials.

Without giving the credentials, is it possible to access a document using the logontoken

Accepted Solutions (1)

Accepted Solutions (1)

Joe_Peters
Active Contributor

Try:

logonToken = invocation.getResponseHeader('X-SAP-LogonToken');
logonToken = logonToken.substring(1,logonToken.length-1);
logonToken = encodeURIComponent(logonToken);

Explanation:

The invocation.getResponseHeader(X-SAP-LogonToken') call returns the logon token enclosed in double quotes. The token must be URI encoded before passing to openDocument, however the enclosing double quotes must not be URI encoded.

The above call might return a value such as:

"server.domain.com:6400@xxx"

If this string (including the quotes) is URIencoded, you'll get:

%22server.domain.com%3A6400%40xxx%22

The "%22"s on each end are from the double quotes, and will cause openDocument to not recognize the token. So, the double quotes need to be removed before encoding.

former_member316829
Participant
0 Kudos

Yes, I have the code for Token generation using RESTful API code

I have the code as below:

function generateToken()

{

var invocation = new XMLHttpRequest();

var url = 'http://uswv1vxap007:6405/biprws/logon/long';

var body = '<?xml version="1.0" ?> <attrs xmlns="http://www.sap.com/rws/bip"> <attr name="userName" type="string">portal</attr> <attr name="password" type="string">Portal</attr> <attr name="auth" type="string" possibilities="secEnterprise">secEnterprise</attr> </attrs>';

var logonToken;

invocation.open('POST', url, false);

invocation.setRequestHeader('X-PINGARUNER', 'pingpong');

invocation.setRequestHeader('Content-Type', 'application/xml');

invocation.setRequestHeader('Accept', 'application/xml');

invocation.send(body);

logonToken = decodeURI(invocation.getResponseHeader('X-SAP-LogonToken'));

return logonToken; }

From this i have returned the LogonToken, now I am not sure how do i URI encode this token. Could you please help.

Joe_Peters
Active Contributor
0 Kudos

Try converting it with encodeURIComponent()

former_member316829
Participant
0 Kudos

I tried giving

logonToken = encodeURI(invocation.getResponseHeader('X-SAP-LogonToken'));

instead of

logonToken = decodeURI(invocation.getResponseHeader('X-SAP-LogonToken'));

but no luck.

Joe_Peters
Active Contributor
0 Kudos

See my updated answer.

Answers (2)

Answers (2)

Former Member

Hi Deepak,

Your code looks correct.

However, I am seeing a decodeURI function has been called in your code.

This function is used for decode the URI.

Suppose, I have the following piece of code:

var uri = "my test.asp?name=ståle&car=saab";
var enc = encodeURI(uri);
var dec = decodeURI(enc);

Then response would be like below:

Encoded URI: my%20test.asp?name=st%C3%A5le&car=saab
Decoded URI: my test.asp?name=ståle&car=saab

In your piece of code, try replacing the decodeURI with encodeURI & give it a try. Joe also mentioned that you have to encode the URI. Also you have to apply a fiddler trace to capture the URI/URL generated through code & use directly in browser to check weather the URI/URL generated through RESTful web services correct or not.

Is this issue is browser specific? Have you tried executing the same workflow using any other browser. Internet Explorer have the character limitation of URL/URI. Keep track how long your URL/URI is generated.

Hope this will give you some pointers to troubleshoot the issue.

Thanks,

Shailendra

former_member316829
Participant
0 Kudos

These were the missing steps:

logonToken = invocation.getResponseHeader('X-SAP-LogonToken');

//remove double codes from Token

logonToken = logonToken.replace(/(^")|("$)/g, '');

//encode Token

logonToken = encodeURIComponent(logonToken);

Then return this LogonToken

former_member316829
Participant
0 Kudos

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@page import="com.crystaldecisions.enterprise.ocaframework.idl.OCCA.OCCAs.SessionManager"%>

<%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>

<%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>

<%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>

<%@ page import="com.crystaldecisions.sdk.occa.security.ILogonTokenMgr" %>

<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>

<%@ page import="com.crystaldecisions.celib.properties.URLEncoder" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<script type="text/javascript">

function generateToken()

{

var invocation = new XMLHttpRequest();

var url = 'http://Server:6405/biprws/logon/long';

var body = '<?xml version="1.0" ?> <attrs xmlns="http://www.sap.com/rws/bip"> <attr name="userName" type="string">Admin</attr>

<attr name="password" type="string">Abcd1234</attr> <attr name="auth" type="string" possibilities="secEnterprise">secEnterprise</attr> </attrs>';

var logonToken;

invocation.open('POST', url, false);

invocation.setRequestHeader('X-PINGARUNER', 'pingpong');

invocation.setRequestHeader('Content-Type', 'application/xml');

invocation.setRequestHeader('Accept', 'application/xml');

invocation.send(body); logonToken = decodeURI(invocation.getResponseHeader('X-SAP-LogonToken'));

alert(logonToken);

return logonToken;

}

</script>

</head>

<body>

<script>

function apply()

{

var tokenVal = generateToken();

window.location = ("http://Server:8080/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=ATacD4.rsaEcdE1LsL_OpLKR5fU&token="+tokenVal);

}

apply();

</script>

</body>

</html>

This is my entire code, even after this I am prompted for User name and password, Am i doing anything wrong here.