Exemple #1
0
 /**
  * Returns URL encoded with the cookie Value (SSOToken ID) if cookies are not support. Throws an
  * SSOException in case of an error.
  *
  * <p>The cookie Value is written in the URL based on the encodingScheme specified. The Cookie
  * Value could be written as path info separated by either a "/" OR ";" or as a query string.
  *
  * <p>If the encoding scheme is SLASH then the cookie value would be written in the URL as extra
  * path info in the following format:
  *
  * <pre>
  * protocol://server:port/servletpath/&lt;cookieName>=&lt;cookieValue>?
  *     queryString
  * </pre>
  *
  * <p>Note that this format works only if the path is a servlet, if a a jsp file is specified then
  * webcontainers return with "File Not found" error. To rewrite links which are JSP files with
  * cookie value use the SEMICOLON OR QUERY encoding scheme.
  *
  * <p>If the encoding scheme is SEMICOLON then the cookie value would be written in the URL as
  * extra path info in the following format:
  *
  * <pre>
  * protocol://server:port/path;&lt;cookieName=cookieValue>?queryString
  * </pre>
  *
  * Note that this is not supported in the servlet specification and some web containers do not
  * support this.
  *
  * <p>If the encoding scheme is QUERY then the cookie value would be written in the URL in the
  * following format:
  *
  * <pre>
  * protocol://server:port/path?&lt;cookieName>=&lt;cookieValue>
  * protocol://server:port/path?queryString&amp;
  *       &lt;cookieName>=&lt;cookieValue>
  * </pre>
  *
  * <p>This is the default and OpenSSO always encodes in this format unless otherwise specified. If
  * the URL passed in has query parameter then entity escaping of ampersand will be done before
  * appending the cookie if the escape is true.Only the ampersand before appending cookie parameter
  * will be entity escaped.
  *
  * <p>
  *
  * @param ssoToken Single Sign Token which contains the session string.
  * @param url the URL to be encoded
  * @param encodingScheme possible values are <code>QUERY</code>, <code>SLASH</code>, <code>
  *     SEMICOLON</code>.
  * @param escape <code>true</code> to escape ampersand when appending the Single Sign On Token ID
  *     to request query string.
  * @return encoded URL with cookie value (session ID) based on the encoding scheme.
  * @exception SSOException if URL cannot be encoded.
  */
 public static String encodeURL(
     SSOToken ssoToken, String url, short encodingScheme, boolean escape) throws SSOException {
   String encodedURL = url;
   try {
     SSOTokenID ssoTokenId = ssoToken.getTokenID();
     SessionID sessionID = new SessionID(ssoTokenId.toString());
     Session session = Session.getSession(sessionID);
     encodedURL = session.encodeURL(url, encodingScheme, escape);
   } catch (Exception e) {
     debug.message("Exception encoding URL ", e);
     throw new SSOException(e);
   }
   return encodedURL;
 }