Example #1
0
 public void request(HttpTransaction req) {
   try {
     authstring = req.getRequestHeader("Authorization");
     System.out.println(authstring);
     switch (count) {
       case 0:
         errorReply(req, "Basic realm=\"wallyworld\"");
         break;
       case 1:
         /* client stores a username/pw for wallyworld
          */
         okReply(req);
         break;
     }
     count++;
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Example #2
0
 void okReply(HttpTransaction req) throws IOException {
   req.setResponseEntityBody("Hello .");
   req.sendResponse(200, "Ok");
   req.orderlyClose();
 }
Example #3
0
 void errorReply(HttpTransaction req, String reply) throws IOException {
   req.addResponseHeader("Connection", "close");
   req.addResponseHeader("Www-authenticate", reply);
   req.sendResponse(401, "Unauthorized");
   req.orderlyClose();
 }