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


C# OpenId.Identifier类代码示例

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


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

示例1: OpenIdClient

		/// <summary>
		/// Initializes a new instance of the <see cref="OpenIdClient"/> class.
		/// </summary>
		/// <param name="providerName">
		/// Name of the provider. 
		/// </param>
		/// <param name="providerIdentifier">
		/// The provider identifier, which is the usually the login url of the specified provider. 
		/// </param>
		public OpenIdClient(string providerName, Identifier providerIdentifier) {
			Requires.NotNullOrEmpty(providerName, "providerName");
			Requires.NotNull(providerIdentifier, "providerIdentifier");

			this.providerName = providerName;
			this.providerIdentifier = providerIdentifier;
		}
开发者ID:jasedorell,项目名称:DotNetOpenAuth,代码行数:16,代码来源:OpenIDClient.cs

示例2: CreateRequests

		public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm, Uri returnTo, Uri privacyPolicy) {
			if (userSuppliedIdentifier == null) {
				throw new ArgumentNullException("userSuppliedIdentifier");
			}
			if (realm == null) {
				throw new ArgumentNullException("realm");
			}
			if (returnTo == null) {
				throw new ArgumentNullException("returnTo");
			}

			var requests = relyingParty.CreateRequests(userSuppliedIdentifier, realm, returnTo);

			foreach (IAuthenticationRequest request in requests) {
				// Ask for the user's email, not because we necessarily need it to do our work,
				// but so we can display something meaningful to the user as their "username"
				// when they log in with a PPID from Google, for example.
				request.AddExtension(new ClaimsRequest {
					Email = DemandLevel.Require,
					FullName = DemandLevel.Request,
					PolicyUrl = privacyPolicy,
				});

				yield return request;
			}
		}
开发者ID:sztupy,项目名称:dotnetopenid,代码行数:26,代码来源:OpenIdRelyingPartyService.cs

示例3: OpenIdMembershipUser

 public OpenIdMembershipUser(
   string providerName, 
   Identifier openId,
   string name,
   object providerUserKey,
   string email,
   string passwordQuestion,
   string comment,
   bool isApproved,
   bool isLockedOut,
   DateTime creationDate,
   DateTime lastLoginDate,
   DateTime lastActivityDate,
   DateTime lastPasswordChangedDate,
   DateTime lastLockoutDate)
     : base(providerName,
   name,
   providerUserKey,
   email,
   passwordQuestion,
   comment,
   isApproved,
   isLockedOut,
   creationDate,
   lastLoginDate,
   lastActivityDate,
   lastPasswordChangedDate,
   lastLockoutDate)
 {
     OpenId = openId;
 }
开发者ID:AArnott,项目名称:OpenIDForSharepoint,代码行数:31,代码来源:OpenIdMembershipUser.cs

示例4: CreateDatabase

        public static void CreateDatabase(Identifier claimedId, string friendlyId, string databaseName)
        {
            const string SqlFormat = @"
            {0}
            GO
            EXEC [dbo].[AddUser] 'admin', 'admin', '{1}', '{2}'
            GO
            ";
            var removeSnippets = new string[] { @"
            IF IS_SRVROLEMEMBER(N'sysadmin') = 1
            BEGIN
            IF EXISTS (SELECT 1
                   FROM   [master].[dbo].[sysdatabases]
                   WHERE  [name] = N'$(DatabaseName)')
            BEGIN
                EXECUTE sp_executesql N'ALTER DATABASE [$(DatabaseName)]
            SET HONOR_BROKER_PRIORITY OFF
            WITH ROLLBACK IMMEDIATE';
            END
            END
            ELSE
            BEGIN
            PRINT N'The database settings cannot be modified. You must be a SysAdmin to apply these settings.';
            END

            GO" };
            string databasePath = HttpContext.Current.Server.MapPath("~/App_Data/" + databaseName + ".mdf");
            StringBuilder schemaSqlBuilder = new StringBuilder();
            using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(DefaultNamespace + ".CreateDatabase.sql")))
            {
                schemaSqlBuilder.Append(sr.ReadToEnd());
            }
            foreach (string remove in removeSnippets)
            {
                schemaSqlBuilder.Replace(remove, string.Empty);
            }
            schemaSqlBuilder.Replace("$(Path1)", HttpContext.Current.Server.MapPath("~/App_Data/"));
            schemaSqlBuilder.Replace("WEBROOT", databasePath);
            schemaSqlBuilder.Replace("$(DatabaseName)", databaseName);

            string sql = string.Format(CultureInfo.InvariantCulture, SqlFormat, schemaSqlBuilder, claimedId, "Admin");

            var serverConnection = new ServerConnection(".\\sqlexpress");
            try
            {
                serverConnection.ExecuteNonQuery(sql);
            }
            finally
            {
                try
                {
                    var server = new Server(serverConnection);
                    server.DetachDatabase(databaseName, true);
                }
                catch (FailedOperationException)
                {
                }
                serverConnection.Disconnect();
            }
        }
