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

C# IAuthenticationRequest类代码示例

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

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



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

示例1: ProcessAuthenticationAsync

		/// <summary>
		/// Processes an authentication request by a popup window.
		/// </summary>
		/// <param name="userIdentityPageBase">The base URI upon which user identity pages are created.</param>
		/// <param name="request">The incoming authentication request.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// A task that completes with the asynchronous operation.
		/// </returns>
		internal static async Task ProcessAuthenticationAsync(Uri userIdentityPageBase, IAuthenticationRequest request, CancellationToken cancellationToken) {
			Requires.NotNull(userIdentityPageBase, "userIdentityPageBase");
			Requires.NotNull(request, "request");

			var window = new CheckIdWindow(userIdentityPageBase, request);

			IHostFactories hostFactories = new DefaultOpenIdHostFactories();
			bool isRPDiscoverable = await request.IsReturnUrlDiscoverableAsync(hostFactories, cancellationToken) == RelyingPartyDiscoveryResult.Success;
			window.discoverableYesLabel.Visibility = isRPDiscoverable ? Visibility.Visible : Visibility.Collapsed;
			window.discoverableNoLabel.Visibility = isRPDiscoverable ? Visibility.Collapsed : Visibility.Visible;

			bool? result = window.ShowDialog();

			// If the user pressed Esc or cancel, just send a negative assertion.
			if (!result.HasValue || !result.Value) {
				request.IsAuthenticated = false;
				return;
			}

			request.IsAuthenticated = window.tabControl1.SelectedItem == window.positiveTab;
			if (request.IsAuthenticated.Value) {
				request.ClaimedIdentifier = window.claimedIdentifierBox.Text;
				request.LocalIdentifier = window.localIdentifierBox.Text;
			}
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:34,代码来源:CheckIdWindow.xaml.cs


示例2: Authenticate

        public IAuthenticationReply Authenticate(IAuthenticationRequest authenticationRequest)
        {
            var authenticationReply = new AuthenticationReply();

            this._traceManager.Trace("CA: Authentication Request Received", authenticationRequest);

            IEnumerable<User> users =
                this.UnitOfWork.Repository<User, int>()
                    .Query()
                    .Filter(p => p.Email.Equals(authenticationRequest.UserId, StringComparison.OrdinalIgnoreCase))
                    .Get();

            User user = users.FirstOrDefault();
            if (user != null)
            {
                var sessionKey = new byte[SessionKeyLength];
                this.GetRandomBytes(sessionKey);

                ITgsToken tgsToken = this.CreateTgsToken(sessionKey);
                ITgtToken tgtToken = this.CreateTgtToken(user, sessionKey);
                this._traceManager.Trace("CA: TGS Generate tokens", tgsToken, tgtToken);
                authenticationReply.TgsBytes = this.EncryptTgsToken(user, tgsToken);
                authenticationReply.TgtBytes = this.EncryptTgtToken(tgtToken);
                this._traceManager.Trace("CA: TGS Encrypt tokens", Tuple.Create(authenticationReply.TgsBytes, authenticationReply.TgtBytes));
            }
            else
            {
                authenticationReply.Message = "User not found.";
            }

            return authenticationReply;
        }
开发者ID:RamanBut-Husaim,项目名称:ZIRKSiS,代码行数:32,代码来源:AuthenticationService.cs


示例3: OpenIdEventArgs

 /// <summary>
 /// Constructs an object with minimal information of an incomplete or failed
 /// authentication attempt.
 /// </summary>
 internal OpenIdEventArgs(IAuthenticationRequest request)
 {
     if (request == null) throw new ArgumentNullException("request");
     Request = request;
     ClaimedIdentifier = request.ClaimedIdentifier;
     IsDirectedIdentity = request.IsDirectedIdentity;
 }
开发者ID:tt,项目名称:dotnetopenid,代码行数:11,代码来源:OpenIdTextBox.cs


示例4: OnBeforeSendingAuthenticationRequest

 protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request)
 {
     var fetchRequest = new FetchRequest();
     fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
     fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
     request.AddExtension(fetchRequest);
 }
开发者ID:nimisha84,项目名称:SampleAppsForIPP_V2SDK,代码行数:7,代码来源:AuthConfig.cs


