* Retrieve the WWW-Authenticate header from server response based on the
* authentication scheme being used.
*/
-static NTSTATUS http_parse_auth_response(enum http_auth_method auth,
+static NTSTATUS http_parse_auth_response(const DATA_BLOB prefix,
struct http_request *auth_response,
DATA_BLOB *in)
{
continue;
}
- switch (auth) {
- case HTTP_AUTH_NTLM:
- if (strncasecmp(h->value, "NTLM ", 5) == 0) {
- *in = data_blob_string_const(h->value);
- return NT_STATUS_OK;
- }
- break;
- default:
- break;
+ cmp = strncasecmp(h->value,
+ (const char *)prefix.data,
+ prefix.length);
+ if (cmp != 0) {
+ continue;
}
+
+ *in = data_blob_string_const(h->value);
+ return NT_STATUS_OK;
}
return NT_STATUS_NOT_SUPPORTED;
struct tevent_queue *send_queue;
enum http_auth_method auth;
+ DATA_BLOB prefix;
struct gensec_security *gensec_ctx;
NTSTATUS gensec_status;
switch (state->auth) {
case HTTP_AUTH_BASIC:
mech_name = "http_basic";
+ state->prefix = data_blob_string_const("Basic");
break;
case HTTP_AUTH_NTLM:
mech_name = "http_ntlm";
+ state->prefix = data_blob_string_const("NTLM");
break;
default:
tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
return;
}
- status = http_parse_auth_response(state->auth,
+ status = http_parse_auth_response(state->prefix,
state->auth_response,
&gensec_in);
if (tevent_req_nterror(req, status)) {