internal TSIP_Header CreateHeaderAuthorization(TSIP_Request request) { if (request == null) { TSK_Debug.Error("Invalid parameter"); return null; } String response, nc = null, uristring; if (String.IsNullOrEmpty(uristring = TSIP_Uri.ToString(request.Uri, true, false))) { TSK_Debug.Error("Failed to parse URI: {0}", request.Uri); return null; } /* We compute the nc here because @ref tsip_challenge_get_response function will increment it's value. */ if (mNc > 0) { nc = THTTP_Auth.GetNonceString(mNc).ToString(); } /* entity_body ==> request-content */ response = GetResponse(request.Method, uristring, request.Content); if (mProxy) { // FIXME TSK_Debug.Error("Proxy-Authorization header not supported yet"); } else { TSIP_HeaderAuthorization header = new TSIP_HeaderAuthorization(); header.UserName = ChallengeUserName; header.Scheme = mScheme; header.Realm = mRealm; header.Nonce = mNonce; header.Qop = mQop; header.Algorithm = String.IsNullOrEmpty(mAlgorithm) ? "MD5" : mAlgorithm; header.Cnonce = mNc > 0 ? mCnonce : null; header.Uri = uristring; header.Nc = mNc > 0 ? nc : null; header.Response = response; return header; } return null; }
internal static TSIP_Header CreateEmptyAuthorization(String username, String realm, String uristring) { TSIP_HeaderAuthorization header = new TSIP_HeaderAuthorization(); header.Scheme = "Digest"; header.UserName = username; header.Realm = realm; header.Nonce = String.Empty; header.Response = String.Empty; header.Uri = uristring; return header; }