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


C# IAuthenticator类代码示例

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


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

示例1: CreateHttpRequest

        private HttpRequestMessage CreateHttpRequest(Request request, IAuthenticator authenticator)
        {
            var httpRequest = new HttpRequestMessage(request.Method, new Uri(request.Uri));

            if (request.Method == HttpMethod.Post || request.Method == HttpMethod.Put)
            {
                var contentRequest = request as ContentRequest;

                if (contentRequest != null && !string.IsNullOrEmpty(contentRequest.Content) && contentRequest.Encoding != null && !string.IsNullOrEmpty(contentRequest.MediaType))
                {
                    httpRequest.Content = new StringContent(contentRequest.Content, contentRequest.Encoding, contentRequest.MediaType);
                }
            }

            var headers = MergeHeaders(request.Headers, authenticator != null ? authenticator.GetHeaders(request) : null);

            if (headers != null && headers.Count > 0)
            {
                foreach (var header in headers)
                {
                    httpRequest.Headers.Add(header.Key, header.Value);
                }
            }

            return httpRequest;
        }
开发者ID:milesdream,项目名称:Rester,代码行数:26,代码来源:Client.cs

示例2: DownloadFile

 /// <summary>
 /// Download a file and return a string with its content.
 /// </summary>
 /// <param name="authenticator">
 /// Authenticator responsible for creating authorized web requests.
 /// </param>
 /// <param name="file">Drive File instance.</param>
 /// <returns>File's content if successful, null otherwise.</returns>
 public static System.IO.Stream DownloadFile(
     IAuthenticator authenticator, File file)
 {
     if (!String.IsNullOrEmpty(file.DownloadUrl))
     {
         try
         {
             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
                 new Uri(file.DownloadUrl));
             authenticator.ApplyAuthenticationToRequest(request);
             HttpWebResponse response = (HttpWebResponse)request.GetResponse();
             if (response.StatusCode == HttpStatusCode.OK)
             {
                 return response.GetResponseStream();
             }
             else
             {
                 Console.WriteLine(
                     "An error occurred: " + response.StatusDescription);
                 return null;
             }
         }
         catch (Exception e)
         {
             Console.WriteLine("An error occurred: " + e.Message);
             return null;
         }
     }
     else
     {
         // The file doesn't have any content stored on Drive.
         return null;
     }
 }
开发者ID:festigf,项目名称:g3,代码行数:42,代码来源:frmMain.cs

示例3: AuthenticationModule

 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationModule" /> class.
 /// </summary>
 /// <param name="authenticator">Used for the actual authentication.</param>
 /// <param name="principalFactory">Used to create the principal that should be used.</param>
 /// <exception cref="System.ArgumentNullException">autheonticator</exception>
 public AuthenticationModule(IAuthenticator authenticator, IPrincipalFactory principalFactory)
 {
     if (authenticator == null) throw new ArgumentNullException("authenticator");
     if (principalFactory == null) throw new ArgumentNullException("principalFactory");
     _authenticator = authenticator;
     _principalFactory = principalFactory;
 }
开发者ID:2594636985,项目名称:Griffin.WebServer,代码行数:13,代码来源:AuthenticationModule.cs

示例4: DefaultHttpPostClient

	    /// <summary>
        /// Initializes a new instance of the <see cref="DefaultHttpPostClient"/> class.
        /// </summary>
        /// <param name="hostProvider">Instance of IHostProvider. If not specified, default one will be used.</param>
        /// <param name="auth">Instance of IAuthenticator. If not specified request will not use authentication.</param>
        public DefaultHttpPostClient([CanBeNull] IHostProvider hostProvider, [CanBeNull] IAuthenticator auth)
        {
            _hostProvider = hostProvider ?? new DefaultHostsProvider();
            _authenticator = auth;

            Init();
        }
开发者ID:monnster,项目名称:yandex-money-sdk-net,代码行数:12,代码来源:DefaultHttpPostClient.cs

示例5: RequestRunner

 public RequestRunner(
     ITransmissionSettings transmissionSettings,
     IAuthenticator authenticator)
 {
     this.transmissionSettings = transmissionSettings;
     this.authenticator = authenticator;
 }
开发者ID:ChrisMissal,项目名称:SpeakEasy,代码行数:7,代码来源:RequestRunner.cs

