本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例5: RequestRunner
public RequestRunner(
ITransmissionSettings transmissionSettings,
IAuthenticator authenticator)
{
this.transmissionSettings = transmissionSettings;
this.authenticator = authenticator;
}
示例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;
}
示例7: Init
private void Init(IAuthenticator auth, string server)
{
Server = server;
RestClient = new RestClient(Server);
RestClient.Authenticator = auth;
}
示例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();
}
示例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;
}
示例10: WelcomeViewModel
public WelcomeViewModel(IAuthenticator authenticator, ITokenProvider tokenProvider)
{
_authenticator = authenticator;
_tokenProvider = tokenProvider;
LoginCommand = new Command(ExecuteLoginCommand);
}
示例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;
}
示例12: LoginController
public LoginController(IAuthenticator authenticator, IAccountRepository accountRepository, IEventBus eventBus,
IFacebookDataRepository facebookDataRepository)
{
this.authenticator = authenticator;
this.accountRepository = accountRepository;
this.eventBus = eventBus;
this.facebookDataRepository = facebookDataRepository;
}
示例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);
}
示例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;
}
示例15: UserController
public UserController(
IAuthenticator authenticator,
IDocumentSession session,
IExecutionContext executionContext)
{
_authenticator = authenticator;
_session = session;
_executionContext = executionContext;
}