• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# OAuth2.TokenRequestValidator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Thinktecture.AuthorizationServer.OAuth2.TokenRequestValidator的典型用法代码示例。如果您正苦于以下问题:C# TokenRequestValidator类的具体用法?C# TokenRequestValidator怎么用?C# TokenRequestValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TokenRequestValidator类属于Thinktecture.AuthorizationServer.OAuth2命名空间,在下文中一共展示了TokenRequestValidator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExpiredRefreshToken

        public void ExpiredRefreshToken()
        {
            TestTokenHandleManager handleManager =
                new TestTokenHandleManager("abc", "codeclient", "https://validredirect", expired: true);

            var validator = new TokenRequestValidator(handleManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.RefreshToken,
                Refresh_Token = "abc"
            };

            try
            {
                var result = validator.Validate(app, request, _client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidGrant, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:pksorensen,项目名称:Thinktecture.AuthorizationServer,代码行数:25,代码来源:TokenRequest_Validation_RefreshToken.cs


示例2: EmptyParameters

        public void EmptyParameters()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");

            var result = validator.Validate(app, new TokenRequest(), _codeClient);
        }
开发者ID:Excelsior-Charles,项目名称:Thinktecture.AuthorizationServer,代码行数:7,代码来源:TokenRequestValidationTests.cs


示例3: NoParameters

        public void NoParameters()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");

            var result = validator.Validate(app, null, null);
        }
开发者ID:Excelsior-Charles,项目名称:Thinktecture.AuthorizationServer,代码行数:7,代码来源:TokenRequestValidationTests.cs


示例4: MissingClientId

        public void MissingClientId()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.Password,
                UserName = "username",
                Password = "password",
                Scope = "read"
            };

            try
            {
                var client = Principal.Create("Test",
                                new Claim("password", "secret"));

                var result = validator.Validate(app, request, client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidClient, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:27,代码来源:TokenRequest_Validation_General.cs


示例5: ValidSingleScope

        public void ValidSingleScope()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.ClientCredentials,
                Scope = "read"
            };

            var result = validator.Validate(app, request, _client);
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:12,代码来源:TokenRequest_Validation_Client.cs


示例6: ValidRequest

        public void ValidRequest()
        {
            var validator = new TokenRequestValidator(_handleManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.RefreshToken,
                Refresh_Token = "abc"
            };

            var result = validator.Validate(app, request, _client);
        }
开发者ID:RomanDidenko,项目名称:Thinktecture.AuthorizationServer,代码行数:12,代码来源:TokenRequest_Validation_RefreshToken.cs


示例7: ValidSingleScope

        public void ValidSingleScope()
        {
            var validator = new TokenRequestValidator(_clientManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = "assertion",
                Assertion = "assertion",
                Scope = "read"
            };

            var result = validator.Validate(app, request, _client);
        }
开发者ID:kahneraja,项目名称:Thinktecture.AuthorizationServer,代码行数:13,代码来源:TokenRequest_Validation_Assertion.cs


示例8: ValidCodeGrant

        public void ValidCodeGrant()
        {
            var validator = new TokenRequestValidator(new TestTokenHandleManager("codeclient", "https://todo"));
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.AuthorizationCode,
                Code = "abc",
                Redirect_Uri = "https://todo"
            };

            var result = validator.Validate(app, request, _codeClient);
        }
开发者ID:Excelsior-Charles,项目名称:Thinktecture.AuthorizationServer,代码行数:13,代码来源:TokenRequestValidationTests.cs


示例9: ValidSingleScope

        public void ValidSingleScope()
        {
            var validator = new TokenRequestValidator(_handleManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.AuthorizationCode,
                Code = "abc",
                Redirect_Uri = "https://validredirect"
            };

            var result = validator.Validate(app, request, _client);
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:13,代码来源:TokenRequest_Validation_Code.cs


示例10: ValidSingleScope

        public void ValidSingleScope()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.Password,
                UserName = "username",
                Password = "password",
                Scope = "read"
            };

            var result = validator.Validate(app, request, _client);
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:14,代码来源:TokenRequest_Validation_Password.cs


