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

C# IAuthenticator类代码示例

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

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



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


示例16: AuthClient

        /// <inheritdoc/>
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthClient"/> class and binds it with a network session.
        /// </summary>
        /// <param name="authenticator">The <see cref="IAuthenticator"/> to use for authenticating the user.</param>
        /// <param name="nexus">The <see cref="IAuthToNexusRequestHandler"/> to query for... world stuff.</param>
        /// <param name="serverSession"><inheritdoc/></param>
        /// <param name="packetFactory"><inheritdoc/></param>
        /// <param name="logger"><inheritdoc/></param>
        public AuthClient(IAuthenticator authenticator, IAuthToNexusRequestHandler nexus, IServerSession serverSession, IPacketFactory packetFactory, ILogger logger)
            : base(serverSession, packetFactory, logger)
        {
            this.authenticator = authenticator;
            this.nexus = nexus;

            this.LoginAttempts = 0;
            this.State = AuthClientState.NotLoggedIn;
        }
开发者ID:shoftee,项目名称:OpenStory,代码行数:18,代码来源:AuthClient.cs


示例17: RequestRunner

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


示例18: AuthenticationController

        public AuthenticationController(IApplicationServices applicationServices, IFormsAuthentication formsAuthentication, IAuthenticator authenticator)
            : base(applicationServices)
        {
            Guard.IsNotNull(formsAuthentication, "formsAuthentication");
            Guard.IsNotNull(authenticator, "authenticator");

            this.formsAuthentication = formsAuthentication;
            this.authenticator = authenticator;
        }
开发者ID:pablogq,项目名称:Blog,代码行数:9,代码来源:AuthenticationController.cs


示例19: AuthTicketService

 public AuthTicketService(
     [NotNull]HttpContextBase httpContext,
     [NotNull]IAuthTicketFactory ticketFactory,
     [NotNull]IAuthenticator authenticator)
 {
     this.httpContext = httpContext;
     this.ticketFactory = ticketFactory;
     this.authenticator = authenticator;
 }
开发者ID:tmont,项目名称:portoa,代码行数:9,代码来源:AuthTicketService.cs


示例20: LogWriter

        public LogWriter(ILogContext context, IAuthenticator authenticator, IClock clock)
        {
            Contract.Requires<ArgumentNullException>(context != null);
            Contract.Requires<ArgumentNullException>(authenticator != null);
            Contract.Requires<ArgumentNullException>(clock != null);

            _context = context;
            _authenticator = authenticator;
            _clock = clock;
        }
开发者ID:digideskio,项目名称:infrastructure,代码行数:10,代码来源:LogWriter.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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