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


C# OpenIdRelyingParty.CreateRequest方法代码示例

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


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

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

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

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

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

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

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

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

示例8: OpenIdLogin

        public ActionResult OpenIdLogin(string openidIdentifier)
        {
            if (!Identifier.IsValid(openidIdentifier))
            {
                ModelState.AddModelError("loginIdentifier",
                                         "The specified login identifier is invalid");

                return View("LogOn");
            }
            else
            {
                var openid = new OpenIdRelyingParty();
                IAuthenticationRequest request = openid.CreateRequest(
                    Identifier.Parse(openidIdentifier));

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

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

示例9: LogOn

        public ActionResult LogOn(string loginIdentifier)
        {
            if (!Identifier.IsValid(loginIdentifier))
            {
                ModelState.AddModelError("loginIdentifier",
                                         "The specified login identifier is invalid");
                return View();
            }
            else
            {
                var openid = new OpenIdRelyingParty();
                IAuthenticationRequest request = openid.CreateRequest(Identifier.Parse(loginIdentifier));

                /*
                request.AddExtension(new ClaimsRequest
                                         {
                                             Email = DemandLevel.Require,
                                             FullName = DemandLevel.Require§
                                         });
                */

                var fetch = new FetchRequest();
                fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
                fetch.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
                request.AddExtension(fetch);

                return request.RedirectingResponse.AsActionResult();
            }
        }
开发者ID:orjan,项目名称:time-tracker,代码行数:29,代码来源:AuthenticationController.cs

示例10: OpenID

        public ActionResult OpenID(string openid_identifier)
        {
            var openid = new OpenIdRelyingParty();
            IAuthenticationRequest request = openid.CreateRequest(Identifier.Parse(openid_identifier));

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

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

示例12: CreateRequestDumbMode

 public void CreateRequestDumbMode()
 {
     var rp = new OpenIdRelyingParty(null);
     Identifier id = this.GetMockIdentifier(ProtocolVersion.V20);
     var authReq = rp.CreateRequest(id, RPRealmUri, RPUri);
     CheckIdRequest requestMessage = (CheckIdRequest)authReq.RedirectingResponse.OriginalMessage;
     Assert.IsNull(requestMessage.AssociationHandle);
 }
开发者ID:vrushalid,项目名称:dotnetopenid,代码行数:8,代码来源:OpenIdRelyingPartyTests.cs

示例13: Execute

        public void Execute(AuthenticateInputModel inputModel)
        {
            var party = new OpenIdRelyingParty();

            var request = party.CreateRequest(inputModel.GetIdentifier());

            request.RedirectToProvider();
        }
开发者ID:mtscout6,项目名称:FubuMVC.Blog,代码行数:8,代码来源:PostHandler.cs

示例14: Page_Load

        /// <summary>
        /// Action Results for Index, uses DotNetOpenAuth for creating OpenId Request with Intuit
        /// and handling response recieved. 
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event Args.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //OpenId Relying Party
            OpenIdRelyingParty openid = new OpenIdRelyingParty();

            var openIdIdentifier = ConfigurationManager.AppSettings["openid_identifier"];
            var response = openid.GetResponse();
            if (response == null)
            {
                // Stage 2: user submitting Identifier
                Identifier id;
                if (Identifier.TryParse(openIdIdentifier, out id))
                {
                    try
                    {
                        IAuthenticationRequest request = openid.CreateRequest(openIdIdentifier);
                        FetchRequest fetch = new FetchRequest();
                        fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email));
                        fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName));
                        request.AddExtension(fetch);
                        request.RedirectToProvider();
                    }
                    catch (ProtocolException ex)
                    {
                        throw ex;
                    }
                }
            }
            else
            {
                if (response.FriendlyIdentifierForDisplay == null)
                {
                    Response.Redirect("/OpenIdHandler.aspx");
                }

                // Stage 3: OpenID Provider sending assertion response
                Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
                FetchResponse fetch = response.GetExtension<FetchResponse>();
                if (fetch != null)
                {
                    Session["OpenIdResponse"] = "True";
                    Session["FriendlyEmail"] = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
                    Session["FriendlyName"] = fetch.GetAttributeValue(WellKnownAttributes.Name.FullName);
                }

                //Check if user disconnected from the App Center
                if (Request.QueryString["disconnect"] != null && Request.QueryString["disconnect"].ToString(CultureInfo.InvariantCulture) == "true")
                {
                    Session["Flag"] = true;
                    Response.Redirect("CleanupOnDisconnect.aspx");
                }
                else
                {
                    Response.Redirect("Default.aspx");
                }
            }
        }
开发者ID:julio,项目名称:IPP_Sample_Code,代码行数:63,代码来源:OpenIdHandler.aspx.cs

示例15: OpenId

		public ActionResult OpenId(LoginModel model)
		{
			Identifier id;
			if (Identifier.TryParse(model.OpenID_Identifier, out id))
			{
				try
				{
					model.Config = _services.Config.Current;
					var openId = new OpenIdRelyingParty();
					returnToUrl = new Uri(Url.Action("OpenIdCallback", "Authentication", new { ReturnUrl = model.ReturnUrl }, Request.Url.Scheme), UriKind.Absolute);
					// hack for google oauth2
					if (model.OpenID_Identifier.Contains("google"))
					{
						client = new GoogleOAuth2Client(model.Config.ClientId, model.Config.ClientSecret);
						client.RequestAuthentication(this.HttpContext, returnToUrl);
						GoogleOAuth2Client.RewriteRequest();
						return Redirect(returnToUrl.ToString());
					}
					else
					{
						var request = openId.CreateRequest(id, Realm.AutoDetect, returnToUrl);

						// add request for name and email using sreg (OpenID Simple Registration
						// Extension)
						request.AddExtension(new ClaimsRequest
						{
							Email = DemandLevel.Require,
							FullName = DemandLevel.Require,
							Nickname = DemandLevel.Require
						});

						// also add AX request
						var axRequest = new FetchRequest();
						axRequest.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
						axRequest.Attributes.AddRequired(WellKnownAttributes.Name.First);
						axRequest.Attributes.AddRequired(WellKnownAttributes.Name.Last);
						axRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
						request.AddExtension(axRequest);

						var redirectingResponse = request.RedirectingResponse;

						return redirectingResponse.AsActionResult();
					}
				}
				catch (ProtocolException ex)
				{
					model.Message = ex.Message;
					return View("Login", model);
				}
			}
			else
			{
				model.Message = "Invalid identifier";
				return View("Login", model);
			}
		}
开发者ID:skyline9002,项目名称:NBlog,代码行数:56,代码来源:AuthenticationController.cs


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