- else if (!strncmp(authorization, "Digest", 6))
- {
- /*
- * Get the username, password, and nonce from the Digest attributes...
- */
-
- if (!httpGetSubField2(&(con->http), HTTP_FIELD_AUTHORIZATION, "username",
- username, sizeof(username)) || !username[0])
- {
- /*
- * Username must not be empty...
- */
-
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdAuthorize: Empty or missing Digest username!");
- return;
- }
-
- if (!httpGetSubField2(&(con->http), HTTP_FIELD_AUTHORIZATION, "response",
- password, sizeof(password)) || !password[0])
- {
- /*
- * Password must not be empty...
- */
-
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdAuthorize: Empty or missing Digest password!");
- return;
- }
-
- if (!httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "nonce",
- nonce))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdAuthorize: No nonce value for Digest "
- "authentication!");
- return;
- }
-
- if (strcmp(con->http.hostname, nonce))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdAuthorize: Bad nonce value, expected \"%s\", "
- "got \"%s\"!", con->http.hostname, nonce);
- return;
- }
-
- /*
- * Validate the username and password...
- */
-
- if (!get_md5_password(username, NULL, md5))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdAuthorize: Unknown MD5 username \"%s\"!",
- username);
- return;
- }
-
- httpMD5Final(nonce, states[con->http.state], con->uri, md5);
-
- if (strcmp(md5, password))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdAuthorize: Authentication failed for \"%s\"!",
- username);
- return;
- }
-
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "cupsdAuthorize: Authorized as %s using Digest",
- username);
-
- con->type = CUPSD_AUTH_DIGEST;
- }