示例5: OpenIdEventArgs

		/// <summary>
		/// Initializes a new instance of the <see cref="OpenIdEventArgs"/> class
		/// with minimal information of an incomplete or failed authentication attempt.
		/// </summary>
		/// <param name="request">The outgoing authentication request.</param>
		internal OpenIdEventArgs(IAuthenticationRequest request) {
			Contract.Requires<ArgumentNullException>(request != null);

			this.Request = request;
			this.ClaimedIdentifier = request.ClaimedIdentifier;
			this.IsDirectedIdentity = request.IsDirectedIdentity;
		}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:12,代码来源:OpenIdEventArgs.cs


示例6: Provider

        public ActionResult Provider()
        {
            IRequest request = OpenIdProvider.GetRequest();
            if (request != null) {
                var authRequest = request as IAuthenticationRequest;
                if (authRequest != null) {
                    PendingAuthenticationRequest = authRequest;
                    if (authRequest.IsReturnUrlDiscoverable(OpenIdProvider) == RelyingPartyDiscoveryResult.Success &&
                        User.Identity.IsAuthenticated &&
                        (authRequest.IsDirectedIdentity || this.UserControlsIdentifier(authRequest))) {
                        return this.SendAssertion();
                    } else {
                        return RedirectToAction("LogOn", "Account", new { returnUrl = Url.Action("SendAssertion") });
                    }
                }

                if (request.IsResponseReady) {
                    return OpenIdProvider.PrepareResponse(request).AsActionResult();
                } else {
                    return RedirectToAction("LogOn", "Account");
                }
            } else {
                return View();
            }
        }
开发者ID:trayburn,项目名称:Presentation-FiveLibs,代码行数:25,代码来源:OpenIdController.cs


示例7: OpenIdEventArgs

		/// <summary>
		/// Initializes a new instance of the <see cref="OpenIdEventArgs"/> class
		/// with minimal information of an incomplete or failed authentication attempt.
		/// </summary>
		/// <param name="request">The outgoing authentication request.</param>
		internal OpenIdEventArgs(IAuthenticationRequest request) {
			Requires.NotNull(request, "request");

			this.Request = request;
			this.ClaimedIdentifier = request.ClaimedIdentifier;
			this.IsDirectedIdentity = request.IsDirectedIdentity;
		}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:12,代码来源:OpenIdEventArgs.cs


示例8: prepareRequest

		private void prepareRequest(IAuthenticationRequest request) {
			// Collect the PAPE policies requested by the user.
			List<string> policies = new List<string>();
			foreach (ListItem item in this.papePolicies.Items) {
				if (item.Selected) {
					policies.Add(item.Value);
				}
			}

			// Add the PAPE extension if any policy was requested.
			var pape = new PolicyRequest();
			if (policies.Count > 0) {
				foreach (string policy in policies) {
					pape.PreferredPolicies.Add(policy);
				}
			}

			if (this.maxAuthTimeBox.Text.Length > 0) {
				pape.MaximumAuthenticationAge = TimeSpan.FromSeconds(double.Parse(this.maxAuthTimeBox.Text));
			}

			if (pape.PreferredPolicies.Count > 0 || pape.MaximumAuthenticationAge.HasValue) {
				request.AddExtension(pape);
			}
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:25,代码来源:login.aspx.cs


示例9: ProcessAuthenticationChallenge

        internal static void ProcessAuthenticationChallenge(IAuthenticationRequest idrequest)
        {
            if (idrequest.Immediate) {
                if (idrequest.IsDirectedIdentity) {
                    if (HttpContext.Current.User.Identity.IsAuthenticated) {
                        idrequest.LocalIdentifier = Util.BuildIdentityUrl();
                        idrequest.IsAuthenticated = true;
                    } else {
                        idrequest.IsAuthenticated = false;
                    }
                } else {
                    string userOwningOpenIdUrl = Util.ExtractUserName(idrequest.LocalIdentifier);

                    // NOTE: in a production provider site, you may want to only
                    // respond affirmatively if the user has already authorized this consumer
                    // to know the answer.
                    idrequest.IsAuthenticated = userOwningOpenIdUrl == HttpContext.Current.User.Identity.Name;
                }

                if (idrequest.IsAuthenticated.Value) {
                    // add extension responses here.
                }
            } else {
                HttpContext.Current.Response.Redirect("~/decide.aspx", true);
            }
        }
开发者ID:trayburn,项目名称:Presentation-FiveLibs,代码行数:26,代码来源:Util.cs


示例10: OnBeforeSendingAuthenticationRequest

 protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request)
 {
     FetchRequest extension = new FetchRequest();
     extension.Attributes.AddRequired("http://axschema.org/contact/email");
     extension.Attributes.AddRequired("http://axschema.org/namePerson");
     request.AddExtension(extension);
 }