示例6: GetAuthenticationHeaderValue

        internal static AuthenticationHeaderValue GetAuthenticationHeaderValue(IAuthenticator authenticator, Uri uri)
        {
            AuthenticationHeaderValue authHeader = null;

            var userInfo = uri != null ? uri.UserInfo : null;
            if (!String.IsNullOrEmpty(userInfo)) 
            {
                authHeader = uri.GetAuthenticationHeader("Basic");
                if (authHeader == null)
                {
                    Log.W(Tag, "Unable to parse user info, not setting credentials");
                }
            } 
            else 
            {
                if (authenticator != null) 
                {
                    userInfo = authenticator.UserInfo;
                    var scheme = authenticator.Scheme;
                    if (userInfo != null && scheme != null)
                    {
                        authHeader = userInfo.AsAuthenticationHeader(scheme);
                    }
                }
            }

            return authHeader;
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:28,代码来源:AuthUtils.cs

示例7: Init

        private void Init(IAuthenticator auth, string server)
        {
            Server = server;

            RestClient = new RestClient(Server);
            RestClient.Authenticator = auth;
        }
开发者ID:vitxd,项目名称:PMAPI-examples,代码行数:7,代码来源:PMAPIClient.cs

示例8: DefaultHttpPostClient

        /// <summary>
        /// Initializes a new instance of the Yandex.Money.Api.Sdk.Interfaces.IHttpClient interface.
        /// </summary>
        /// <param name="hostProvider">an instance of IHostProvider implementation</param>
        /// <param name="auth">an instance of IAuthenticator implementation</param>
        public DefaultHttpPostClient(IHostProvider hostProvider, IAuthenticator auth)
        {
            _hostProvider = hostProvider;
            _authenticator = auth;

            Init();
        }
开发者ID:svedm,项目名称:yandex-money-sdk-net,代码行数:12,代码来源:DefaultHttpPostClient.cs

示例9: AuthenticatorConfiguration

 /// <summary>
 /// Initializes a new instance of the AuthenticatorConfiguration class.
 /// </summary>
 public AuthenticatorConfiguration(string name, IAuthenticator authenticator, IPrincipalBuilder principalBuilder)
 {
     //TODO: 4-8-2011 -- create a FleutnValidator that matches up with this and call it here
     Name = name;
     Authenticator = authenticator;
     PrincipalBuilder = principalBuilder;
 }
开发者ID:Iristyle,项目名称:Authentic,代码行数:10,代码来源:AuthenticatorConfiguration.cs

示例10: WelcomeViewModel

        public WelcomeViewModel(IAuthenticator authenticator, ITokenProvider tokenProvider)
        {
            _authenticator = authenticator;
            _tokenProvider = tokenProvider;

            LoginCommand = new Command(ExecuteLoginCommand);

        }
开发者ID:MMalikKhan,项目名称:TaskTimerApp,代码行数:8,代码来源:WelcomeViewModel.cs

示例11: DigestAuthenticatorConfiguration

 /// <summary>
 /// Initializes a new instance of the DigestAuthenticatorConfiguration class.
 /// </summary>
 public DigestAuthenticatorConfiguration(string name, IAuthenticator authenticator,
     IPrincipalBuilder principalBuilder, string realm, string privateKey)
     : base(name, authenticator, principalBuilder)
 {
     //TODO: 4-8-2011 cook up an AbstractValidator class that verifies this goop
     Realm = realm;
     PrivateKey = privateKey;
 }
开发者ID:Iristyle,项目名称:Authentic,代码行数:11,代码来源:DigestAuthenticatorConfiguration.cs

示例12: LoginController

 public LoginController(IAuthenticator authenticator, IAccountRepository accountRepository, IEventBus eventBus,
                        IFacebookDataRepository facebookDataRepository)
 {
     this.authenticator = authenticator;
     this.accountRepository = accountRepository;
     this.eventBus = eventBus;
     this.facebookDataRepository = facebookDataRepository;
 }
开发者ID:burkhartt,项目名称:Jellyfish,代码行数:8,代码来源:LoginController.cs

示例13: Client

 public Client(IAuthenticator authenticator)
 {
     _restClient = new RestClient(StravaClient.ApiBaseUrl) { Authenticator = authenticator };
     Athletes = new AthleteClient(this);
     Activities = new ActivityClient(this);
     Segments = new SegmentClient(this);
     Clubs = new ClubClient(this);
 }
开发者ID:gabornemeth,项目名称:StravaSharp,代码行数:8,代码来源:Client.cs

示例14: AccountController

 /// <summary>
 /// Initializes a new instance of the <see cref="AccountController"/> class.
 /// </summary>
 /// <param name="userSession">The user session.</param>
 /// <param name="memberService">The user repository.</param>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="cryptographer">The cryptographer.</param>
 /// <param name="authenticationService"></param>
 public AccountController(IUserSession userSession, IMemberService memberService, IAuthenticator authenticator, ICryptographer cryptographer, IAuthenticationService authenticationService)
     : base(userSession)
 {
     this.memberService = memberService;
     this.authenticator = authenticator;
     this.cryptographer = cryptographer;
     this.authenticationService = authenticationService;
 }
开发者ID:TimBarcz,项目名称:groop,代码行数:16,代码来源:AccountController.cs

示例15: UserController

        public UserController(
			IAuthenticator authenticator,
			IDocumentSession session,
			IExecutionContext executionContext)
        {
            _authenticator = authenticator;
            _session = session;
            _executionContext = executionContext;
        }
开发者ID:hombredequeso,项目名称:Power-Analysis,代码行数:9,代码来源:UserController.cs


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