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

C# ICredentials类代码示例

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

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



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

示例1: BuildFetcher

 public BuildFetcher(String serverAddress, String projectName, ICredentials credentials)
 {
     this.projectName = projectName;
     tfsServer = new TeamFoundationServer(serverAddress, credentials);
     tfsServer.Authenticate();
     buildServer = (IBuildServer) tfsServer.GetService(typeof (IBuildServer));
 }
开发者ID:ArildF,项目名称:Smeedee,代码行数:7,代码来源:BuildFetcher.cs


示例2: SetupEnvironment

        public static void SetupEnvironment(string url,
            ICredentials credentials,
            string path)
        {
            if (string.IsNullOrEmpty(url))
                throw new ArgumentException("url");

            if (string.IsNullOrEmpty(path))
                throw new ArgumentException("path");

            ReportingService2010 service = ReportingService2010TestEnvironment.GetReportingService(url, credentials);

            if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder"))
                service.DeleteItem(path);

            // Create the parent (base) folder where the integration tests will be written to (e.g. /DEST_SSRSMigrate_Tests)
            ReportingService2010TestEnvironment.CreateFolderFromPath(service, path);

            // Create folder structure
            ReportingService2010TestEnvironment.CreateFolders(service, path);

            // Create the the data sources
            ReportingService2010TestEnvironment.CreateDataSources(service, path);

            // Create the the reports
            //ReportingService2010TestEnvironment.CreateReports(service, path);
        }
开发者ID:jpann,项目名称:SSRSMigrate,代码行数:27,代码来源:ReportingService2010TestEnvironment.cs