开发者ID:mikalai-silivonik,项目名称:bnh,代码行数:7,代码来源:Yahoo.cs


示例11: OnBeforeSendingAuthenticationRequest

		/// <summary>
		/// Called just before the authentication request is sent to service provider.
		/// </summary>
		/// <param name="request">
		/// The request. 
		/// </param>
		protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request) {
			// Attribute Exchange extensions
			var fetchRequest = new FetchRequest();
			fetchRequest.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, isRequired: true));
			fetchRequest.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName, isRequired: false));

			request.AddExtension(fetchRequest);
		}
开发者ID:vonbv,项目名称:dotnetopenid,代码行数:14,代码来源:YahooOpenIdClient.cs


示例12: responseOptions

        IAuthenticationResult IApplicationSync.AuthenticateAccount(IAuthenticationRequest request, Action<IRetrievalOptions<IAuthenticationResult>> responseOptions)
        {
            var options = new DefaultRetrievalOptions<IAuthenticationResult>();
            responseOptions(options);

            var dispatcher = new AuthenticationRequestDispatcher();

            return dispatcher.Authenticate(this.GetInternalSyncDataStore(), this, request, options);
        }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:9,代码来源:DefaultApplication.LoginSync.cs


示例13: responseOptions

        Task<IAuthenticationResult> IApplication.AuthenticateAccountAsync(IAuthenticationRequest request, Action<IRetrievalOptions<IAuthenticationResult>> responseOptions, CancellationToken cancellationToken)
        {
            var options = new DefaultRetrievalOptions<IAuthenticationResult>();
            responseOptions(options);

            var dispatcher = new AuthenticationRequestDispatcher();

            return dispatcher.AuthenticateAsync(this.GetInternalAsyncDataStore(), this, request, options, cancellationToken);
        }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:9,代码来源:DefaultApplication.Login.cs


示例14: AuthenticateAsync

        public Task<IAuthenticationResult> AuthenticateAsync(string parentHref, IAuthenticationRequest request, IRetrievalOptions<IAuthenticationResult> options, CancellationToken cancellationToken)
        {
            Validate(parentHref, request);

            var attempt = this.BuildRequest(parentHref, request);
            var href = $"{parentHref}/loginAttempts";

            return this.dataStoreAsync.CreateAsync<IBasicLoginAttempt, IAuthenticationResult>(href, attempt, options, null, cancellationToken);
        }
开发者ID:jwynia,项目名称:stormpath-sdk-dotnet,代码行数:9,代码来源:BasicAuthenticator.cs


示例15: OnBeforeSendingAuthenticationRequest

		/// <summary>
		/// Called just before the authentication request is sent to service provider.
		/// </summary>
		/// <param name="request">
		/// The request. 
		/// </param>
		protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request) {
			// Attribute Exchange extensions
			var fetchRequest = new FetchRequest();
			fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
			fetchRequest.Attributes.AddOptional(WellKnownAttributes.Contact.HomeAddress.Country);
			fetchRequest.Attributes.AddOptional(WellKnownAttributes.Name.First);
			fetchRequest.Attributes.AddOptional(WellKnownAttributes.Name.Last);

			request.AddExtension(fetchRequest);
		}
开发者ID:raelyard,项目名称:dotnetopenid,代码行数:16,代码来源:GoogleOpenIdClient.cs


示例16: AttachAuthorizationRequest

		/// <summary>
		/// Attaches an OAuth authorization request to an outgoing OpenID authentication request.
		/// </summary>
		/// <param name="openIdAuthenticationRequest">The OpenID authentication request.</param>
		/// <param name="scope">The scope of access that is requested of the service provider.</param>
		public void AttachAuthorizationRequest(IAuthenticationRequest openIdAuthenticationRequest, string scope) {
			Requires.NotNull(openIdAuthenticationRequest, "openIdAuthenticationRequest");

			var authorizationRequest = new AuthorizationRequest {
				Consumer = this.ConsumerKey,
				Scope = scope,
			};

			openIdAuthenticationRequest.AddExtension(authorizationRequest);
		}
开发者ID:Adilson,项目名称:dotnetopenid,代码行数:15,代码来源:WebConsumerOpenIdRelyingParty.cs


