internal void Update(HttpWebRequest httpWebRequest) {
//
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::Update() httpWebRequest#" + ValidationHelper.HashString(httpWebRequest) + " Authorization#" + ValidationHelper.HashString(Authorization) + " ResponseStatusCode:" + httpWebRequest.ResponseStatusCode.ToString());
if (Authorization!=null) {
PrepareState(httpWebRequest);
ISessionAuthenticationModule myModule = Module as ISessionAuthenticationModule;
if (myModule!=null) {
//
// the whole point here is to complete the Security Context. Sometimes, though,
// a bad cgi script or a bad server, could miss sending back the final blob.
// in this case we won't be able to complete the handshake, but we'll have to clean up anyway.
//
string challenge = httpWebRequest.AuthHeader(AuthenticateHeader);
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::Update() Complete:" + Authorization.Complete.ToString() + " Module:" + ValidationHelper.ToString(Module) + " challenge:" + ValidationHelper.ToString(challenge));
if (!IsProxyAuth && httpWebRequest.ResponseStatusCode==HttpStatusCode.ProxyAuthenticationRequired) {
//
// don't call Update on the module, since there's an ongoing
// handshake and we don't need to update any state in such a case
//
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::Update() skipping call to " + myModule.ToString() + ".Update() since we need to reauthenticate with the proxy");
}
else {
bool complete = true;
try {
complete = myModule.Update(challenge, httpWebRequest);
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::Update() " + myModule.ToString() + ".Update() returned complete:" + complete.ToString());
}
catch (Exception exception) {
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::Update() " + myModule.ToString() + ".Update() caught exception:" + exception.Message);
ClearSession(httpWebRequest);
}
catch {
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::Update() " + myModule.ToString() + ".Update() caught exception: Non-CLS Compliant Exception");
ClearSession(httpWebRequest);
}
Authorization.SetComplete(complete);
}
}
//
// If authentication was successful, create binding between
// the request and the authorization for future preauthentication
//
if (Module != null && Authorization.Complete && Module.CanPreAuthenticate && httpWebRequest.ResponseStatusCode!=StatusCodeMatch) {
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::Update() handshake is Complete calling BindModule()");
AuthenticationManager.BindModule(ChallengedUri, Authorization, Module);
}
}
}