示例3: RavenCountersClient

		public RavenCountersClient(string serverUrl, string counterStorageName, ICredentials credentials = null, string apiKey = null)
        {
            try
            {
                ServerUrl = serverUrl;
                if (ServerUrl.EndsWith("/"))
                    ServerUrl = ServerUrl.Substring(0, ServerUrl.Length - 1);

				CounterStorageName = counterStorageName;
                Credentials = credentials ?? CredentialCache.DefaultNetworkCredentials;
                ApiKey = apiKey;

				convention = new CounterConvention();
                //replicationInformer = new RavenFileSystemReplicationInformer(convention, JsonRequestFactory);
                //readStripingBase = replicationInformer.GetReadStripingBase();
	            //todo: implement remote counter changes
                //notifications = new RemoteFileSystemChanges(serverUrl, apiKey, credentials, jsonRequestFactory, convention, replicationInformer, () => { });
                               
                InitializeSecurity();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }
开发者ID:JackWangCUMT,项目名称:ravendb,代码行数:26,代码来源:RavenCountersClient.cs


示例4: Authenticate

		public Authorization Authenticate (string challenge, WebRequest webRequest, ICredentials credentials) 
		{
			if (authObject == null)
				return null;

			return authObject.Authenticate (challenge, webRequest, credentials);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:7,代码来源:NtlmClient.cs


示例5: Login

 public void Login(ICredentials credentials)
 {
   _lastCredentials = credentials;
   var mapping = _mappings.First(m => m.Databases.Contains(credentials.Database));
   _current = mapping.Connection;
   _current.Login(credentials);
 }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:7,代码来源:MappedConnection.cs


示例6: GetLegendInfo

 public ArcGISLegendResponse GetLegendInfo(string serviceUrl, ICredentials credentials = null)
 {
     _webRequest = CreateRequest(serviceUrl, credentials);
     var response = _webRequest.GetSyncResponse(_timeOut);
     _legendResponse = GetLegendResponseFromWebresponse(response);
     return _legendResponse;
 }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:7,代码来源:ArcGISLegend.cs


示例7: WebXlob

 public WebXlob(Uri uri, NameValueCollection customHeaders, ICredentials credentials)
 {
     if (uri == null) throw new ArgumentNullException("uri");
     _uri = uri;
     _headers = customHeaders;
     _credentials = credentials;
 }
开发者ID:bittercoder,项目名称:Lob,代码行数:7,代码来源:WebXlob.cs


示例8: GetStream

        public Stream GetStream(Uri uri, ICredentials credentials, int? timeout, int? byteLimit)
        {
            WebRequest request = WebRequest.Create(uri);
#if !PORTABLE
            if (timeout != null)
                request.Timeout = timeout.Value;
#endif

            if (credentials != null)
                request.Credentials = credentials;

            WebResponse response;

#if PORTABLE
            Task<WebResponse> result = Task.Factory.FromAsync(
                request.BeginGetResponse,
                new Func<IAsyncResult, WebResponse>(request.EndGetResponse), null);
            result.ConfigureAwait(false);

            response = result.Result;
#else
            response = request.GetResponse();
#endif

            Stream responseStream = response.GetResponseStream();
            if (timeout != null)
                responseStream.ReadTimeout = timeout.Value;

            if (byteLimit != null)
                return new LimitedStream(responseStream, byteLimit.Value);

            return responseStream;
        }
开发者ID:Nangal,项目名称:Newtonsoft.Json.Schema,代码行数:33,代码来源:WebRequestDownloader.cs


示例9: NewGetRequest

        /// <summary>
        /// Sends a get request to the server
        /// </summary>
        public string NewGetRequest(string method, IDictionary<string, string> keyValues, ICredentials credentials)
        {
            StringBuilder url = new StringBuilder();
            url.Append(_baseUrl);
            url.Append(method);
            url.Append("?");

            bool first = true;
            foreach (string key in keyValues.Keys)
            {
                if (!first)
                    url.Append("&");
                url.Append(key);
                url.Append("=");
                url.Append(keyValues[key]);
                first = false;
            }

            HttpWebRequest request = WebRequest.Create(url.ToString()) as HttpWebRequest;

            if (credentials != null)
                request.Credentials = credentials;

            // Get response
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                // Get the response stream
                StreamReader reader = new StreamReader(response.GetResponseStream());

                // Console application output
                return reader.ReadToEnd();
            }
        }
开发者ID:RodH257,项目名称:RestHelpers,代码行数:36,代码来源:RestfulCommunicator.cs


示例10: ToRequest

		public static HttpWebRequest ToRequest(this string url, IDictionary<string, string> operationsHeaders, ICredentials credentials, string verb)
		{
			var request = (HttpWebRequest)WebRequestCreator.ClientHttp.Create( url.ToUri() );
			request.WithOperationHeaders(operationsHeaders);
			request.Method = verb;
			return request;
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:7,代码来源:RavenUrlExtensions.cs


示例11: PreAuthIfNeeded

 internal void PreAuthIfNeeded(HttpWebRequest httpWebRequest, ICredentials authInfo) {
     //
     // attempt to do preauth, if needed
     //
     GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() TriedPreAuth:" + TriedPreAuth.ToString() + " authInfo:" + ValidationHelper.HashString(authInfo));
     if (!TriedPreAuth) {
         TriedPreAuth = true;
         if (authInfo!=null) {
             PrepareState(httpWebRequest);
             Authorization preauth = null;
             try {
                 preauth = AuthenticationManager.PreAuthenticate(httpWebRequest, authInfo);
                 GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() preauth:" + ValidationHelper.HashString(preauth));
                 if (preauth!=null && preauth.Message!=null) {
                     GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() setting TriedPreAuth to Complete:" + preauth.Complete.ToString());
                     UniqueGroupId = preauth.ConnectionGroupId;
                     httpWebRequest.Headers.Set(AuthorizationHeader, preauth.Message);
                 }
             }
             catch (Exception exception) {
                 GlobalLog.Print("AuthenticationState#" + ValidationHelper.HashString(this) + "::PreAuthIfNeeded() PreAuthenticate() returned exception:" + exception.Message);
             }
         }
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:25,代码来源:httpwebrequest.cs


示例12: Launch

        // ===========================================================================================================
        /// <summary>
        /// Launches the current sequence by executing all it's templates 
        /// </summary>
        /// <param name="credentials">The credentials required for creating the client context</param>
        /// <param name="templateProvider">The <b>XMLTemplatePRovider</b> that is mapped to the client's working directory</param>
        // ===========================================================================================================
        public void Launch(ICredentials credentials, XMLTemplateProvider templateProvider)
        {
            if(!this.Ignore)
            {
                logger.Info("Launching sequence '{0}' ({1})", this.Name, this.Description);

                using (ClientContext ctx = new ClientContext(this.WebUrl))
                {
                    // --------------------------------------------------
                    // Sets the context with the provided credentials
                    // --------------------------------------------------
                    ctx.Credentials = credentials;
                    ctx.RequestTimeout = Timeout.Infinite;

                    // --------------------------------------------------
                    // Loads the full web for futur references (providers)
                    // --------------------------------------------------
                    Web web = ctx.Web;
                    ctx.Load(web);
                    ctx.ExecuteQueryRetry();

                    // --------------------------------------------------
                    // Launches the templates
                    // --------------------------------------------------
                    foreach (Template template in this.Templates)
                    {
                        template.Apply(web, templateProvider);
                    }
                }
            }
            else
            {
                logger.Info("Ignoring sequence '{0}' ({1})", this.Name, this.Description);
            }
        }
开发者ID:coupalm,项目名称:PnP,代码行数:42,代码来源:Sequence.cs


示例13: InternalAuthenticate

		static Authorization InternalAuthenticate (WebRequest webRequest, ICredentials credentials)
		{
			HttpWebRequest request = webRequest as HttpWebRequest;
			if (request == null || credentials == null)
				return null;

			NetworkCredential cred = credentials.GetCredential (request.AuthUri, "basic");
			if (cred == null)
				return null;

			string userName = cred.UserName;
			if (userName == null || userName == "")
				return null;

			string password = cred.Password;
			string domain = cred.Domain;
			byte [] bytes;

			// If domain is set, MS sends "domain\user:password". 
			if (domain == null || domain == "" || domain.Trim () == "")
				bytes = GetBytes (userName + ":" + password);
			else
				bytes = GetBytes (domain + "\\" + userName + ":" + password);

			string auth = "Basic " + Convert.ToBase64String (bytes);
			return new Authorization (auth);
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:27,代码来源:BasicClient.cs


示例14: CreateClientHandler

        public static HttpClientHandler CreateClientHandler(string serviceUrl, ICredentials credentials, bool useCookies = false)
        {
            if (serviceUrl == null)
            {
                throw new ArgumentNullException("serviceUrl");
            }

            // Set up our own HttpClientHandler and configure it
            HttpClientHandler clientHandler = new HttpClientHandler();

            if (credentials != null)
            {
                // Set up credentials cache which will handle basic authentication
                CredentialCache credentialCache = new CredentialCache();

                // Get base address without terminating slash
                string credentialAddress = new Uri(serviceUrl).GetLeftPart(UriPartial.Authority).TrimEnd(uriPathSeparator);

                // Add credentials to cache and associate with handler
                NetworkCredential networkCredentials = credentials.GetCredential(new Uri(credentialAddress), "Basic");
                credentialCache.Add(new Uri(credentialAddress), "Basic", networkCredentials);
                clientHandler.Credentials = credentialCache;
                clientHandler.PreAuthenticate = true;
            }

            // HttpClient's default UseCookies is true (meaning always roundtripping cookie back)
            // However, our api will default to false to cover multiple instance scenarios
            clientHandler.UseCookies = useCookies;

            // Our handler is ready
            return clientHandler;
        }
开发者ID:40a,项目名称:kudu,代码行数:32,代码来源:HttpClientHelper.cs


示例15: AsyncServerClient

		/// <summary>
		/// Initializes a new instance of the <see cref="AsyncServerClient"/> class.
		/// </summary>
		/// <param name="url">The URL.</param>
		/// <param name="convention">The convention.</param>
		/// <param name="credentials">The credentials.</param>
		public AsyncServerClient(string url, DocumentConvention convention, ICredentials credentials, HttpJsonRequestFactory jsonRequestFactory)
		{
			this.url = url;
			this.jsonRequestFactory = jsonRequestFactory;
			this.convention = convention;
			this.credentials = credentials;
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:13,代码来源:AsyncServerClient.cs


示例16: GetSearchResult

		public static IEnumerable<XElement> GetSearchResult(string SearchQuery, int PageSize, int PageCount, string SearchServiceUrl, string Scope, ICredentials Credentials)
		{
			var query = @"SELECT WorkId,Rank,Title,Author,Size,Path,Write,HitHighlightedSummary FROM Scope() WHERE freetext('" + SearchQuery.Replace('\'', ' ') + @"')";
			if (!string.IsNullOrEmpty(Scope))
			{
				query = query + string.Format(@"AND ""Scope""='{0}'", Scope);
			}

			XNamespace ns = "urn:Microsoft.Search.Query";
			XElement queryPacket = new XElement(ns + "QueryPacket",
				new XElement(ns + "Query",
					new XElement(ns + "Context",
						new XElement(ns + "QueryText",
							new XAttribute("language", CultureInfo.CurrentCulture.ToString()),
							new XAttribute("type", "MSSQLFT"),
								query
							)
						), new XElement(ns + "TrimDuplicates", false),
						new XElement(ns + "Range",
							new XElement(ns + "StartAt", (PageCount - 1) * PageSize + 1),
							new XElement(ns + "Count", PageSize)
						)
					)
				);

			QueryService queryService = new QueryService();
			queryService.Url = SearchServiceUrl;
			queryService.Credentials = Credentials;
			string queryResultsString = queryService.Query(queryPacket.ToString());

			return new List<XElement>() {
				XElement.Parse(CleanInvalidXmlChars(queryResultsString))
			};
		}
开发者ID:JustAndrei,项目名称:C1-Packages,代码行数:34,代码来源:Functions.cs


示例17: GetLatestChangesetId

        /// <summary>
        /// Retrieves the latest changeset ID associated with a path
        /// </summary>
        /// <param name="localPath">A path on the local filesystem</param>
        /// <param name="credentials">Credentials used to authenticate against the serer</param>
        /// <returns></returns>
        public int GetLatestChangesetId(string localPath, ICredentials credentials)
        {
            int latestChangesetId = 0;
            string server;

            Workstation workstation = new Workstation(versionControlClientAssembly);
            WorkspaceInfo workspaceInfo = workstation.GetLocalWorkspaceInfo(localPath);
            server = workspaceInfo.ServerUri.ToString();
            VersionControlServer sourceControl = new VersionControlServer(clientAssembly, versionControlClientAssembly, server, credentials);

            Workspace workspace = sourceControl.GetWorkspace(localPath);
            WorkspaceVersionSpec workspaceVersionSpec = new WorkspaceVersionSpec(versionControlClientAssembly, workspace);

            VersionSpec versionSpec = new VersionSpec(versionControlClientAssembly);
            RecursionType recursionType = new RecursionType(versionControlClientAssembly);

            IEnumerable history = sourceControl.QueryHistory(localPath, versionSpec.Latest, recursionType.Full, workspaceVersionSpec);

            IEnumerator historyEnumerator = history.GetEnumerator();
            Changeset latestChangeset = new Changeset(versionControlClientAssembly);
            if (historyEnumerator.MoveNext())
            {
                latestChangeset = new Changeset(versionControlClientAssembly, historyEnumerator.Current);
            }

            if (latestChangeset.Instance != null)
            {
                latestChangesetId = latestChangeset.ChangesetId;
            }
            return latestChangesetId;
        }
开发者ID:464884492,项目名称:msbuildtasks,代码行数:37,代码来源:TeamFoundationServer.cs


示例18: GetTfsConfigurationServer

        public static TfsConnection GetTfsConfigurationServer(string uri, ICredentials credentials)
        {
            // constructor
            var tfsMock = _getTfsMock(uri, credentials);

            return tfsMock.Object;
        }
开发者ID:uiatester,项目名称:STUPS,代码行数:7,代码来源:FakeTfsFactory.cs


示例19: Download

        /// <summary>
        /// Make a web request to the given URL using the given credentials, and download the response into a file.
        /// </summary>
        /// <param name="uri">download url</param>
        /// <param name="cred">credentials to access url</param>
        /// <param name="path">file path</param>
        public static void Download(Uri uri, ICredentials cred, string path)
        {
            var request = (HttpWebRequest) WebRequest.Create(uri);
            request.Timeout = 60*1000;
            request.Method = "GET";
            request.KeepAlive = true;
            request.Credentials = cred;

            HttpWebResponse response = null;
            try
            {
                response = (HttpWebResponse) request.GetResponse();
                using (Stream rcvd = response.GetResponseStream())
                {
                    using (FileStream store = File.Create(path))
                    {
                        int n = 64*1024;
                        var buf = new byte[n];
                        while ((n = rcvd.Read(buf, 0, n)) > 0)
                        {
                            store.Write(buf, 0, n);
                        }
                    }
                }
            }
            finally
            {
                if (response != null) response.Close();
            }
        }
开发者ID:ashish-antil,项目名称:Products,代码行数:36,代码来源:TransportUtils.cs


示例20: SaslMechanismLogin

		/// <summary>
		/// Initializes a new instance of the <see cref="MailKit.Security.SaslMechanismLogin"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new LOGIN SASL context.
		/// </remarks>
		/// <param name="uri">The URI of the service.</param>
		/// <param name="encoding">The encoding to use for the user's credentials.</param>
		/// <param name="credentials">The user's credentials.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <para><paramref name="uri"/> is <c>null</c>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="encoding"/> is <c>null</c>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="credentials"/> is <c>null</c>.</para>
		/// </exception>
		public SaslMechanismLogin (Uri uri, Encoding encoding, ICredentials credentials) : base (uri, credentials)
		{
			if (encoding == null)
				throw new ArgumentNullException (nameof (encoding));

			this.encoding = encoding;
		}
开发者ID:jstedfast,项目名称:MailKit,代码行数:23,代码来源:SaslMechanismLogin.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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