+
+ if (mc && mc->established &&
+ mag_basic_check(cfg, mc, ba_user, ba_pwd)) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, req,
+ "Already established BASIC AUTH context found!");
+ mag_set_req_data(req, cfg, mc);
+ ret = OK;
+ goto done;
+ }
+
+ break;
+
+ case AUTH_TYPE_RAW_NTLM:
+ if (!is_mech_allowed(cfg, &gss_mech_ntlmssp)) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, req,
+ "NTLM Authentication is not allowed!");
+ goto done;
+ }
+
+ if (!parse_auth_header(req->pool, &auth_header, &input)) {
+ goto done;
+ }
+
+ desired_mechs = discard_const(&gss_mech_set_ntlmssp);
+ break;
+
+ default:
+ goto done;
+ }
+
+ if (mc && mc->established) {
+ /* if we are re-authenticating make sure the conn context
+ * is cleaned up so we do not accidentally reuse an existing
+ * established context */
+ mag_conn_clear(mc);
+ }
+
+ req->ap_auth_type = apr_pstrdup(req->pool, auth_types[auth_type]);
+
+#ifdef HAVE_CRED_STORE
+ if (cfg->use_s4u2proxy) {
+ cred_usage = GSS_C_BOTH;
+ }
+#endif
+ if (!mag_acquire_creds(req, cfg, desired_mechs,
+ cred_usage, &acquired_cred, NULL)) {
+ goto done;
+ }
+
+ if (auth_type == AUTH_TYPE_BASIC) {