Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4965261

Add support for HttpURLConnection.setDefaultRequestProperty()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.2_02
    • core-libs
    • None
    • generic
    • solaris_9

      We are using SUNOne IS product. We have SUNOne IS Policy agent running on the web-server to
      secure the access to web-server files and directory so that only valid user can access them. When
      our client software (may be running locally or remotely) want to access such secured web
      files/directory they create object of class java.net.HttpURLConnection. The SUNOne IS Policy
      agent requires that the SSOToken ID string should be inserted as a cookie in the
      HttpURLConnection object. Otherwise the access to the secure file/directory will be denied.

      In our client software, to set the cookie in the HttpURLConnection object we have to call
      setRequestProperty() method of java.net.URLConnection class (super class of
      HttpURLConnection class) and pass the cookie name and cookie value(SSOToken ID string) as
      the argument. Since we have many different plugins in our client software that are running in the
      same process and creating HttpURLConnection object, each of them have to be modified to call
      setRequestProperty(). Though the change is small, it has to be done at many places. This is
      impacting not just us but also our partners (internal customer) as it is causing changes in their
      software too.

      The URLConnection class in J2SE has static methods
      setDefaultRequestProperty() and getDefaultRequestProperty() that are currently available but
      marked as deprecated. Using setDefaultRequestProperty() we can set a cookie once and then it will
      get automatically set into each HttpURLConnection object by J2SE without us having to change
      our software. If we use setDefaultRequestProperty() then we will avoid changes at many places.
      However since this method is marked as deprecated by J2SE we cannot use them.

      We only have to call HttpURLConnection.setDefaultRequestProperty() once for the entire session of our GUI. This is desirable for us because we can call this method once when our GUI starts in order to set SSOToken as a cookie (as required by SunOne IS). And then J2SE will automatically set this SSOToken as a cookie in all subsequest instances of HttpURLConnection class that are created. This means that ours (and our customers) existing classes that creates instances of HttpURLConnection class (using URL.openConnection()) for accessing secure web files/directory does not have to be changed as the cookie will be automatically set by J2SE in those instances.

            jccollet Jean-Christophe Collet (Inactive)
            cprasadsunw Ck Prasad (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: