Skip to Content
author's profile photo
Former Member

Retrieve MYSAPSSO2 Cookie in Java iView

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • author's profile photo
    Former Member
    May 13, 2004 at 06:56 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    May 13, 2004 at 04:11 PM

    Dagfinn Parnas

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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

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

      }

      %>