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


C# ICredentials类代码示例

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


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


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