Authorization header
Second part in authentication process. The UAS have sent a Authenticate header and the UAC responds with this one.
Inheritance: IHeader
Example #1
0
        /// <summary>
        /// RFC3261 Section 8.1.3.5 Processing 4xx Responses
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        private bool Process4xx(IClientTransaction transaction, IResponse response)
        {
            if (!StatusCodeHelper.Is4xx(response))
            {
                return(true);
            }

            // Certain 4xx response codes require specific UA processing,
            // independent of the method.

            // If a 401 (Unauthorized) or 407 (Proxy Authentication Required)
            // response is received, the UAC SHOULD follow the authorization
            // procedures of Section 22.2 and Section 22.3 to retry the request with
            // credentials.
            if (response.StatusCode == StatusCode.Unauthorized)
            {
                var request      = (IRequest)transaction.Request.Clone();
                var authenticate = (Authenticate)response.Headers[Authenticate.WWW_NAME];

                var authorization = new Authorization();
                authorization.Nonce = authenticate.Nonce;
            }

            // If a 413 (Request Entity Too Large) response is received (Section
            // 21.4.11), the request contained a body that was longer than the UAS
            // was willing to accept.  If possible, the UAC SHOULD retry the
            // request, either omitting the body or using one of a smaller length.


            // If a 415 (Unsupported Media Type) response is received (Section
            // 21.4.13), the request contained media types not supported by the UAS.
            // The UAC SHOULD retry sending the request, this time only using
            // content with types listed in the Accept header field in the response,
            // with encodings listed in the Accept-Encoding header field in the
            // response, and with languages listed in the Accept-Language in the
            // response.

            // If a 416 (Unsupported URI Scheme) response is received (Section
            // 21.4.14), the Request-URI used a URI scheme not supported by the
            // server.  The client SHOULD retry the request, this time, using a SIP
            // URI.

            // If a 420 (Bad Extension) response is received (Section 21.4.15), the
            // request contained a Require or Proxy-Require header field listing an
            // option-tag for a feature not supported by a proxy or UAS.  The UAC
            // SHOULD retry the request, this time omitting any extensions listed in
            // the Unsupported header field in the response.

            // In all of the above cases, the request is retried by creating a new
            // request with the appropriate modifications.  This new request
            // constitutes a new transaction and SHOULD have the same value of the
            // Call-ID, To, and From of the previous request, but the CSeq should
            // contain a new sequence number that is one higher than the previous.

            // With other 4xx responses, including those yet to be defined, a retry
            // may or may not be possible depending on the method and the use case.
            _logger.Warning("Failed to handle status code: " + response);
            return(false);
        }
Example #2
0
        private Registration Authenticate(RequestContext context)
        {
            Authorization authorization = (Authorization)context.Request.Headers[Authorization.LNAME];
            Registration  registration  = _repository.GetByAuthentication(authorization.Realm, authorization.UserName);

            if (registration == null)
            {
                _logger.Info("Failed to find auth user name: " + authorization.UserName + " in realm " + authorization.Realm);
                context.Response.ReasonPhrase = "Failed to find auth user name";
                context.Response.StatusCode   = StatusCode.BadRequest;
                return(null);
            }

            _repository.UpdateUri(registration, context.Request.From.Uri);

            //TODO: Digest authentication.



            return(registration);
        }
Example #3
0
        /// <summary>
        /// RFC3261 Section 8.1.3.5 Processing 4xx Responses
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        private bool Process4xx(IClientTransaction transaction, IResponse response)
        {
            if (!StatusCodeHelper.Is4xx(response))
                return true;

            // Certain 4xx response codes require specific UA processing,
            // independent of the method.

            // If a 401 (Unauthorized) or 407 (Proxy Authentication Required)
            // response is received, the UAC SHOULD follow the authorization
            // procedures of Section 22.2 and Section 22.3 to retry the request with
            // credentials.
            if (response.StatusCode == StatusCode.Unauthorized)
            {
                var request = (IRequest) transaction.Request.Clone();
                var authenticate = (Authenticate) response.Headers[Authenticate.WWW_NAME];

                var authorization = new Authorization();
                authorization.Nonce = authenticate.Nonce;
            }

            // If a 413 (Request Entity Too Large) response is received (Section
            // 21.4.11), the request contained a body that was longer than the UAS
            // was willing to accept.  If possible, the UAC SHOULD retry the
            // request, either omitting the body or using one of a smaller length.

            // If a 415 (Unsupported Media Type) response is received (Section
            // 21.4.13), the request contained media types not supported by the UAS.
            // The UAC SHOULD retry sending the request, this time only using
            // content with types listed in the Accept header field in the response,
            // with encodings listed in the Accept-Encoding header field in the
            // response, and with languages listed in the Accept-Language in the
            // response.

            // If a 416 (Unsupported URI Scheme) response is received (Section
            // 21.4.14), the Request-URI used a URI scheme not supported by the
            // server.  The client SHOULD retry the request, this time, using a SIP
            // URI.

            // If a 420 (Bad Extension) response is received (Section 21.4.15), the
            // request contained a Require or Proxy-Require header field listing an
            // option-tag for a feature not supported by a proxy or UAS.  The UAC
            // SHOULD retry the request, this time omitting any extensions listed in
            // the Unsupported header field in the response.

            // In all of the above cases, the request is retried by creating a new
            // request with the appropriate modifications.  This new request
            // constitutes a new transaction and SHOULD have the same value of the
            // Call-ID, To, and From of the previous request, but the CSeq should
            // contain a new sequence number that is one higher than the previous.

            // With other 4xx responses, including those yet to be defined, a retry
            // may or may not be possible depending on the method and the use case.
            _logger.Warning("Failed to handle status code: " + response);
            return false;
        }