Exemplo n.º 1
0
        protected virtual void ParseParameters(HttpContext httpContext, OAuthRequestContext requestContext)
        {
            // Try to parse the parameters
            OAuthParameters parameters = OAuthParameters.Parse(httpContext.Request, ServiceProviderContext.Settings.ParameterSources);

            /*
             * Check for missing required parameters:
             *
             * The consumer key, signature method, signature, timestamp and nonce parameters
             * are all required
             */
            parameters.RequireAllOf(
                Constants.ConsumerKeyParameter,
                Constants.TokenParameter,
                Constants.SignatureMethodParameter,
                Constants.SignatureParameter,
                Constants.TimestampParameter,
                Constants.NonceParameter,
                Constants.VerifierParameter);

            /*
             * The version parameter is optional, but it if is present its value must be 1.0
             */
            if (parameters.Version != null)
            {
                parameters.RequireVersion(Constants.Version1_0);
            }

            /*
             * Check that there are no other parameters except for realm, version and
             * the required parameters
             */
            parameters.AllowOnly(
                Constants.ConsumerKeyParameter,
                Constants.TokenParameter,
                Constants.SignatureMethodParameter,
                Constants.SignatureParameter,
                Constants.TimestampParameter,
                Constants.NonceParameter,
                Constants.VerifierParameter,
                Constants.VersionParameter,    // (optional)
                Constants.RealmParameter);     // (optional)

            requestContext.Parameters = parameters;
        }