当前位置: 首页>>代码示例>>C#>>正文


C# RelyingParty.OpenIdRelyingParty类代码示例

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


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


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