internal void PreAuthIfNeeded(HttpWebRequest httpWebRequest, ICredentials authInfo) {
//
// attempt to do preauth, if needed
//
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() TriedPreAuth:" + TriedPreAuth.ToString() + " authInfo:" + ValidationHelper.HashString(authInfo));
if (!TriedPreAuth) {
TriedPreAuth = true;
if (authInfo!=null) {
PrepareState(httpWebRequest);
Authorization preauth = null;
try {
preauth = AuthenticationManager.PreAuthenticate(httpWebRequest, authInfo);
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() preauth:" + ValidationHelper.HashString(preauth));
if (preauth!=null && preauth.Message!=null) {
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() setting TriedPreAuth to Complete:" + preauth.Complete.ToString());
UniqueGroupId = preauth.ConnectionGroupId;
httpWebRequest.Headers.Set(AuthorizationHeader, preauth.Message);
}
}
catch (Exception exception) {
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() PreAuthenticate() returned exception:" + exception.Message);
ClearSession(httpWebRequest);
}
catch {
GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() PreAuthenticate() returned exception: Non-CLS Compliant Exception");
ClearSession(httpWebRequest);
}
}
}
}