Ejemplo n.º 1
0
        protected internal override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request", SR.net_http_handler_norequest);
            }

            if ((request.RequestUri.Scheme != UriSchemeHttp) && (request.RequestUri.Scheme != UriSchemeHttps))
            {
                throw NotImplemented.ByDesignWithMessage(SR.net_http_client_http_baseaddress_required);
            }

            if (request.RequestUri.Scheme == UriSchemeHttps && !s_supportsSSL)
            {
                throw new PlatformNotSupportedException(SR.net_http_unix_https_support_unavailable_libcurl);
            }

            if (request.Headers.TransferEncodingChunked.GetValueOrDefault() && (request.Content == null))
            {
                throw new InvalidOperationException(SR.net_http_chunked_not_allowed_with_empty_content);
            }

            if (_useCookie && _cookieContainer == null)
            {
                throw new InvalidOperationException(SR.net_http_invalid_cookiecontainer);
            }

            CheckDisposed();
            SetOperationStarted();

            // Do an initial cancellation check to avoid initiating the async operation if
            // cancellation has already been requested.  After this, we'll rely on CancellationToken.Register
            // to notify us of cancellation requests and shut down the operation if possible.
            if (cancellationToken.IsCancellationRequested)
            {
                return(Task.FromCanceled <HttpResponseMessage>(cancellationToken));
            }

            // Create the easy request.  This associates the easy request with this handler and configures
            // it based on the settings configured for the handler.
            var easy = new EasyRequest(this, request, cancellationToken);

            // Submit the easy request to the multi agent.
            if (request.Content != null)
            {
                // If there is request content to be sent, preload the stream
                // and submit the request to the multi agent.  This is separated
                // out into a separate async method to avoid associated overheads
                // in the case where there is no request content stream.
                return(QueueOperationWithRequestContentAsync(easy));
            }
            else
            {
                // Otherwise, just submit the request.
                ConfigureAndQueue(easy);
                return(easy.Task);
            }
        }
Ejemplo n.º 2
0
        public ClientCredentials Clone()
        {
            ClientCredentials result = CloneCore();

            if (result == null || result.GetType() != this.GetType())
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(NotImplemented.ByDesignWithMessage(SR.Format(SR.CloneNotImplementedCorrectly, this.GetType(), (result != null) ? result.ToString() : "null")));
            }
            return(result);
        }
Ejemplo n.º 3
0
        protected internal override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request", SR.net_http_handler_norequest);
            }

            if ((request.RequestUri.Scheme != UriSchemeHttp) && (request.RequestUri.Scheme != UriSchemeHttps))
            {
                throw NotImplemented.ByDesignWithMessage(SR.net_http_client_http_baseaddress_required);
            }

            if (request.RequestUri.Scheme == UriSchemeHttps && !_supportsSSL)
            {
                throw new PlatformNotSupportedException(SR.net_http_unix_https_support_unavailable_libcurl);
            }

            if (request.Headers.TransferEncodingChunked.GetValueOrDefault() && (request.Content == null))
            {
                throw new InvalidOperationException(SR.net_http_chunked_not_allowed_with_empty_content);
            }

            // TODO: Check that SendAsync is not being called again for same request object.
            //       Probably fix is needed in WinHttpHandler as well

            CheckDisposed();

            SetOperationStarted();

            if (cancellationToken.IsCancellationRequested)
            {
                return(Task.FromCanceled <HttpResponseMessage>(cancellationToken));
            }

            // Create RequestCompletionSource object and save current values of handler settings.
            RequestCompletionSource state = new RequestCompletionSource
            {
                CancellationToken = cancellationToken,
                RequestMessage    = request,
            };

            BeginRequest(state);

            return(state.Task);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Protected virtual method to override and implement validation logic.
        ///     <para>
        ///         Derived classes should override this method instead of <see cref="IsValid(object)" />, which is deprecated.
        ///     </para>
        /// </summary>
        /// <param name="value">The value to validate.</param>
        /// <param name="validationContext">
        ///     A <see cref="ValidationContext" /> instance that provides
        ///     context about the validation operation, such as the object and member being validated.
        /// </param>
        /// <returns>
        ///     When validation is valid, <see cref="ValidationResult.Success" />.
        ///     <para>
        ///         When validation is invalid, an instance of <see cref="ValidationResult" />.
        ///     </para>
        /// </returns>
        /// <exception cref="InvalidOperationException"> is thrown if the current attribute is malformed.</exception>
        /// <exception cref="NotImplementedException">
        ///     is thrown when <see cref="IsValid(object, ValidationContext)" />
        ///     has not been implemented by a derived class.
        /// </exception>
        protected virtual ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (_hasBaseIsValid)
            {
                // this means neither of the IsValid methods has been overridden, throw.
                throw NotImplemented.ByDesignWithMessage(
                          SR.ValidationAttribute_IsValid_NotImplemented);
            }

            var result = ValidationResult.Success;

            // call overridden method.
            if (!IsValid(value))
            {
                string[] memberNames = validationContext.MemberName != null
                    ? new string[] { validationContext.MemberName }
                    : null;
                result = new ValidationResult(FormatErrorMessage(validationContext.DisplayName), memberNames);
            }

            return(result);
        }