示例11: Post

        public HttpResponseMessage Post(string appName, TokenRequest request)
        {
            Tracing.Start("OAuth2 Token Endpoint");

            // make sure application is registered
            var application = _config.FindApplication(appName);
            if (application == null)
            {
                Tracing.Error("Application not found: " + appName);
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not found");
            }

            // validate token request
            ValidatedRequest validatedRequest;
            try
            {
                validatedRequest = new TokenRequestValidator(_handleManager).Validate(application, request, ClaimsPrincipal.Current);
            }
            catch (TokenRequestValidationException ex)
            {
                Tracing.Error("Aborting OAuth2 token request");
                return Request.CreateOAuthErrorResponse(ex.OAuthError);
            }

            // switch over the grant type
            if (validatedRequest.GrantType.Equals(OAuthConstants.GrantTypes.Password))
            {
                return ProcessResourceOwnerCredentialRequest(validatedRequest);
            }
            else if (validatedRequest.GrantType.Equals(OAuthConstants.GrantTypes.AuthorizationCode))
            {
                return ProcessAuthorizationCodeRequest(validatedRequest);
            }
            else if (string.Equals(validatedRequest.GrantType, OAuthConstants.GrantTypes.RefreshToken))
            {
                return ProcessRefreshTokenRequest(validatedRequest);
            }
            else if (string.Equals(validatedRequest.GrantType, OAuthConstants.GrantTypes.ClientCredentials))
            {
                return ProcessClientCredentialsRequest(validatedRequest);
            }

            Tracing.Error("invalid grant type: " + request.Grant_Type);
            return Request.CreateOAuthErrorResponse(OAuthConstants.Errors.UnsupportedGrantType);
        }
开发者ID:nanderto,项目名称:Thinktecture.AuthorizationServer,代码行数:45,代码来源:TokenController.cs


示例12: MissingCode

        public void MissingCode()
        {
            var validator = new TokenRequestValidator(_handleManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.RefreshToken,
            };

            try
            {
                var result = validator.Validate(app, request, _client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidGrant, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:RomanDidenko,项目名称:Thinktecture.AuthorizationServer,代码行数:21,代码来源:TokenRequest_Validation_RefreshToken.cs


示例13: MissingScope

        public void MissingScope()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.ClientCredentials,
            };

            try
            {
                var result = validator.Validate(app, request, _client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidScope, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:21,代码来源:TokenRequest_Validation_Client.cs


示例14: UnknownScope

        public void UnknownScope()
        {
            var validator = new TokenRequestValidator(_clientManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = "assertion",
                Assertion = "assertion",
                Scope = "unknown"
            };

            try
            {
                var result = validator.Validate(app, request, _client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidScope, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:kahneraja,项目名称:Thinktecture.AuthorizationServer,代码行数:23,代码来源:TokenRequest_Validation_Assertion.cs


示例15: MissingScope

        public void MissingScope()
        {
            var validator = new TokenRequestValidator(_clientManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.Password,
                UserName = "JohnSmith",
                Password = "12345678",
            };

            try
            {
                var result = validator.Validate(app, request, _client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidScope, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:kahneraja,项目名称:Thinktecture.AuthorizationServer,代码行数:23,代码来源:TokenRequest_Validation_Password.cs


示例16: NonMatchingRedirectUri

        public void NonMatchingRedirectUri()
        {
            var validator = new TokenRequestValidator(_handleManager);
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.AuthorizationCode,
                Code = "abc",
                Redirect_Uri = "https://invalidredirect"
            };

            try
            {
                var result = validator.Validate(app, request, _client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidRequest, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:23,代码来源:TokenRequest_Validation_Code.cs


示例17: UnknownGrantType

        public void UnknownGrantType()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = "unknown"
            };

            try
            {
                var result = validator.Validate(app, request, null);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.UnsupportedGrantType, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:21,代码来源:TokenRequest_Validation_General.cs


示例18: NoParameters

        public void NoParameters()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");

            try
            {
                var result = validator.Validate(app, null, null);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidRequest, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:Griimm,项目名称:Thinktecture.AuthorizationServer,代码行数:17,代码来源:TokenRequest_Validation_General.cs


示例19: UnauthorizedCodeGrant

        public void UnauthorizedCodeGrant()
        {
            var validator = new TokenRequestValidator(new TestTokenHandleManager(null, null));
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.AuthorizationCode,
                Code = "abc"
            };

            var result = validator.Validate(app, request, _resourceOwnerClient);
        }
开发者ID:Excelsior-Charles,项目名称:Thinktecture.AuthorizationServer,代码行数:12,代码来源:TokenRequestValidationTests.cs


示例20: DisabledClient

        public void DisabledClient()
        {
            var validator = new TokenRequestValidator();
            var app = _testConfig.FindApplication("test");
            var request = new TokenRequest
            {
                Grant_Type = OAuthConstants.GrantTypes.ClientCredentials
            };

            try
            {
                var client = Principal.Create("Test",
                new Claim("client_id", "disabledclient"),
                new Claim("secret", "secret"));

                var result = validator.Validate(app, request, client);
            }
            catch (TokenRequestValidationException ex)
            {
                Assert.AreEqual(OAuthConstants.Errors.InvalidClient, ex.OAuthError);
                return;
            }

            Assert.Fail("No exception thrown.");
        }
开发者ID:murat0058,项目名称:AuthorizationServer,代码行数:25,代码来源:TokenRequest_Validation_General.cs



注:本文中的Thinktecture.AuthorizationServer.OAuth2.TokenRequestValidator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Configuration.IdentityServerOptions类代码示例发布时间:2022-05-26
下一篇:
C# OAuth2.TokenRequest类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap