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

C# RelyingParty.OpenIdRelyingParty类代码示例

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

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



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

示例1: LoginToGoogle

        void LoginToGoogle()
        {
            try
            {
                using (OpenIdRelyingParty party = new OpenIdRelyingParty())
                {
                    IAuthenticationRequest request = party.CreateRequest(ConfigurationManager.AppSettings["google-auth-path"]);
                    var fetch = new FetchRequest();
                    fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
                    fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
                    fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
                    request.AddExtension(fetch);

                    //request.AddExtension(new ClaimsRequest
                    //{
                    //    Country = DemandLevel.Request,
                    //    Email = DemandLevel.Request,
                    //    Gender = DemandLevel.Require,
                    //    PostalCode = DemandLevel.Require,
                    //    TimeZone = DemandLevel.Require,
                    //});

                    request.RedirectToProvider();
                }
            }
            catch (ProtocolException ex)
            {
                LabelStatus.Text = ex.Message;
            }
        }
开发者ID:shamil-khan,项目名称:-net-practice,代码行数:30,代码来源:LoginView.cs


示例2: Authenticate

        /// <summary>
        /// Authenicates a user based on the information in the HTTP request.
        /// </summary>
        /// <returns></returns>
        public override void Authenticate(AuthenticationRequest request, AuthenticationResponse response)
        {
            // Only execute the authentication if the user is not known yet

            if (response.Principal == null)
            {
                // Get OpenID provider's response from the http context
                using (var openid = new OpenIdRelyingParty())
                {
                    var openIDResponse = openid.GetResponse();

                    // TODO: figure out which OpenID provider sent the response
                    // and associate with the right authenticator

                    if (response != null)
                    {
                        switch (openIDResponse.Status)
                        {
                            case AuthenticationStatus.Authenticated:
                                response.SetPrincipal(CreatePrincipal(openIDResponse));
                                break;
                            case AuthenticationStatus.Canceled:
                            case AuthenticationStatus.Failed:
                                throw new System.Security.Authentication.AuthenticationException("OpenID authentication failed.", openIDResponse.Exception); // TODO
                            case AuthenticationStatus.ExtensionsOnly:
                            case AuthenticationStatus.SetupRequired:
                                throw new InvalidOperationException();
                            default:
                                throw new NotImplementedException();
                        }
                    }
                }
            }
        }
开发者ID:skyquery,项目名称:graywulf-plugins,代码行数:38,代码来源:OpenIDAuthenticator.cs


示例3: Index

        //
        // GET: /Home/
        //STEAM_0:0:68926576
        //SteamWebAPI.SetGlobalKey("CFDCF16D4EC9D68762FBE9C61B43892D");
        //vmykel
        //wheniwasyourman
        public ActionResult Index()
        {
            OpenIdRelyingParty openid = new OpenIdRelyingParty();
            OpenIdLogin openlog = new OpenIdLogin();
            openid.SecuritySettings.AllowDualPurposeIdentifiers = true;
            IAuthenticationResponse response = openid.GetResponse();

            if (response != null)
            {
                string regex = Request.QueryString["openid.identity"];
                //string youareel= "http://steamcommunity.com/openid/id/76561198131281243";
                string[] str = regex.Split('/');
                string id = str[5];
                Session["user"] = id;
                FormsAuthentication.SetAuthCookie(id, false);
                if(!User.Identity.IsAuthenticated)
                {
                    return RedirectToAction("Index");
                }
                if (User.Identity.IsAuthenticated)
                {
                    return RedirectToAction("Index","Account");
                }
            }

            if (User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Account");
            }

            return View();
        }
开发者ID:kristianguevara,项目名称:BackupRepoAPI,代码行数:38,代码来源:HomeController.cs


示例4: Register

		public static void Register(OpenIdRelyingParty relyingParty) {
			if (relyingParty == null) {
				throw new ArgumentNullException("relyingParty");
			}

			relyingParty.ExtensionFactories.Add(new Acme());
		}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:7,代码来源:Acme.cs


示例5: beginButton_Click

        protected void beginButton_Click(object sender, EventArgs e)
        {
            if (!this.Page.IsValid) {
                return; // don't login if custom validation failed.
            }
            try {
                using (OpenIdRelyingParty rp = new OpenIdRelyingParty()) {
                    var request = rp.CreateRequest(this.openIdBox.Text);
                    request.IsExtensionOnly = true;

                    // This is where you would add any OpenID extensions you wanted
                    // to include in the request.
                    request.AddExtension(new ClaimsRequest {
                        Country = DemandLevel.Request,
                        Gender = DemandLevel.Require,
                        PostalCode = DemandLevel.Require,
                        TimeZone = DemandLevel.Require,
                    });

                    request.RedirectToProvider();
                }
            } catch (ProtocolException ex) {
                // The user probably entered an Identifier that
                // was not a valid OpenID endpoint.
                this.openidValidator.Text = ex.Message;
                this.openidValidator.IsValid = false;
            }
        }
开发者ID:trayburn,项目名称:Presentation-FiveLibs,代码行数:28,代码来源:NoIdentityOpenId.aspx.cs


示例6: SignIn

        public ActionResult SignIn()
        {
            var openid = new OpenIdRelyingParty();
            var response = openid.GetResponse();

            if (response != null)
            {
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:
                        var claimsResponse = response.GetExtension<ClaimsResponse>();
                        FormsAuthentication.SetAuthCookie(claimsResponse.Email, true);
                        return RedirectToAction("Index", "Member");
                    case AuthenticationStatus.Canceled:
                        ModelState.AddModelError("loginIdentifier",
                                                 "Login was cancelled at the provider");
                        break;
                    case AuthenticationStatus.Failed:
                        ModelState.AddModelError("loginIdentifier",
                                                 "Login failed using the provided OpenID identifier");
                        break;
                }
            }

            return View();
        }
开发者ID:mikaelharsjo,项目名称:Yoyyin,代码行数:26,代码来源:AuthController.cs


示例7: ExtensionFactories

		public void ExtensionFactories() {
			var rp = new OpenIdRelyingParty(null);
			var factories = rp.ExtensionFactories;
			Assert.IsNotNull(factories);
			Assert.AreEqual(1, factories.Count);
			Assert.IsInstanceOf<StandardOpenIdExtensionFactory>(factories[0]);
		}
开发者ID:SachiraChin,项目名称:dotnetopenid,代码行数:7,代码来源:OpenIdRelyingPartyTests.cs


示例8: LogOn

        public ActionResult LogOn(string from)
        {
            var openid = new OpenIdRelyingParty();
            IAuthenticationResponse response = openid.GetResponse();

            if (response != null)
            {
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:
                        var sreg = response.GetExtension<ClaimsResponse>();
                        if (sreg != null)
                        {
                            Session.Add("Email", sreg.Email);
                            Session.Add("FullName", sreg.FullName);
                        }

                        FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false);
                        break;
                    case AuthenticationStatus.Canceled:
                        ModelState.AddModelError("loginIdentifier", "Login was cancelled at the provider");
                        break;
                    case AuthenticationStatus.Failed:
                        ModelState.AddModelError("loginIdentifier", "Login failed using the provided OpenID identifier");
                        break;
                }
            }

            return View();
        }
开发者ID:brunoshine,项目名称:ShareIt,代码行数:30,代码来源:AccountController.cs


示例9: CreateRequest

        public IAuthenticationRequest CreateRequest(string realmUrl, string returnUrl)
        {
            if (!Uri.IsWellFormedUriString(realmUrl, UriKind.Relative))
            {
                throw new ArgumentException("Value is not a well formed relative uri string", "realmUrl");
            }

            if (!Uri.IsWellFormedUriString(returnUrl, UriKind.Relative))
            {
                throw new ArgumentException("Value is not a well formed relative uri string", "returnUrl");
            }

            IAuthenticationRequest request;

            var baseUri = new Uri(_request.Url, "/");

            var realmUri = new Uri(baseUri, realmUrl);

            var returnToUri = new Uri(baseUri, returnUrl);

            using (var openIdRelyingParty = new OpenIdRelyingParty())
            {
                request = openIdRelyingParty.CreateRequest(Identifier.Parse("https://www.google.com/accounts/o8/id"), new Realm(realmUri), returnToUri);
            }

            request.AddExtension(new ClaimsRequest
                                     {
                                         Email = DemandLevel.Require
                                     });

            return request;
        }
开发者ID:bhaktapk,项目名称:com-prerit,代码行数:32,代码来源:OpenIdService.cs


示例10: Login

        public ActionResult Login()
        {
            var openid = new OpenIdRelyingParty();
            IAuthenticationResponse response = openid.GetResponse();

            if (response != null)
            {
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:
                        var user = EnsureUserExists(response);
                        FormsAuthentication.RedirectFromLoginPage(
                            user.email, false);
                        break;
                    case AuthenticationStatus.Canceled:
                        ModelState.AddModelError("loginIdentifier",
                            "Login was cancelled at the provider");
                        break;
                    case AuthenticationStatus.Failed:
                        ModelState.AddModelError("loginIdentifier",
                            "Login failed using the provided OpenID identifier");
                        break;
                }
            }

            return View();
        }
开发者ID:Myslik,项目名称:opencat,代码行数:27,代码来源:UserController.cs


