Java Reference
In-Depth Information
thisrequest.However,youcaninstallacustomizedserverthatwillresultinthisrequest,
and Listing11-22 presentsanenhanced TempVerterPublisher applicationthatac-
complishes this task.
Listing 11-22. Supporting basic authentication with the TempVerterPublisher application
import java.io.IOException;
import java.net.InetSocketAddress;
import javax.xml.ws.Endpoint;
import com.sun.net.httpserver.BasicAuthenticator;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpServer;
import ca.tutortutor.tv.TempVerterImpl;
class TempVerterPublisher
{
public static void main(String[] args) throws IOExcep-
tion
{
HttpServer server = HttpServer.create(new InetSock-
etAddress(9901), 0);
HttpContext context = server.createContext("/Tem-
pVerter");
BasicAuthenticator auth;
auth = new BasicAuthenticator("myAuth")
{
@Override
public boolean checkCredentials(String username,
String password)
{
return
username.equals("x")
&&
pass-
word.equals("y");
}
Search WWH ::




Custom Search