< prev index next >

test/java/net/Authenticator/B4962064.java

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 4962064

  27  * @library ../../../sun/net/www/httptest/
  28  * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
  29  * @run main/othervm B4962064
  30  * @summary Extend Authenticator to provide access to request URI and server/proxy
  31  */
  32 
  33 import java.io.*;
  34 import java.net.*;
  35 
  36 public class B4962064 implements HttpCallback {
  37 
  38     static int count = 0;
  39 
  40     public void request (HttpTransaction req) {
  41         try {
  42             switch (count) {
  43               case 0:
  44                 req.addResponseHeader ("Connection", "close");
  45                 req.addResponseHeader ("WWW-Authenticate", "Basic realm=\"foo\"");
  46                 req.sendResponse (401, "Unauthorized");




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 4962064
  27  * @modules java.base/sun.net.www
  28  * @library ../../../sun/net/www/httptest/
  29  * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
  30  * @run main/othervm B4962064
  31  * @summary Extend Authenticator to provide access to request URI and server/proxy
  32  */
  33 
  34 import java.io.*;
  35 import java.net.*;
  36 
  37 public class B4962064 implements HttpCallback {
  38 
  39     static int count = 0;
  40 
  41     public void request (HttpTransaction req) {
  42         try {
  43             switch (count) {
  44               case 0:
  45                 req.addResponseHeader ("Connection", "close");
  46                 req.addResponseHeader ("WWW-Authenticate", "Basic realm=\"foo\"");
  47                 req.sendResponse (401, "Unauthorized");


< prev index next >