示例11: BeginAuth

        public ActionResult BeginAuth()
        {
            var provider = "http://steamcommunity.com/openid";
            var realm = new DotNetOpenAuth.OpenId.Realm(string.Format("{0}{1}{2}", this.Request.Url.Scheme, Uri.SchemeDelimiter, this.Request.Url.Authority));
            var returnTo = new Uri(this.Request.Url, this.Url.Action("EndAuth"));

            using (var rp = new OpenIdRelyingParty())
            {
                var request = rp.CreateRequest(provider, realm, returnTo);

                var claimsRequest = new ClaimsRequest
                {
                    Email = DemandLevel.Require,
                    BirthDate = DemandLevel.Request,
                    Country = DemandLevel.Request,
                    FullName = DemandLevel.Request,
                    Gender = DemandLevel.Request,
                    Language = DemandLevel.Request,
                    Nickname = DemandLevel.Request,
                    PostalCode = DemandLevel.Request,
                    TimeZone = DemandLevel.Request,
                };

                request.AddExtension(claimsRequest);

                return request.RedirectingResponse.AsActionResult();
            }
        }
开发者ID:djeebus,项目名称:SteamMatchUp,代码行数:28,代码来源:HomeController.cs


示例12: Login

        public ActionResult Login(LoginViewModel model)
        {
            if (!Identifier.IsValid(model.IdentityProviderUri))
            {
                throw new Exception("The specified login identifier is invalid");
            }

            var openId = new OpenIdRelyingParty();
            var request = openId.CreateRequest(Identifier.Parse(model.IdentityProviderUri));

            request.AddExtension(new ClaimsRequest
            {
                BirthDate = DemandLevel.NoRequest,
                Email = DemandLevel.Request,
                FullName = DemandLevel.NoRequest,
                TimeZone = DemandLevel.Request,
                Nickname = DemandLevel.Request,
                Country = DemandLevel.NoRequest,
                Gender = DemandLevel.NoRequest,
                Language = DemandLevel.NoRequest,
                PostalCode = DemandLevel.NoRequest
            });

            return request.RedirectingResponse.AsActionResult();
        }
开发者ID:eouw0o83hf,项目名称:Blog,代码行数:25,代码来源:AuthenticationController.cs


示例13: OpenIdRelyingParty

        private static OpenIdRelyingParty openid; // = new OpenIdRelyingParty();

        #endregion Fields

        #region Constructors

        static GoogleOAuth()
        {
            if (System.Web.HttpContext.Current != null)
            {
                openid = new OpenIdRelyingParty();
            }
        }
开发者ID:hankbeasley,项目名称:hoahome,代码行数:13,代码来源:GoogleOAuth.cs


示例14: LogOn

        //
        // GET: /Account/LogOn
        public ActionResult LogOn()
        {
            var openid = new OpenIdRelyingParty();
            IAuthenticationResponse response = openid.GetResponse();

            if (response != null)
            {
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:

                        RedirectFromLoginPage(
                        response.ClaimedIdentifier, "LogOn");

                        break;
                    case AuthenticationStatus.Canceled:
                        ModelState.AddModelError("loginIdentifier",
                            "Login was cancelled at the provider");
                        break;
                    case AuthenticationStatus.Failed:
                        ModelState.AddModelError("loginIdentifier",
                            "Login failed using the provided OpenID identifier");
                        break;
                }
            }

            return View();
        }
开发者ID:bogdanbl,项目名称:DotNetOpenAuthTest,代码行数:30,代码来源:AccountController.cs


示例15: IsValidLogin

        public void IsValidLogin(Uri serviceUri)
        {
            var result = false;

            var openid = new OpenIdRelyingParty();
            if (openid.GetResponse() == null) {
                // Stage 2: user submitting Identifier
                openid.CreateRequest(HttpRequest.Request.Form["openid_identifier"]).RedirectToProvider();
            }
            else {
                // Stage 3: OpenID Provider sending assertion response
                switch (openid.Response.Status) {
                    case AuthenticationStatus.Authenticated:
                        FormsAuthenticationProvider.RedirectFromLoginPage(openid.Response.ClaimedIdentifier, false);
                        break;
                    case AuthenticationStatus.Canceled:
                        ViewData["Message"] = "Canceled at provider";
                        RenderView("Login");
                        break;
                    case AuthenticationStatus.Failed:
                        ViewData["Message"] = openid.Response.Exception.Message;
                        RenderView("Login");
                        break;
                }
            }
        }
开发者ID:zachariahyoung,项目名称:virtualaltnet,代码行数:26,代码来源:OpenIDAuthenticationProvider.cs


