コード例 #1
0
        private void AddMapping(AuthenticationOptionMapping mapping)
        {
            var hit = from m in Mappings
                      where m.Options.RequestType == mapping.Options.RequestType &&
                      m.Options.Name == mapping.Options.Name &&
                      m.Options.Scheme == mapping.Options.Scheme
                      select m;

            if (hit.FirstOrDefault() != null)
            {
                throw new InvalidOperationException("Duplicate authentication entry");
            }

            Mappings.Add(mapping);

            switch (mapping.Options.RequestType)
            {
            case HttpRequestType.AuthorizationHeader:
                _hasAuthorizationHeader = true;
                break;

            case HttpRequestType.Header:
                _hasHeader = true;
                break;

            case HttpRequestType.QueryString:
                _hasQueryString = true;
                break;

            case HttpRequestType.Cookie:
                _hasCookie = true;
                break;

            case HttpRequestType.ClientCertificate:
                _hasClientCert = true;
                break;

            default:
                throw new InvalidOperationException("Invalid request type");
            }
        }
コード例 #2
0
        private void AddMapping(AuthenticationOptionMapping mapping)
        {
            var hit = from m in Mappings
                      where m.Options.RequestType == mapping.Options.RequestType &&
                            m.Options.Name == mapping.Options.Name &&
                            m.Options.Scheme == mapping.Options.Scheme
                      select m;

            if (hit.FirstOrDefault() != null)
            {
                throw new InvalidOperationException("Duplicate authentication entry");
            }

            Mappings.Add(mapping);

            switch (mapping.Options.RequestType)
            {
                case HttpRequestType.AuthorizationHeader:
                    _hasAuthorizationHeader = true;
                    break;
                case HttpRequestType.Header:
                    _hasHeader = true;
                    break;
                case HttpRequestType.QueryString:
                    _hasQueryString = true;
                    break;
                case HttpRequestType.Cookie:
                    _hasCookie = true;
                    break;
                case HttpRequestType.ClientCertificate:
                    _hasClientCert = true;
                    break;
                default:
                    throw new InvalidOperationException("Invalid request type");
            }
        }