本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}