Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Here is a small piece of code that can help troubleshoot problems with getting a SSO ticket from a Ticket Issuing System

publicString getSSOTicket(String portalServerHost,intportalServerPort, String portalUser, String portalPassword)throwsException{

String ticket =null;

// Create the URL instance to the ticket issuing system

URL url =newURL("https://"portalServerHost":"portalServerPort"/irj/portal?j_user="portalUser"&j_password="+ portalPassword); URLConnection connection = url.openConnection();

connection.setRequestProperty("content-type","application/binary;charset=UTF-8");

intresponseCode = ((HttpURLConnection) connection).getResponseCode();

if(responseCode == HttpURLConnection.HTTP_OK){

                          String headerName =null;

                          for(inti=1; (headerName = connection.getHeaderFieldKey() )!=null; i++){

                                if(headerName.equals("Set-Cookie")){

                                              String cookie = connection.getHeaderField() ;

                                              if(cookie.indexOf("MYSAPSSO2") != -1)    

                                               ticket = cookie.substring(cookie.indexOf('=') + 1,  cookie.indexOf(';');                                    
                                               break; {}    

                       }

             }

 }

return  ticket;

}

This method takes the following as arguments

        Portal / issuing system's host and port

        Portal / issuing system's user and password

Method will return the issued ticket else null

  • No labels