示例16: MakeRequest

        private ActionResult MakeRequest(string loginIdentifier)
        {
            if (!Identifier.IsValid(loginIdentifier))
            {
                TempData.FlashError("The loginIdentifier is not valid.");
                return RedirectToAction("SignIn", "Authentication");
            }
            else
            {
                var openid = new OpenIdRelyingParty();

                var replyTo = Url.Action("CompleteRequest", "OpenId", null, Request.Url.Scheme);
                var replyToUri = new Uri(replyTo, UriKind.Absolute);
                var request = openid.CreateRequest(
                    Identifier.Parse(loginIdentifier), Realm.AutoDetect,
                    replyToUri);

                // Require some additional data
                request.AddExtension(new ClaimsRequest
                {
                    BirthDate = DemandLevel.NoRequest,
                    Email = DemandLevel.Require,
                    FullName = DemandLevel.Require
                });

                return request.RedirectingResponse.AsActionResult();
            }
        }
开发者ID:highwaychurch,项目名称:web,代码行数:28,代码来源:OpenIdController.cs


示例17: LogOn

        //
        // GET: /LogOn/
        public ActionResult LogOn()
        {
            var openid = new OpenIdRelyingParty();
            var response = openid.GetResponse();

            if (response != null) {
                switch (response.Status) {
                    case AuthenticationStatus.Authenticated:
                        var fetch = response.GetExtension<FetchResponse>();
                        if (fetch != null) {
                            foreach (var attribute in fetch.Attributes) {
                                ViewData.Add(attribute.TypeUri, string.Join("|", attribute.Values));
                            }
                        }
                        //response.ClaimedIdentifier
                        //return RedirectToAction("LogOn");
                        break;
                    case AuthenticationStatus.Canceled:
                        ModelState.AddModelError("loginIdentifier",
                                                 "Login was cancelled at the provider");
                        break;
                    case AuthenticationStatus.Failed:
                        ModelState.AddModelError("loginIdentifier",
                                                 "Login failed using the provided OpenID identifier");
                        break;
                }
            }

            return View();
        }
开发者ID:nsourabh77,项目名称:teamreview,代码行数:32,代码来源:LogOnController.cs


示例18: Initialize

        protected override void Initialize(RequestContext requestContext)
        {
            if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
            if (OpenId == null) { OpenId = new OpenIdRelyingParty(); }

            base.Initialize(requestContext);
        }
开发者ID:belldandy,项目名称:Html5OpenIdTemplate,代码行数:7,代码来源:AccountController.cs


示例19: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            using (var openid = new OpenIdRelyingParty()) {
                // In order to receive the UIRequest as a response, we must register a custom extension factory.
                openid.ExtensionFactories.Add(new UIRequestAtRelyingPartyFactory());

                var response = openid.GetResponse();
                if (response == null) {
                    // Submit an OpenID request which Google must reply to immediately.
                    // If the user hasn't established a trust relationship with this site yet,
                    // Google will not give us the user identity, but they will tell us whether the user
                    // at least has an active login session with them so we know whether to promote the
                    // "Log in with Google" button.
                    IAuthenticationRequest request = openid.CreateRequest("https://www.google.com/accounts/o8/id");
                    request.AddExtension(new UIRequest { Mode = UIModeDetectSession });
                    request.Mode = AuthenticationRequestMode.Immediate;
                    request.RedirectToProvider();
                } else {
                    if (response.Status == AuthenticationStatus.Authenticated) {
                        this.YouTrustUsLabel.Visible = true;
                    } else if (response.Status == AuthenticationStatus.SetupRequired) {
                        // Google refused to authenticate the user without user interaction.
                        // This is either because Google doesn't know who the user is yet,
                        // or because the user hasn't indicated to Google to trust this site.
                        // Google uniquely offers the RP a tip as to which of the above situations is true.
                        // Figure out which it is.  In a real app, you might use this value to promote a
                        // Google login button on your site if you detect that a Google session exists.
                        var ext = response.GetUntrustedExtension<UIRequest>();
                        this.YouAreLoggedInLabel.Visible = ext != null && ext.Mode == UIModeDetectSession;
                        this.YouAreNotLoggedInLabel.Visible = !this.YouAreLoggedInLabel.Visible;
                    }
                }
            }
        }
开发者ID:VertexShader,项目名称:Regiztry,代码行数:34,代码来源:DetectGoogleSession.aspx.cs


示例20: UserController

 /// <summary>
 /// Constructor.
 /// </summary>
 public UserController(IUserRepository users, IUserAuthService authService, ILogger logger)
     : base(authService, logger)
 {
     _openId = new OpenIdRelyingParty();
     _logger = logger;
     _users = users;
 }
开发者ID:pengwin,项目名称:SampleProject,代码行数:10,代码来源:UserController.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Mocks.TestDirectedMessage类代码示例发布时间:2022-05-24
下一篇:
C# Provider.ProviderSecuritySettings类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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