示例17: Authenticate

        public IAuthenticationResult Authenticate(IInternalDataStore dataStore, IApplication application, IAuthenticationRequest request, IRetrievalOptions<IAuthenticationResult> options)
        {
            Validate(dataStore, application, request);

            if (request is UsernamePasswordRequest)
            {
                return new BasicAuthenticator(dataStore).Authenticate(application.Href, request, options);
            }

            throw new InvalidOperationException($"The AuthenticationRequest {request.GetType().Name} is not supported by this implementation.");
        }
开发者ID:jwynia,项目名称:stormpath-sdk-dotnet,代码行数:11,代码来源:AuthenticationRequestDispatcher.cs


示例18: AttachAuthorizationRequest

        /// <summary>
        /// Attaches an OAuth authorization request to an outgoing OpenID authentication request.
        /// </summary>
        /// <param name="openIdAuthenticationRequest">The OpenID authentication request.</param>
        /// <param name="scope">The scope of access that is requested of the service provider.</param>
        public void AttachAuthorizationRequest(IAuthenticationRequest openIdAuthenticationRequest, string scope)
        {
            Contract.Requires(openIdAuthenticationRequest != null);
            ErrorUtilities.VerifyArgumentNotNull(openIdAuthenticationRequest, "openIdAuthenticationRequest");

            var authorizationRequest = new AuthorizationRequest {
                Consumer = this.ConsumerKey,
                Scope = scope,
            };

            openIdAuthenticationRequest.AddExtension(authorizationRequest);
        }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:17,代码来源:WebConsumer.cs


示例19: Validate

        private static void Validate(string parentHref, IAuthenticationRequest request)
        {
            if (string.IsNullOrEmpty(parentHref))
            {
                throw new ArgumentNullException(nameof(parentHref));
            }

            if (!(request is UsernamePasswordRequest))
            {
                throw new ArgumentException("Only UsernamePasswordRequest instances are supported by this by this authenticator.");
            }
        }
开发者ID:jwynia,项目名称:stormpath-sdk-dotnet,代码行数:12,代码来源:BasicAuthenticator.cs


示例20: ProcessRequest

    public void ProcessRequest(HttpContext context) {
       var sregRequest = ProviderEndpoint.PendingAuthenticationRequest.GetExtension<ClaimsRequest>();
       ClaimsResponse sregResponse = null;
       if (sregRequest != null)
       {
          //sregResponse = profileFields.GetOpenIdProfileFields(sregRequest);
       }
       ProviderEndpoint.PendingAuthenticationRequest.IsAuthenticated = true;
       if (sregResponse != null)
       {
          ProviderEndpoint.PendingAuthenticationRequest.AddResponseExtension(sregResponse);
       }
       //Debug.Assert(ProviderEndpoint.PendingAuthenticationRequest.IsResponseReady);
       ProviderEndpoint.PendingAuthenticationRequest.Response.Send();
       ProviderEndpoint.PendingAuthenticationRequest = null;


      OpenIdProvider provider = new OpenIdProvider();
      if (provider.Request != null) {
        // Some OpenID requests are automatable and can be responded to immediately.
        if (!provider.Request.IsResponseReady) {
          // But authentication requests cannot be responded to until something on
          // this site decides whether to approve or disapprove the authentication.
          var idrequest = (IAuthenticationRequest)provider.Request;
          // We store the authentication request in the user's session so that
          // redirects and user prompts can appear and eventually some page can decide
          // to respond to the OpenID authentication request either affirmatively or
          // negatively.
          PendingAuthenticationRequest = idrequest;
          // We delegate that approval process to our utility method that we share
          // with our other Provider sample page server.aspx.
          Util.ProcessAuthenticationChallenge(idrequest);
          // As part of authentication approval, the user may need to authenticate
          // to this Provider and/or decide whether to allow the requesting RP site
          // to log this user in.  If any UI needs to be presented to the user, 
          // the previous call to ProcessAuthenticationChallenge MAY not return
          // due to a redirect to some ASPX page.
        } else {
          // Some other automatable OpenID request is coming down, so clear
          // any previously session stored authentication request that might be
          // stored for this user.
          PendingAuthenticationRequest = null;
        }
        // Whether this was an automated message or an authentication message,
        // if there is a response ready to send back immediately, do so.
        if (provider.Request.IsResponseReady) {
          provider.Request.Response.Send();
          PendingAuthenticationRequest = null;
        }
      }
    }
开发者ID:trevorpower,项目名称:tadmap,代码行数:51,代码来源:Provider.ashx.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IAuthenticationResponse类代码示例发布时间:2022-05-24
下一篇:
C# IAuthenticationProvider类代码示例发布时间: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