public FilesWinService(ILog log, IDeaConfig config, IFirewallService firewallService) : base(log, true) { this.config = config; this.firewallService = firewallService; Uri baseAddress = config.FilesServiceUri; var webHttpBinding = new WebHttpBinding(); webHttpBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly; webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; var serviceHost = new IocServiceHost(typeof(FilesService), baseAddress); base.serviceHost = serviceHost; ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(typeof(IFilesService), webHttpBinding, baseAddress); endpoint.Behaviors.Add(new WebHttpBehavior()); ServiceCredential filesCredentials = config.FilesCredentials; #if DEBUG log.Debug("FilesWinService baseAddress: {0} credentials: {1}:{2}", baseAddress, filesCredentials.Username, filesCredentials.Password); #endif serviceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNamePasswordValidator(filesCredentials); serviceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom; }
public VcapComponentBase( string type, string index, Guid uuid, string host, ServiceCredential credentials, DateTime start) { Type = type; Index = index; Uuid = uuid; Host = host; Start = start; Credentials = credentials; }
public async Task <ApiResult> SimpleExecute(Uri uri, HttpMethod method, HttpContent payload = null, string language = null) { var credentials = new ServiceCredential( _configuration["ClientService:UserName"], _configuration["ClientService:Password"]); language = !string.IsNullOrEmpty(language) ? language : _configuration["ClientService:Language"]; return(await Execute(uri, method, payload, credentials, language, _configuration["ClientService:ApiKey"])); }
void Start() { LogSystem.InstallDefaultReactors(); _dataController = FindObjectOfType <DataController> (); _voiceProcessor = FindObjectOfType <VoiceProcessor> (); CredentialData serviceCredentials = _dataController.GetServiceCredentials(); ServiceCredential textToSpeechCredential = serviceCredentials.textToSpeechCredential; Credentials credentials = new Credentials(textToSpeechCredential.username, textToSpeechCredential.password, textToSpeechCredential.url); _textToSpeech = new TextToSpeech(credentials); }
public static async Task <string> LoginAsync(string username, string password, string loginURI) { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; var credential = new ServiceCredential() { Name = username, Password = password }; var loginParams = new LoginServiceParams(); loginParams.ServiceCredential = credential; var resultdeserealizedJson = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, "", new Uri(loginURI), loginParams); var resultdeserealized = JsonSerializer.DeserializeObject <LoginResult>(resultdeserealizedJson); return(resultdeserealized.AccessToken.AuthorizationHeader); }
void Start() { LogSystem.InstallDefaultReactors(); _dataController = FindObjectOfType <DataController> (); _scriptReader = FindObjectOfType <ScriptReader> (); CredentialData serviceCredentials = _dataController.GetServiceCredentials(); ServiceCredential speechToTextCredential = serviceCredentials.speechToTextCredential; // Create credential and instantiate service Credentials credentials = new Credentials(speechToTextCredential.username, speechToTextCredential.password, speechToTextCredential.url); _speechToText = new SpeechToText(credentials); _speechToText.ProfanityFilter = false; Active = true; StartRecording(); }
public GoogleService(IConfigurationManager configurationManager) { Check.Argument.IsNotNull(configurationManager, "configurationManager"); _configurationManager = configurationManager; calendarId = _configurationManager.AppSettings["googleCalendarId"]; applicationName = _configurationManager.AppSettings["googleApplicationName"]; private_key = _configurationManager.AppSettings["googlePrivateKey"]; client_email = _configurationManager.AppSettings["googleClientEmail"]; credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(client_email) { Scopes = scopes }.FromPrivateKey(private_key)); service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = applicationName, }); }
public CustomUserNamePasswordValidator(ServiceCredential credentials) { this.credentials = credentials; }
public VcapComponentAnnounce(string type, string index, Guid uuid, string host, ServiceCredential credentials, DateTime start) : base(type, index, uuid, host, credentials, start) { }
public VcapComponentDiscover(string type, Guid uuid, string host, ServiceCredential credentials) : base(type, null, uuid, host, credentials, DateTime.Now) { }
public OAuth2Interceptor(ServiceCredential credential, IClock clock) { this.credential = credential; this.clock = clock; }
private GoogleCredential(ServiceCredential credential) { this.credential = credential; }
public async Task <ApiResult> Execute(Uri uri, HttpMethod method, HttpContent payload = null, ServiceCredential credential = null, string language = null, string apiKey = null) { var httpClientHandler = new HttpClientHandler { AllowAutoRedirect = true }; var httpRequestMessage = new HttpRequestMessage { Method = method, RequestUri = uri }; httpRequestMessage.Headers.Add("Cache-Control", "no-cache"); if (credential != null) { var credentials = string.Format("{0}:{1}", credential.UserName, credential.Password); var credentialsBytes = Encoding.ASCII.GetBytes(credentials); var auth = Convert.ToBase64String(credentialsBytes); httpRequestMessage.Headers.Add("Authorization", "Basic " + auth); } if (!string.IsNullOrEmpty(apiKey)) { httpRequestMessage.Headers.Add("x-api-key", apiKey); } if (!string.IsNullOrEmpty(language)) { httpRequestMessage.Headers.Add("Accept-Language", language); } if (!string.IsNullOrEmpty(_configuration["ClientService:CustomHeaderType"])) { httpRequestMessage.Headers.Add(_configuration["ClientService:CustomHeaderType"], _configuration["ClientService:CustomHeaderValue"]); } return(await Execute(httpClientHandler, httpRequestMessage, payload)); }