开发者ID:vanzheng,项目名称:CShareCodeSample,代码行数:60,代码来源:Utilities.cs

示例5: LogOn

        private ActionResult LogOn(Identifier identifier)
        {
            //Remove the unnecessary portion of the identifier
            string steamIDString = identifier.ToString().Replace("http://steamcommunity.com/openid/id/", "");
            long steamId64 = long.Parse(steamIDString);

            using (var db = new SprayContext())
            {
                var user = db.Users.FirstOrDefault(x => x.SteamId == steamId64);

                SteamWebAPI.SteamAPISession session = new SteamWebAPI.SteamAPISession();
                session.accessToken = ""; /* CHANGEME - Steam Web API access token */
                var userInfo = session.GetUserInfo(steamId64.ToString());

                if (user == null)
                {
                    //Add the user if they're new
                    user = CreateUser(steamId64, db, userInfo);
                }
                else
                {
                    // Or update the relevant information
                    user.AvatarURI = userInfo.avatarUrl;
                    user.NickName = userInfo.nickname;
                    user.LastUpdated = DateTime.Now;
                }

                int recordsAffected = db.SaveChanges();
                FormsAuthentication.SetAuthCookie(steamId64.ToString(), true);
            }

            return RedirectToAction("Index", "Home");
        }
开发者ID:Red-Vanquish,项目名称:TF2SprayMaker,代码行数:33,代码来源:AccountController.cs

示例6: Discover

		/// <summary>
		/// Performs discovery on the specified identifier.
		/// </summary>
		/// <param name="identifier">The identifier to discover services for.</param>
		/// <returns>A non-null sequence of services discovered for the identifier.</returns>
		public IEnumerable<IdentifierDiscoveryResult> Discover(Identifier identifier) {
			Requires.NotNull(identifier, "identifier");

			IEnumerable<IdentifierDiscoveryResult> results = Enumerable.Empty<IdentifierDiscoveryResult>();
			foreach (var discoverer in this.DiscoveryServices) {
				bool abortDiscoveryChain;
				var discoveryResults = discoverer.Discover(identifier, this.host.WebRequestHandler, out abortDiscoveryChain).CacheGeneratedResults();
				results = results.Concat(discoveryResults);
				if (abortDiscoveryChain) {
					Logger.OpenId.InfoFormat("Further discovery on '{0}' was stopped by the {1} discovery service.", identifier, discoverer.GetType().Name);
					break;
				}
			}

			// If any OP Identifier service elements were found, we must not proceed
			// to use any Claimed Identifier services, per OpenID 2.0 sections 7.3.2.2 and 11.2.
			// For a discussion on this topic, see
			// http://groups.google.com/group/dotnetopenid/browse_thread/thread/4b5a8c6b2210f387/5e25910e4d2252c8
			// Sometimes the IIdentifierDiscoveryService will automatically filter this for us, but
			// just to be sure, we'll do it here as well.
			if (!this.host.SecuritySettings.AllowDualPurposeIdentifiers) {
				results = results.CacheGeneratedResults(); // avoid performing discovery repeatedly
				var opIdentifiers = results.Where(result => result.ClaimedIdentifier == result.Protocol.ClaimedIdentifierForOPIdentifier);
				var claimedIdentifiers = results.Where(result => result.ClaimedIdentifier != result.Protocol.ClaimedIdentifierForOPIdentifier);
				results = opIdentifiers.Any() ? opIdentifiers : claimedIdentifiers;
			}

			return results;
		}
开发者ID:CooPzZ,项目名称:dotnetopenid,代码行数:34,代码来源:IdentifierDiscoveryServices.cs

示例7: CreateOpenIdRequest

 /// <summary>
 /// Creates the open id request.
 /// </summary>
 /// <param name="identifier">The identifier.</param>
 /// <returns></returns>
 private IAuthenticationRequest CreateOpenIdRequest(Identifier identifier)
 {
     var request = openId.CreateRequest(identifier);
     var fetchRequest = CreateFetchRequest();
     request.AddExtension(fetchRequest);
     return request;
 }
开发者ID:edrex333,项目名称:OpenID,代码行数:12,代码来源:UserController.cs

示例8: TryRequireSsl

		internal override bool TryRequireSsl(out Identifier secureIdentifier) {
			// We take special care to make our wrapped identifier secure, but still
			// return a mocked (secure) identifier.
			Identifier secureWrappedIdentifier;
			bool result = this.wrappedIdentifier.TryRequireSsl(out secureWrappedIdentifier);
			secureIdentifier = new MockIdentifier(secureWrappedIdentifier, this.mockHttpRequest, this.endpoints);
			return result;
		}
