private String resetPreferredIDPCookie(String existingCookieValue,String toAddCookieValue,boolean bIsSAML2){
  StringBuffer returnCookie=new StringBuffer();
  String encodedCookieToAdd=Base64.encode(generateSuccinctID(toAddCookieValue,bIsSAML2));
  StringTokenizer st=new StringTokenizer(existingCookieValue,IDPDiscoveryConstants.PREFERRED_COOKIE_SEPERATOR);
  while (st.hasMoreTokens()) {
    String curIdpString=(String)st.nextToken();
    if (curIdpString.equals(encodedCookieToAdd)) {
      continue;
    }
 else {
      returnCookie.append(curIdpString + " ");
    }
  }
  returnCookie.append(encodedCookieToAdd);
  return returnCookie.toString();
}

private String resetPreferredIDPCookie ( String existingCookieValue , String toAddCookieValue , boolean bIsSAML2 ) { StringBuffer returnCookie = new StringBuffer ( ) ; String encodedCookieToAdd = Base64 . encode ( generateSuccinctID ( toAddCookieValue , bIsSAML2 ) ) ; StringTokenizer st = new StringTokenizer ( existingCookieValue , IDPDiscoveryConstants . PREFERRED_COOKIE_SEPERATOR ) ; while ( st . hasMoreTokens ( ) ) { String curIdpString = ( String ) st . nextToken ( ) ; if ( curIdpString . equals ( encodedCookieToAdd ) ) { continue ; } else { returnCookie . append ( curIdpString + " " ) ; } } returnCookie . append ( encodedCookieToAdd ) ; return returnCookie . toString ( ) ; }
this function is used to reset the preferred idp cookie based on the present value and the providerid of the idp that calls this service
