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


C# IAuthenticationRequest类代码示例

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


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


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