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


C# OpenIdRelyingParty.GetResponse方法代码示例

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


在下文中一共展示了OpenIdRelyingParty.GetResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: Authenticate

        /// <summary>
        /// Authenicates a user based on the information in the HTTP request.
        /// </summary>
        /// <returns></returns>
        public override GraywulfPrincipal Authenticate()
        {
            // Get OpenID provider's response from the http context
            using (var openid = new OpenIdRelyingParty())
            {
                var response = openid.GetResponse();

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

                if (response != null)
                {
                    switch (response.Status)
                    {
                        case AuthenticationStatus.Authenticated:
                            return CreatePrincipal(response);
                        case AuthenticationStatus.Canceled:
                        case AuthenticationStatus.Failed:
                            throw new System.Security.Authentication.AuthenticationException("OpenID authentication failed.", response.Exception);
                        case AuthenticationStatus.ExtensionsOnly:
                        case AuthenticationStatus.SetupRequired:
                            throw new InvalidOperationException();
                        default:
                            throw new NotImplementedException();
                    }
                }

                return null;
            }
        }
开发者ID:skyquery,项目名称:graywulf,代码行数:34,代码来源:OpenIDAuthenticator.cs

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: Authenticate

		public ActionResult Authenticate(string returnUrl) {
			var rp = new OpenIdRelyingParty();
			var response = rp.GetResponse();
			if (response != null) {
				switch (response.Status) {
					case AuthenticationStatus.Authenticated:
						// Make sure we have a user account for this guy.
						string identifier = response.ClaimedIdentifier; // convert to string so LinqToSQL expression parsing works.
						if (MvcApplication.DataContext.Users.FirstOrDefault(u => u.OpenIDClaimedIdentifier == identifier) == null) {
							MvcApplication.DataContext.Users.InsertOnSubmit(new User {
								OpenIDFriendlyIdentifier = response.FriendlyIdentifierForDisplay,
								OpenIDClaimedIdentifier = response.ClaimedIdentifier,
							});
						}

						FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false);
						return this.Redirect(returnUrl ?? Url.Action("Index", "Home"));
					default:
						ModelState.AddModelError(string.Empty, "An error occurred during login.");
						break;
				}
			}

			return this.View("LogOn");
		}
开发者ID:balamanikantak-sailfish,项目名称:DotNetOpenAuth.Samples,代码行数:25,代码来源:AccountController.cs

示例9: Login

        public ActionResult Login()
        {
            var openId = new OpenIdRelyingParty();
            var response = openId.GetResponse();
                        
            if (response != null)
            {
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:
                        var user = BlogService.GetOrCreateUser(response);
                        return FinishAuthentication(user);

                    case AuthenticationStatus.Canceled:
                        throw new Exception("Login was cancelled at the provider");

                    case AuthenticationStatus.Failed:
                        throw new Exception("Login failed using the provided OpenID identifier");

                    default:
                        throw new NotImplementedException();
                }
            }

            return View(GetViewModel());
        }
开发者ID:eouw0o83hf,项目名称:Blog,代码行数:26,代码来源:AuthenticationController.cs

示例10: 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

示例11: DoLoad

        void DoLoad()
        {
            OpenIdRelyingParty openid = new OpenIdRelyingParty();
            var response = openid.GetResponse();
            if (response == null) return;
            switch (response.Status)
            {
                case AuthenticationStatus.Authenticated:
                    var fetch = response.GetExtension<FetchResponse>();
                    Session["claim"] = response.ClaimedIdentifier;
                    Session["user"] = GetUserDetail(fetch);

                    // This is where you would look for any OpenID extension responses included
                    // in the authentication assertion.
                    //var claimsResponse = response.GetExtension<ClaimsResponse>();
                    //Database.ProfileFields = claimsResponse;
                    // Store off the "friendly" username to display -- NOT for username lookup
                    //Database.FriendlyLoginName = response.FriendlyIdentifierForDisplay;

                    // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
                    // with the OpenID Claimed Identifier as their username.
                    FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false);
                    break;
                case AuthenticationStatus.Canceled:
                    break;
                case AuthenticationStatus.Failed:
                    break;

            }
            LabelStatus.Text = string.Format("Status : {0}", response.Status);
        }
开发者ID:shamil-khan,项目名称:-net-practice,代码行数:31,代码来源:LoginView.cs

示例12: LogOn

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

            var page = HttpContext.Items["page"] = "/";
            if (response != null)
            {
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:
                        FormsAuthentication.SetAuthCookie(response.GetExtension<ClaimsResponse>().Email, false);
                        return Redirect("~" + response.GetCallbackArgument("redirectPage"));
                        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:conso,项目名称:OpenIdSpike,代码行数:27,代码来源:AccountController.cs

示例13: LogOn

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

            if (response != null)
            {
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:
                        FormsAuthentication.SetAuthCookie(accountRepository.Login(response.ClaimedIdentifier).ToString(), true);
                        return new RedirectResult("/", false);
                    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:kenoyer130,项目名称:Notes,代码行数:25,代码来源:LoginController.cs

示例14: 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

示例15: Index

    public ActionResult Index()
    {
      ViewData["Authenticated"] = "FALSE";

      using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
      {
        var response = openid.GetResponse();

        if (response != null)
        {
          switch (response.Status)
          {
            case AuthenticationStatus.Authenticated:
              ViewData["Authenticated"] = "TRUE";
              break;
            case AuthenticationStatus.Canceled:
              ViewData["Authenticated"] = "Cancelled";
              break;
            case AuthenticationStatus.Failed:
              ViewData["Authenticated"] = "FAILED";
              break;
          }
        }
      }

      return View();
    }
开发者ID:tomasmcguinness,项目名称:shadow.io,代码行数:27,代码来源:HomeController.cs


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