开发者ID:CooPzZ,项目名称:dotnetopenid,代码行数:8,代码来源:MockIdentifier.cs

示例9: NoDiscoveryIdentifier

        /// <summary>
        /// Initializes a new instance of the <see cref="NoDiscoveryIdentifier"/> class.
        /// </summary>
        /// <param name="wrappedIdentifier">The ordinary Identifier whose discovery is being masked.</param>
        /// <param name="claimSsl">Whether this Identifier should claim to be SSL-secure, although no discovery will never generate service endpoints anyway.</param>
        internal NoDiscoveryIdentifier(Identifier wrappedIdentifier, bool claimSsl)
            : base(wrappedIdentifier.OriginalString, claimSsl)
        {
            Contract.Requires(wrappedIdentifier != null);
            ErrorUtilities.VerifyArgumentNotNull(wrappedIdentifier, "wrappedIdentifier");

            this.wrappedIdentifier = wrappedIdentifier;
        }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:13,代码来源:NoDiscoveryIdentifier.cs

示例10: Discover

		/// <summary>
		/// Performs discovery on the specified identifier.
		/// </summary>
		/// <param name="identifier">The identifier to perform discovery on.</param>
		/// <param name="requestHandler">The means to place outgoing HTTP requests.</param>
		/// <param name="abortDiscoveryChain">if set to <c>true</c>, no further discovery services will be called for this identifier.</param>
		/// <returns>
		/// A sequence of service endpoints yielded by discovery.  Must not be null, but may be empty.
		/// </returns>
		public IEnumerable<IdentifierDiscoveryResult> Discover(Identifier identifier, IDirectWebRequestHandler requestHandler, out bool abortDiscoveryChain) {
			abortDiscoveryChain = false;
			var xriIdentifier = identifier as XriIdentifier;
			if (xriIdentifier == null) {
				return Enumerable.Empty<IdentifierDiscoveryResult>();
			}

			return DownloadXrds(xriIdentifier, requestHandler).XrdElements.CreateServiceEndpoints(xriIdentifier);
		}
开发者ID:rynqs,项目名称:DotNetOpenAuth,代码行数:18,代码来源:XriDiscoveryProxyService.cs

示例11: GenerateOPIdentifierServiceEndpoints

		/// <summary>
		/// Generates OpenID Providers that can authenticate using directed identity.
		/// </summary>
		/// <param name="xrds">The XrdsDocument instance to use in this process.</param>
		/// <param name="opIdentifier">The OP Identifier entered (and resolved) by the user.  Essentially the user-supplied identifier.</param>
		/// <returns>A sequence of the providers that can offer directed identity services.</returns>
		private static IEnumerable<IdentifierDiscoveryResult> GenerateOPIdentifierServiceEndpoints(this IEnumerable<XrdElement> xrds, Identifier opIdentifier) {
			Requires.NotNull(xrds, "xrds");
			Requires.NotNull(opIdentifier, "opIdentifier");
			return from service in xrds.FindOPIdentifierServices()
				   from uri in service.UriElements
				   let protocol = Protocol.FindBestVersion(p => p.OPIdentifierServiceTypeURI, service.TypeElementUris)
				   let providerDescription = new ProviderEndpointDescription(uri.Uri, service.TypeElementUris)
				   select IdentifierDiscoveryResult.CreateForProviderIdentifier(opIdentifier, providerDescription, service.Priority, uri.Priority);
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:15,代码来源:OpenIdXrdsHelperRelyingParty.cs

示例12: Discover

		/// <summary>
		/// Performs discovery on the specified identifier.
		/// </summary>
		/// <param name="identifier">The identifier to perform discovery on.</param>
		/// <param name="requestHandler">The means to place outgoing HTTP requests.</param>
		/// <param name="abortDiscoveryChain">if set to <c>true</c>, no further discovery services will be called for this identifier.</param>
		/// <returns>
		/// A sequence of service endpoints yielded by discovery.  Must not be null, but may be empty.
		/// </returns>
		public IEnumerable<IdentifierDiscoveryResult> Discover(Identifier identifier, IDirectWebRequestHandler requestHandler, out bool abortDiscoveryChain) {
			var mockIdentifier = identifier as MockIdentifier;
			if (mockIdentifier == null) {
				abortDiscoveryChain = false;
				return Enumerable.Empty<IdentifierDiscoveryResult>();
			}

			abortDiscoveryChain = true;
			return mockIdentifier.DiscoveryEndpoints;
		}
开发者ID:437072341,项目名称:dotnetopenid,代码行数:19,代码来源:MockIdentifierDiscoveryService.cs

示例13: SendRequest

        public static ActionResult SendRequest(OpenIdRelyingParty openid, Identifier openIdIdentifier)
        {
            Logger.Info("Sending request to the open id provider");

            var req = openid.CreateRequest(openIdIdentifier);

            var fetch = new FetchRequest();
            fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, true));
            fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.Alias, true));
            req.AddExtension(fetch);
            return req.RedirectingResponse.AsActionResult();
        }
