cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve MYSAPSSO2 Cookie in Java iView

Former Member
0 Kudos

Hello guru's

I have a question. I am attempting to grab the users current SSO2 cookie and pass it as a hidden param. Does anyone know how you can retrieve the MYSAPSSO2 cookie in a java iview?

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Dagfinn Parnas

Thank you this is exactly what I require!! Pure Magic!!

Former Member
0 Kudos

I have a question about this.

I've got sap web as working with bsps. This server is in other machine. Can I even get this cookie?

I was thinking that if the server name change, then can't get the cookie. Is it really possible?

Thank you very much!

PD: paco paco ¿hablas castellano?

Former Member
0 Kudos

Can you clairify what you are asking Dominguez? Are you trying to get the SSO2 Cookie from a bsp page?

P.D sorry but I do not speak Castilian!! (only understand a bit)

Former Member
0 Kudos

Yes, that's what I want!!

I'm working with EP 5 in one server, and the SAP Web AS is in another one in a different domain!! that is the problem I think. First I log on to the portal, and after that I click on a link how call an iView working in other server in other domain.

Thanks in advance!

Former Member
0 Kudos

What you need to do is to create an alias for the portal which is in the domain your other server is in. If you can't do this, it is not possible.

Then you create an iview which is loaded on startup (by for example adding it to the default framework page).

Some cutting and pasting from an SAP document

In the Portal set the value URL

Template of your iView to:

<Request.Protocol>://

[your servername]/irj/

servlet/prt/portal/prtroot/

InitialLogonSupport.default

?MYSAPSSO2=

<Request.SSO2Ticket>

4.3 Issue SAP Logon Ticket with Custom Code

In case it is not possible to install one of the available web server filters for SSO, you can use custom

code to issue a SAP Logon ticket for another domain.

o sendSSO2Cookie.jsp

4.3.1 Custom JSP File

1. Copy the file "sendSSO2Cookie.jsp"

to any JAVA application server

2. In the Portal set the value URL

Template of your iView to:

<Request.Protocol>://

[your servername plus path]

/sendSSO2Cookie.jsp?

MYSAPSSO2=

<Request.SSO2Ticket>

4.4 Integrate Cookie Provider iView into the Portal

1. Open the framework page which is

used for your portal users

2. Add your provider iView(s) to the

page.

The jsp page has the following contents

<%@ page import = "java.net.URLEncoder" %>

<%

String cookieval = request.getParameter("MYSAPSSO2");

String server = request.getServerName();

int dotPos = server.indexOf(".");

if (cookieval != null && !cookieval.equals("")) {

Cookie cookie = new Cookie ("MYSAPSSO2", URLEncoder.encode(cookieval));

if (dotPos != -1) {

cookie.setDomain(server.substring(dotPos+1));

}

cookie.setPath("/");

response.addCookie(cookie);

%>

<html>

<head></head>

<body>

<h1>Done.</h1>

</body>

</html>

<%

}

else {

response.setStatus(403);

}

%>

Former Member
0 Kudos

Think you can get it from the request (IPortalComponentRequest and HTTPServletRequest can both be used)


final String SAP_LOGON_TICKET_COOKIE_NAME = "MYSAPSSO2" ;
Cookie[] cookies = request.getCookies();
String ticketValue = null; 

for(int i = 0 ; i<cookies.length ; i++) {
 if (cookies<i>.getName().equalsIgnoreCase(SAP_LOGON_TICKET_COOKIE_NAME) ) {
  logonTicketFound = true;   
  ticketValue = cookies<i>.getValue()
 }
}

But in most cases it would be better to create the sap logon ticket for multiple domains and let IE forward it for you (there is a document on this that I got from SAP which was version 0.9), but this won't work if you are doing http calls directly from a java class.