Java Reference
In-Depth Information
String krb5user; // Assume Kerberos 5.
char[] krb5pass;
// get krb5user and krb5pass in your own way
...
return (new PasswordAuthentication(krb5user, kr-
b5pass));
}
else
{
...
}
}
}
Note FormoreinformationonJava'ssupportforSPNEGOandtheotherauthentica-
tionschemes,checkouttheJDK7documentation's“HttpAuthentication”pageat ht-
tp://download.oracle.com/javase/7/docs/technotes/guides/
net/http-auth.html .
Cookie Management
Serverapplicationscommonlyuse HTTP cookies (stateobjects)— cookies forshort—to
persistsmallamountsofinformationonclients.Forexample,theidentifiersofcurrently
selecteditemsinashoppingcartcanbestoredascookies.It'spreferabletostorecookies
ontheclient,ratherthanontheserver,becauseofthepotentialformillionsofcookies
(depending on a website's popularity). In that case, not only would a server require a
massiveamountofstoragejustforcookies,butalsosearchingforandmaintainingcook-
ies would be time consuming.
Note Check out Wikipedia's “HTTP cookie” entry ( ht-
tp://en.wikipedia.org/wiki/HTTP_cookie ) for a quick refresher on
cookies.
AserverapplicationsendsacookietoaclientaspartofanHTTPresponse.Aclient
(e.g., a web browser) sends a cookie to the server as part of an HTTP request. Before
Java5,applicationsworkedwiththe URLConnection class(andits HttpURLCon-
nection subclass) to get an HTTP response's cookies and to set an HTTP request's
cookies.The String getHeaderFieldKey(int n) and String getHead-
Search WWH ::




Custom Search