开发者ID:michal-franc,项目名称:learndash,代码行数:12,代码来源:OpenIdService.cs

示例14: DiscoverAsync

		/// <summary>
		/// Performs discovery on the specified identifier.
		/// </summary>
		/// <param name="identifier">The identifier to perform discovery on.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// A sequence of service endpoints yielded by discovery.  Must not be null, but may be empty.
		/// </returns>
		public async Task<IdentifierDiscoveryServiceResult> DiscoverAsync(Identifier identifier, CancellationToken cancellationToken) {
			Requires.NotNull(identifier, "identifier");
			Verify.Operation(this.HostFactories != null, Strings.HostFactoriesRequired);
			cancellationToken.ThrowIfCancellationRequested();

			var uriIdentifier = identifier as UriIdentifier;
			if (uriIdentifier == null) {
				return new IdentifierDiscoveryServiceResult(Enumerable.Empty<IdentifierDiscoveryResult>());
			}

			var endpoints = new List<IdentifierDiscoveryResult>();

			// Attempt YADIS discovery
			DiscoveryResult yadisResult = await Yadis.DiscoverAsync(this.HostFactories, uriIdentifier, identifier.IsDiscoverySecureEndToEnd, cancellationToken);
			cancellationToken.ThrowIfCancellationRequested();
			if (yadisResult != null) {
				if (yadisResult.IsXrds) {
					try {
						XrdsDocument xrds = new XrdsDocument(yadisResult.ResponseText);
						var xrdsEndpoints = xrds.XrdElements.CreateServiceEndpoints(yadisResult.NormalizedUri, uriIdentifier);

						// Filter out insecure endpoints if high security is required.
						if (uriIdentifier.IsDiscoverySecureEndToEnd) {
							xrdsEndpoints = xrdsEndpoints.Where(se => se.ProviderEndpoint.IsTransportSecure());
						}
						endpoints.AddRange(xrdsEndpoints);
					} catch (XmlException ex) {
						Logger.Yadis.Error("Error while parsing the XRDS document.  Falling back to HTML discovery.", ex);
					}
				}

				// Failing YADIS discovery of an XRDS document, we try HTML discovery.
				if (endpoints.Count == 0) {
					await yadisResult.TryRevertToHtmlResponseAsync();
					var htmlEndpoints = new List<IdentifierDiscoveryResult>(DiscoverFromHtml(yadisResult.NormalizedUri, uriIdentifier, yadisResult.ResponseText));
					if (htmlEndpoints.Any()) {
						Logger.Yadis.DebugFormat("Total services discovered in HTML: {0}", htmlEndpoints.Count);
						Logger.Yadis.Debug(htmlEndpoints.ToStringDeferred(true));
						endpoints.AddRange(htmlEndpoints.Where(ep => !uriIdentifier.IsDiscoverySecureEndToEnd || ep.ProviderEndpoint.IsTransportSecure()));
						if (endpoints.Count == 0) {
							Logger.Yadis.Info("No HTML discovered endpoints met the security requirements.");
						}
					} else {
						Logger.Yadis.Debug("HTML discovery failed to find any endpoints.");
					}
				} else {
					Logger.Yadis.Debug("Skipping HTML discovery because XRDS contained service endpoints.");
				}
			}

			return new IdentifierDiscoveryServiceResult(endpoints);
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:60,代码来源:UriDiscoveryService.cs

示例15: DiscoverAsync

		/// <summary>
		/// Performs discovery on the specified identifier.
		/// </summary>
		/// <param name="identifier">The identifier to perform discovery on.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// A sequence of service endpoints yielded by discovery.  Must not be null, but may be empty.
		/// </returns>
		public async Task<IdentifierDiscoveryServiceResult> DiscoverAsync(Identifier identifier, CancellationToken cancellationToken) {
			Requires.NotNull(identifier, "identifier");
			Verify.Operation(this.HostFactories != null, Strings.HostFactoriesRequired);

			var xriIdentifier = identifier as XriIdentifier;
			if (xriIdentifier == null) {
				return new IdentifierDiscoveryServiceResult(Enumerable.Empty<IdentifierDiscoveryResult>());
			}

			var xrds = await DownloadXrdsAsync(xriIdentifier, this.HostFactories, cancellationToken);
			var endpoints = xrds.XrdElements.CreateServiceEndpoints(xriIdentifier);
			return new IdentifierDiscoveryServiceResult(endpoints);
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:21,代码来源:XriDiscoveryProxyService.cs


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