Ejemplo n.º 5
0
 /// <devdoc>
 ///    <para>
 ///       Serializes EndPoint information into a SocketAddress structure.
 ///    </para>
 /// </devdoc>
 public virtual SocketAddress Serialize()
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 6
0
        protected override void Go()
        {
            Goto(0);

            int advance = -1;

            while (true)
            {
                if (advance >= 0)
                {
                    // https://github.com/dotnet/coreclr/pull/14850#issuecomment-342256447
                    // Single common Advance call to reduce method size; and single method inline point
                    Advance(advance);
                    advance = -1;
                }
#if DEBUG
                if (runmatch.Debug)
                {
                    DumpState();
                }
#endif

                CheckTimeout();

                switch (Operator())
                {
                case RegexCode.Stop:
                    return;

                case RegexCode.Nothing:
                    break;

                case RegexCode.Goto:
                    Goto(Operand(0));
                    continue;

                case RegexCode.Testref:
                    if (!IsMatched(Operand(0)))
                    {
                        break;
                    }
                    advance = 1;
                    continue;

                case RegexCode.Lazybranch:
                    TrackPush(Textpos());
                    advance = 1;
                    continue;

                case RegexCode.Lazybranch | RegexCode.Back:
                    TrackPop();
                    Textto(TrackPeek());
                    Goto(Operand(0));
                    continue;

                case RegexCode.Setmark:
                    StackPush(Textpos());
                    TrackPush();
                    advance = 0;
                    continue;

                case RegexCode.Nullmark:
                    StackPush(-1);
                    TrackPush();
                    advance = 0;
                    continue;

                case RegexCode.Setmark | RegexCode.Back:
                case RegexCode.Nullmark | RegexCode.Back:
                    StackPop();
                    break;

                case RegexCode.Getmark:
                    StackPop();
                    TrackPush(StackPeek());
                    Textto(StackPeek());
                    advance = 0;
                    continue;

                case RegexCode.Getmark | RegexCode.Back:
                    TrackPop();
                    StackPush(TrackPeek());
                    break;

                case RegexCode.Capturemark:
                    if (Operand(1) != -1 && !IsMatched(Operand(1)))
                    {
                        break;
                    }
                    StackPop();
                    if (Operand(1) != -1)
                    {
                        TransferCapture(Operand(0), Operand(1), StackPeek(), Textpos());
                    }
                    else
                    {
                        Capture(Operand(0), StackPeek(), Textpos());
                    }
                    TrackPush(StackPeek());

                    advance = 2;

                    continue;

                case RegexCode.Capturemark | RegexCode.Back:
                    TrackPop();
                    StackPush(TrackPeek());
                    Uncapture();
                    if (Operand(0) != -1 && Operand(1) != -1)
                    {
                        Uncapture();
                    }

                    break;

                case RegexCode.Branchmark:
                {
                    int matched;
                    StackPop();

                    matched = Textpos() - StackPeek();

                    if (matched != 0)
                    {                                      // Nonempty match -> loop now
                        TrackPush(StackPeek(), Textpos()); // Save old mark, textpos
                        StackPush(Textpos());              // Make new mark
                        Goto(Operand(0));                  // Loop
                    }
                    else
                    {                                          // Empty match -> straight now
                        TrackPush2(StackPeek());               // Save old mark
                        advance = 1;                           // Straight
                    }
                    continue;
                }

                case RegexCode.Branchmark | RegexCode.Back:
                    TrackPop(2);
                    StackPop();
                    Textto(TrackPeek(1));                           // Recall position
                    TrackPush2(TrackPeek());                        // Save old mark
                    advance = 1;                                    // Straight
                    continue;

                case RegexCode.Branchmark | RegexCode.Back2:
                    TrackPop();
                    StackPush(TrackPeek());                         // Recall old mark
                    break;                                          // Backtrack

                case RegexCode.Lazybranchmark:
                {
                    // We hit this the first time through a lazy loop and after each
                    // successful match of the inner expression.  It simply continues
                    // on and doesn't loop.
                    StackPop();

                    int oldMarkPos = StackPeek();

                    if (Textpos() != oldMarkPos)
                    {                      // Nonempty match -> try to loop again by going to 'back' state
                        if (oldMarkPos != -1)
                        {
                            TrackPush(oldMarkPos, Textpos());           // Save old mark, textpos
                        }
                        else
                        {
                            TrackPush(Textpos(), Textpos());
                        }
                    }
                    else
                    {
                        // The inner expression found an empty match, so we'll go directly to 'back2' if we
                        // backtrack.  In this case, we need to push something on the stack, since back2 pops.
                        // However, in the case of ()+? or similar, this empty match may be legitimate, so push the text
                        // position associated with that empty match.
                        StackPush(oldMarkPos);

                        TrackPush2(StackPeek());                        // Save old mark
                    }
                    advance = 1;
                    continue;
                }

                case RegexCode.Lazybranchmark | RegexCode.Back:
                {
                    // After the first time, Lazybranchmark | RegexCode.Back occurs
                    // with each iteration of the loop, and therefore with every attempted
                    // match of the inner expression.  We'll try to match the inner expression,
                    // then go back to Lazybranchmark if successful.  If the inner expression
                    // fails, we go to Lazybranchmark | RegexCode.Back2
                    int pos;

                    TrackPop(2);
                    pos = TrackPeek(1);
                    TrackPush2(TrackPeek());                        // Save old mark
                    StackPush(pos);                                 // Make new mark
                    Textto(pos);                                    // Recall position
                    Goto(Operand(0));                               // Loop
                    continue;
                }

                case RegexCode.Lazybranchmark | RegexCode.Back2:
                    // The lazy loop has failed.  We'll do a true backtrack and
                    // start over before the lazy loop.
                    StackPop();
                    TrackPop();
                    StackPush(TrackPeek());                          // Recall old mark
                    break;

                case RegexCode.Setcount:
                    StackPush(Textpos(), Operand(0));
                    TrackPush();
                    advance = 1;
                    continue;

                case RegexCode.Nullcount:
                    StackPush(-1, Operand(0));
                    TrackPush();
                    advance = 1;
                    continue;

                case RegexCode.Setcount | RegexCode.Back:
                    StackPop(2);
                    break;

                case RegexCode.Nullcount | RegexCode.Back:
                    StackPop(2);
                    break;

                case RegexCode.Branchcount:
                    // StackPush:
                    //  0: Mark
                    //  1: Count
                {
                    StackPop(2);
                    int mark    = StackPeek();
                    int count   = StackPeek(1);
                    int matched = Textpos() - mark;

                    if (count >= Operand(1) || (matched == 0 && count >= 0))
                    {                                           // Max loops or empty match -> straight now
                        TrackPush2(mark, count);                // Save old mark, count
                        advance = 2;                            // Straight
                    }
                    else
                    {                                          // Nonempty match -> count+loop now
                        TrackPush(mark);                       // remember mark
                        StackPush(Textpos(), count + 1);       // Make new mark, incr count
                        Goto(Operand(0));                      // Loop
                    }
                    continue;
                }

                case RegexCode.Branchcount | RegexCode.Back:
                    // TrackPush:
                    //  0: Previous mark
                    // StackPush:
                    //  0: Mark (= current pos, discarded)
                    //  1: Count
                    TrackPop();
                    StackPop(2);
                    if (StackPeek(1) > 0)
                    {                                              // Positive -> can go straight
                        Textto(StackPeek());                       // Zap to mark
                        TrackPush2(TrackPeek(), StackPeek(1) - 1); // Save old mark, old count
                        advance = 2;                               // Straight
                        continue;
                    }
                    StackPush(TrackPeek(), StackPeek(1) - 1);           // recall old mark, old count
                    break;

                case RegexCode.Branchcount | RegexCode.Back2:
                    // TrackPush:
                    //  0: Previous mark
                    //  1: Previous count
                    TrackPop(2);
                    StackPush(TrackPeek(), TrackPeek(1));               // Recall old mark, old count
                    break;                                              // Backtrack


                case RegexCode.Lazybranchcount:
                    // StackPush:
                    //  0: Mark
                    //  1: Count
                {
                    StackPop(2);
                    int mark  = StackPeek();
                    int count = StackPeek(1);

                    if (count < 0)
                    {                                    // Negative count -> loop now
                        TrackPush2(mark);                // Save old mark
                        StackPush(Textpos(), count + 1); // Make new mark, incr count
                        Goto(Operand(0));                // Loop
                    }
                    else
                    {                                          // Nonneg count -> straight now
                        TrackPush(mark, count, Textpos());     // Save mark, count, position
                        advance = 2;                           // Straight
                    }
                    continue;
                }

                case RegexCode.Lazybranchcount | RegexCode.Back:
                    // TrackPush:
                    //  0: Mark
                    //  1: Count
                    //  2: Textpos
                {
                    TrackPop(3);
                    int mark    = TrackPeek();
                    int textpos = TrackPeek(2);

                    if (TrackPeek(1) < Operand(1) && textpos != mark)
                    {                                         // Under limit and not empty match -> loop
                        Textto(textpos);                      // Recall position
                        StackPush(textpos, TrackPeek(1) + 1); // Make new mark, incr count
                        TrackPush2(mark);                     // Save old mark
                        Goto(Operand(0));                     // Loop
                        continue;
                    }
                    else
                    {                                                  // Max loops or empty match -> backtrack
                        StackPush(TrackPeek(), TrackPeek(1));          // Recall old mark, count
                        break;                                         // backtrack
                    }
                }

                case RegexCode.Lazybranchcount | RegexCode.Back2:
                    // TrackPush:
                    //  0: Previous mark
                    // StackPush:
                    //  0: Mark (== current pos, discarded)
                    //  1: Count
                    TrackPop();
                    StackPop(2);
                    StackPush(TrackPeek(), StackPeek(1) - 1);       // Recall old mark, count
                    break;                                          // Backtrack

                case RegexCode.Setjump:
                    StackPush(Trackpos(), Crawlpos());
                    TrackPush();
                    advance = 0;
                    continue;

                case RegexCode.Setjump | RegexCode.Back:
                    StackPop(2);
                    break;

                case RegexCode.Backjump:
                    // StackPush:
                    //  0: Saved trackpos
                    //  1: Crawlpos
                    StackPop(2);
                    Trackto(StackPeek());

                    while (Crawlpos() != StackPeek(1))
                    {
                        Uncapture();
                    }

                    break;

                case RegexCode.Forejump:
                    // StackPush:
                    //  0: Saved trackpos
                    //  1: Crawlpos
                    StackPop(2);
                    Trackto(StackPeek());
                    TrackPush(StackPeek(1));
                    advance = 0;
                    continue;

                case RegexCode.Forejump | RegexCode.Back:
                    // TrackPush:
                    //  0: Crawlpos
                    TrackPop();

                    while (Crawlpos() != TrackPeek())
                    {
                        Uncapture();
                    }

                    break;

                case RegexCode.Bol:
                    if (Leftchars() > 0 && CharAt(Textpos() - 1) != '\n')
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.Eol:
                    if (Rightchars() > 0 && CharAt(Textpos()) != '\n')
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.Boundary:
                    if (!IsBoundary(Textpos(), runtextbeg, runtextend))
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.Nonboundary:
                    if (IsBoundary(Textpos(), runtextbeg, runtextend))
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.ECMABoundary:
                    if (!IsECMABoundary(Textpos(), runtextbeg, runtextend))
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.NonECMABoundary:
                    if (IsECMABoundary(Textpos(), runtextbeg, runtextend))
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.Beginning:
                    if (Leftchars() > 0)
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.Start:
                    if (Textpos() != Textstart())
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.EndZ:
                    if (Rightchars() > 1 || Rightchars() == 1 && CharAt(Textpos()) != '\n')
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.End:
                    if (Rightchars() > 0)
                    {
                        break;
                    }
                    advance = 0;
                    continue;

                case RegexCode.One:
                    if (Forwardchars() < 1 || Forwardcharnext() != (char)Operand(0))
                    {
                        break;
                    }

                    advance = 1;
                    continue;

                case RegexCode.Notone:
                    if (Forwardchars() < 1 || Forwardcharnext() == (char)Operand(0))
                    {
                        break;
                    }

                    advance = 1;
                    continue;

                case RegexCode.Set:
                    if (Forwardchars() < 1 || !RegexCharClass.CharInClass(Forwardcharnext(), _code.Strings[Operand(0)]))
                    {
                        break;
                    }

                    advance = 1;
                    continue;

                case RegexCode.Multi:
                {
                    if (!Stringmatch(_code.Strings[Operand(0)]))
                    {
                        break;
                    }

                    advance = 1;
                    continue;
                }

                case RegexCode.Ref:
                {
                    int capnum = Operand(0);

                    if (IsMatched(capnum))
                    {
                        if (!Refmatch(MatchIndex(capnum), MatchLength(capnum)))
                        {
                            break;
                        }
                    }
                    else
                    {
                        if ((runregex.roptions & RegexOptions.ECMAScript) == 0)
                        {
                            break;
                        }
                    }

                    advance = 1;
                    continue;
                }

                case RegexCode.Onerep:
                {
                    int c = Operand(1);

                    if (Forwardchars() < c)
                    {
                        break;
                    }

                    char ch = (char)Operand(0);

                    while (c-- > 0)
                    {
                        if (Forwardcharnext() != ch)
                        {
                            goto BreakBackward;
                        }
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Notonerep:
                {
                    int c = Operand(1);

                    if (Forwardchars() < c)
                    {
                        break;
                    }

                    char ch = (char)Operand(0);

                    while (c-- > 0)
                    {
                        if (Forwardcharnext() == ch)
                        {
                            goto BreakBackward;
                        }
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Setrep:
                {
                    int c = Operand(1);

                    if (Forwardchars() < c)
                    {
                        break;
                    }

                    string set = _code.Strings[Operand(0)];

                    while (c-- > 0)
                    {
                        // Check the timeout every 2000th iteration. The additional if check
                        // in every iteration can be neglected as the cost of the CharInClass
                        // check is many times higher.
                        if ((uint)c % LoopTimeoutCheckCount == 0)
                        {
                            CheckTimeout();
                        }

                        if (!RegexCharClass.CharInClass(Forwardcharnext(), set))
                        {
                            goto BreakBackward;
                        }
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Oneloop:
                {
                    int c = Operand(1);

                    if (c > Forwardchars())
                    {
                        c = Forwardchars();
                    }

                    char ch = (char)Operand(0);
                    int  i;

                    for (i = c; i > 0; i--)
                    {
                        if (Forwardcharnext() != ch)
                        {
                            Backwardnext();
                            break;
                        }
                    }

                    if (c > i)
                    {
                        TrackPush(c - i - 1, Textpos() - Bump());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Notoneloop:
                {
                    int c = Operand(1);

                    if (c > Forwardchars())
                    {
                        c = Forwardchars();
                    }

                    char ch = (char)Operand(0);
                    int  i;

                    for (i = c; i > 0; i--)
                    {
                        if (Forwardcharnext() == ch)
                        {
                            Backwardnext();
                            break;
                        }
                    }

                    if (c > i)
                    {
                        TrackPush(c - i - 1, Textpos() - Bump());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Setloop:
                {
                    int c = Operand(1);

                    if (c > Forwardchars())
                    {
                        c = Forwardchars();
                    }

                    string set = _code.Strings[Operand(0)];
                    int    i;

                    for (i = c; i > 0; i--)
                    {
                        // Check the timeout every 2000th iteration. The additional if check
                        // in every iteration can be neglected as the cost of the CharInClass
                        // check is many times higher.
                        if ((uint)i % LoopTimeoutCheckCount == 0)
                        {
                            CheckTimeout();
                        }

                        if (!RegexCharClass.CharInClass(Forwardcharnext(), set))
                        {
                            Backwardnext();
                            break;
                        }
                    }

                    if (c > i)
                    {
                        TrackPush(c - i - 1, Textpos() - Bump());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Oneloop | RegexCode.Back:
                case RegexCode.Notoneloop | RegexCode.Back:
                {
                    TrackPop(2);
                    int i   = TrackPeek();
                    int pos = TrackPeek(1);

                    Textto(pos);

                    if (i > 0)
                    {
                        TrackPush(i - 1, pos - Bump());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Setloop | RegexCode.Back:
                {
                    TrackPop(2);
                    int i   = TrackPeek();
                    int pos = TrackPeek(1);

                    Textto(pos);

                    if (i > 0)
                    {
                        TrackPush(i - 1, pos - Bump());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Onelazy:
                case RegexCode.Notonelazy:
                {
                    int c = Operand(1);

                    if (c > Forwardchars())
                    {
                        c = Forwardchars();
                    }

                    if (c > 0)
                    {
                        TrackPush(c - 1, Textpos());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Setlazy:
                {
                    int c = Operand(1);

                    if (c > Forwardchars())
                    {
                        c = Forwardchars();
                    }

                    if (c > 0)
                    {
                        TrackPush(c - 1, Textpos());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Onelazy | RegexCode.Back:
                {
                    TrackPop(2);
                    int pos = TrackPeek(1);
                    Textto(pos);

                    if (Forwardcharnext() != (char)Operand(0))
                    {
                        break;
                    }

                    int i = TrackPeek();

                    if (i > 0)
                    {
                        TrackPush(i - 1, pos + Bump());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Notonelazy | RegexCode.Back:
                {
                    TrackPop(2);
                    int pos = TrackPeek(1);
                    Textto(pos);

                    if (Forwardcharnext() == (char)Operand(0))
                    {
                        break;
                    }

                    int i = TrackPeek();

                    if (i > 0)
                    {
                        TrackPush(i - 1, pos + Bump());
                    }

                    advance = 2;
                    continue;
                }

                case RegexCode.Setlazy | RegexCode.Back:
                {
                    TrackPop(2);
                    int pos = TrackPeek(1);
                    Textto(pos);

                    if (!RegexCharClass.CharInClass(Forwardcharnext(), _code.Strings[Operand(0)]))
                    {
                        break;
                    }

                    int i = TrackPeek();

                    if (i > 0)
                    {
                        TrackPush(i - 1, pos + Bump());
                    }

                    advance = 2;
                    continue;
                }

                default:
                    throw NotImplemented.ByDesignWithMessage(SR.UnimplementedState);
                }

BreakBackward:
                ;

                // "break Backward" comes here:
                Backtrack();
            }
        }
Ejemplo n.º 7
0
 /// <devdoc>
 /// <para>When overridden in a derived class, returns the <see cref='System.IO.Stream'/> object used
 ///    for reading data from the resource referenced in the <see cref='System.Net.WebRequest'/>
 ///    object.</para>
 /// </devdoc>
 public virtual Stream GetResponseStream()
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 8
0
 internal static Exception MethodNotImplemented([CallerMemberName] string methodName = "")
 {
     return(NotImplemented.ByDesignWithMessage(methodName));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Gets the IP properties for this network interface.
 /// </summary>
 /// <returns>The interface's IP properties.</returns>
 public virtual IPInterfaceProperties GetIPProperties()
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 10
0
 public int MakeSignature(SafeDeleteContext context, Interop.SspiCli.SecurityBufferDescriptor inputOutput, uint sequenceNumber)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 11
0
 public virtual void Abort()
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 12
0
 public virtual Stream EndGetRequestStream(IAsyncResult asyncResult)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 13
0
 public virtual IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 14
0
 public virtual WebResponse EndGetResponse(IAsyncResult asyncResult)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
 protected internal override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request,
                                                                  CancellationToken cancellationToken)
 {
     throw NotImplemented.ByDesignWithMessage("HTTP stack not implemented");
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Gets the physical address of this network interface
 /// </summary>
 /// <returns>The interface's physical address.</returns>
 public virtual PhysicalAddress GetPhysicalAddress()
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 17
0
 public virtual bool Supports(NetworkInterfaceComponent networkInterfaceComponent)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Returns a list of all unicast IP addresses after ensuring they are all stable.
 /// </summary>
 /// <returns>The collection of unicast IP addresses.</returns>
 public virtual Task <UnicastIPAddressInformationCollection> GetUnicastAddressesAsync()
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Provides Internet Protocol (IP) statistical data for this network interface.
 /// Despite the naming, the results are not IPv4 specific.
 /// Do not use this method, use GetIPStatistics instead.
 /// </summary>
 /// <returns>The interface's IP statistics.</returns>
 public virtual IPv4InterfaceStatistics GetIPv4Statistics()
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 20
0
 public virtual IAsyncResult BeginGetUnicastAddresses(AsyncCallback callback, object state)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 21
0
 public int VerifySignature(SafeDeleteContext context, ref Interop.SspiCli.SecBufferDesc inputOutput, uint sequenceNumber)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 22
0
 public virtual UnicastIPAddressInformationCollection EndGetUnicastAddresses(IAsyncResult asyncResult)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 23
0
        private unsafe SecurityStatus EncryptDecryptHelper(OP op, SafeDeleteContext context, SecurityBuffer[] input, uint sequenceNumber)
        {
            Interop.Secur32.SecurityBufferDescriptor sdcInOut = new Interop.Secur32.SecurityBufferDescriptor(input.Length);
            var unmanagedBuffer = new Interop.Secur32.SecurityBufferStruct[input.Length];

            fixed(Interop.Secur32.SecurityBufferStruct *unmanagedBufferPtr = unmanagedBuffer)
            {
                sdcInOut.UnmanagedPointer = unmanagedBufferPtr;
                GCHandle[] pinnedBuffers = new GCHandle[input.Length];
                byte[][]   buffers       = new byte[input.Length][];
                try
                {
                    for (int i = 0; i < input.Length; i++)
                    {
                        SecurityBuffer iBuffer = input[i];
                        unmanagedBuffer[i].count = iBuffer.size;
                        unmanagedBuffer[i].type  = iBuffer.type;
                        if (iBuffer.token == null || iBuffer.token.Length == 0)
                        {
                            unmanagedBuffer[i].token = IntPtr.Zero;
                        }
                        else
                        {
                            pinnedBuffers[i]         = GCHandle.Alloc(iBuffer.token, GCHandleType.Pinned);
                            unmanagedBuffer[i].token = Marshal.UnsafeAddrOfPinnedArrayElement(iBuffer.token, iBuffer.offset);
                            buffers[i] = iBuffer.token;
                        }
                    }

                    // The result is written in the input Buffer passed as type=BufferType.Data.
                    int errorCode;
                    switch (op)
                    {
                    case OP.Encrypt:
                        errorCode = EncryptMessage(context, sdcInOut, sequenceNumber);
                        break;

                    case OP.Decrypt:
                        errorCode = DecryptMessage(context, sdcInOut, sequenceNumber);
                        break;

                    default: throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
                    }

                    // Marshalling back returned sizes / data.
                    for (int i = 0; i < input.Length; i++)
                    {
                        SecurityBuffer iBuffer = input[i];
                        iBuffer.size = unmanagedBuffer[i].count;
                        iBuffer.type = unmanagedBuffer[i].type;

                        if (iBuffer.size == 0)
                        {
                            iBuffer.offset = 0;
                            iBuffer.token  = null;
                        }
                        else
                        {
                            checked
                            {
                                // Find the buffer this is inside of.  Usually they all point inside buffer 0.
                                int j;
                                for (j = 0; j < input.Length; j++)
                                {
                                    if (buffers[j] == null)
                                    {
                                        continue;
                                    }

                                    byte *bufferAddress = (byte *)Marshal.UnsafeAddrOfPinnedArrayElement(buffers[j], 0);
                                    if ((byte *)unmanagedBuffer[i].token >= bufferAddress &&
                                        (byte *)unmanagedBuffer[i].token + iBuffer.size <= bufferAddress + buffers[j].Length)
                                    {
                                        iBuffer.offset = (int)((byte *)unmanagedBuffer[i].token - bufferAddress);
                                        iBuffer.token  = buffers[j];
                                        break;
                                    }
                                }

                                if (j >= input.Length)
                                {
                                    GlobalLog.Assert("SSPIWrapper::EncryptDecryptHelper", "Output buffer out of range.");
                                    iBuffer.size   = 0;
                                    iBuffer.offset = 0;
                                    iBuffer.token  = null;
                                }
                            }
                        }

                        // Backup validate the new sizes.
                        GlobalLog.Assert(iBuffer.offset >= 0 && iBuffer.offset <= (iBuffer.token == null ? 0 : iBuffer.token.Length), "SSPIWrapper::EncryptDecryptHelper|'offset' out of range.  [{0}]", iBuffer.offset);
                        GlobalLog.Assert(iBuffer.size >= 0 && iBuffer.size <= (iBuffer.token == null ? 0 : iBuffer.token.Length - iBuffer.offset), "SSPIWrapper::EncryptDecryptHelper|'size' out of range.  [{0}]", iBuffer.size);
                    }

                    if (errorCode != 0 && Logging.On)
                    {
                        if (errorCode == 0x90321)
                        {
                            Logging.PrintError(Logging.Web, SR.Format(SR.net_log_operation_returned_something, op, "SEC_I_RENEGOTIATE"));
                        }
                        else
                        {
                            Logging.PrintError(Logging.Web, SR.Format(SR.net_log_operation_failed_with_error, op, String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                        }
                    }
                    return(MapToSecurityStatus((Interop.SecurityStatus)errorCode));
                }
                finally
                {
                    for (int i = 0; i < pinnedBuffers.Length; ++i)
                    {
                        if (pinnedBuffers[i].IsAllocated)
                        {
                            pinnedBuffers[i].Free();
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Load custom configuration from Xml
 /// </summary>
 /// <param name="nodelist">Custom configuration elements</param>
 public virtual void LoadCustomConfiguration(XmlNodeList nodelist)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(NotImplemented.ByDesignWithMessage(SR.Format(SR.ID0023, this.GetType().AssemblyQualifiedName)));
 }
Ejemplo n.º 25
0
        private static unsafe int EncryptDecryptHelper(OP op, SSPIInterface secModule, SafeDeleteContext context, SecurityBuffer[] input, uint sequenceNumber)
        {
            Interop.SspiCli.SecBufferDesc sdcInOut = new Interop.SspiCli.SecBufferDesc(input.Length);
            var unmanagedBuffer = new Interop.SspiCli.SecBuffer[input.Length];

            fixed(Interop.SspiCli.SecBuffer *unmanagedBufferPtr = unmanagedBuffer)
            {
                sdcInOut.pBuffers = unmanagedBufferPtr;
                GCHandle[] pinnedBuffers = new GCHandle[input.Length];
                byte[][]   buffers       = new byte[input.Length][];
                try
                {
                    for (int i = 0; i < input.Length; i++)
                    {
                        SecurityBuffer iBuffer = input[i];
                        unmanagedBuffer[i].cbBuffer   = iBuffer.size;
                        unmanagedBuffer[i].BufferType = iBuffer.type;
                        if (iBuffer.token == null || iBuffer.token.Length == 0)
                        {
                            unmanagedBuffer[i].pvBuffer = IntPtr.Zero;
                        }
                        else
                        {
                            pinnedBuffers[i]            = GCHandle.Alloc(iBuffer.token, GCHandleType.Pinned);
                            unmanagedBuffer[i].pvBuffer = Marshal.UnsafeAddrOfPinnedArrayElement(iBuffer.token, iBuffer.offset);
                            buffers[i] = iBuffer.token;
                        }
                    }

                    // The result is written in the input Buffer passed as type=BufferType.Data.
                    int errorCode;
                    switch (op)
                    {
                    case OP.Encrypt:
                        errorCode = secModule.EncryptMessage(context, ref sdcInOut, sequenceNumber);
                        break;

                    case OP.Decrypt:
                        errorCode = secModule.DecryptMessage(context, ref sdcInOut, sequenceNumber);
                        break;

                    case OP.MakeSignature:
                        errorCode = secModule.MakeSignature(context, ref sdcInOut, sequenceNumber);
                        break;

                    case OP.VerifySignature:
                        errorCode = secModule.VerifySignature(context, ref sdcInOut, sequenceNumber);
                        break;

                    default:
                        NetEventSource.Fail(null, $"Unknown OP: {op}");
                        throw NotImplemented.ByDesignWithMessage(Strings.net_MethodNotImplementedException);
                    }

                    // Marshalling back returned sizes / data.
                    for (int i = 0; i < input.Length; i++)
                    {
                        SecurityBuffer iBuffer = input[i];
                        iBuffer.size = unmanagedBuffer[i].cbBuffer;
                        iBuffer.type = unmanagedBuffer[i].BufferType;

                        if (iBuffer.size == 0)
                        {
                            iBuffer.offset = 0;
                            iBuffer.token  = null;
                        }
                        else
                        {
                            checked
                            {
                                // Find the buffer this is inside of.  Usually they all point inside buffer 0.
                                int j;
                                for (j = 0; j < input.Length; j++)
                                {
                                    if (buffers[j] == null)
                                    {
                                        continue;
                                    }

                                    byte *bufferAddress = (byte *)Marshal.UnsafeAddrOfPinnedArrayElement(buffers[j], 0);
                                    if ((byte *)unmanagedBuffer[i].pvBuffer >= bufferAddress &&
                                        (byte *)unmanagedBuffer[i].pvBuffer + iBuffer.size <= bufferAddress + buffers[j].Length)
                                    {
                                        iBuffer.offset = (int)((byte *)unmanagedBuffer[i].pvBuffer - bufferAddress);
                                        iBuffer.token  = buffers[j];
                                        break;
                                    }
                                }

                                if (j >= input.Length)
                                {
                                    NetEventSource.Fail(null, "Output buffer out of range.");
                                    iBuffer.size   = 0;
                                    iBuffer.offset = 0;
                                    iBuffer.token  = null;
                                }
                            }
                        }

                        // Backup validate the new sizes.
                        if (iBuffer.offset < 0 || iBuffer.offset > (iBuffer.token == null ? 0 : iBuffer.token.Length))
                        {
                            NetEventSource.Fail(null, $"'offset' out of range.  [{iBuffer.offset}]");
                        }

                        if (iBuffer.size < 0 || iBuffer.size > (iBuffer.token == null ? 0 : iBuffer.token.Length - iBuffer.offset))
                        {
                            NetEventSource.Fail(null, $"'size' out of range.  [{iBuffer.size}]");
                        }
                    }

                    if (NetEventSource.IsEnabled && errorCode != 0)
                    {
                        if (errorCode == Interop.SspiCli.SEC_I_RENEGOTIATE)
                        {
                            NetEventSource.Error(null, System.StringsHelper.Format(Strings.event_OperationReturnedSomething, op, "SEC_I_RENEGOTIATE"));
                        }
                        else
                        {
                            NetEventSource.Error(null, System.StringsHelper.Format(Strings.net_log_operation_failed_with_error, op, $"0x{0:X}"));
                        }
                    }

                    return(errorCode);
                }
                finally
                {
                    for (int i = 0; i < pinnedBuffers.Length; ++i)
                    {
                        if (pinnedBuffers[i].IsAllocated)
                        {
                            pinnedBuffers[i].Free();
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
 public int QueryContextIssuerList(SafeDeleteContext securityContext, out Object issuerList)
 {
     // TODO (Issue #3362) To be implemented
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 27
0
 public static SafeFreeContextBufferChannelBinding QueryContextChannelBinding(SafeDeleteContext phContext, ChannelBindingKind attribute)
 {
     // TODO (Issue #3954) To be implemented
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 28
0
 public int QueryContextChannelBinding(SafeDeleteContext phContext, ChannelBindingKind attribute,
                                       out SafeFreeContextBufferChannelBinding refHandle)
 {
     // TODO (Issue #3362) To be implemented
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 29
0
 /// <devdoc>
 ///    <para>
 ///       Creates an EndPoint instance from a SocketAddress structure.
 ///    </para>
 /// </devdoc>
 public virtual EndPoint Create(SocketAddress socketAddress)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }
Ejemplo n.º 30
0
 public virtual long GetScopeId(ScopeLevel scopeLevel)
 {
     throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
 }