private static void generatePassword(ICredentialHandler credential) { Console.Clear(); Console.Write("User Id: "); var user = Console.ReadLine(); try { var pass = credential.GetPassword(user); Console.WriteLine("Password: {0}", pass); Console.WriteLine("--------------------------------------------------"); Console.WriteLine("Note: Password will expire after {0} seconds", TimeBasedOTP.TimeBasedPassword.DEFAULT_VALIDITY_PERIODE_SECONDS); } catch (TimeBasedOTP.TimeBasedOneTimePasswordException ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error: {0}", ex.Message); Console.ForegroundColor = ConsoleColor.White; } catch { //TODO } Console.ReadLine(); }
private static void validatePassword(ICredentialHandler credential) { Console.Clear(); Console.Write("User Id: "); var user = Console.ReadLine(); Console.Write("Password: "******"--------------------------------------------------"); try { if (credential.IsValid(user, pass, 30)) { Console.WriteLine("User Authenticated."); } else { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("Invalid user id or password."); } } catch (TimeBasedOTP.TimeBasedOneTimePasswordException ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error: {0}", ex.Message); } Console.ForegroundColor = ConsoleColor.White; Console.ReadLine(); consoleMessage(); }
public void EnsureAuthentication(ICredentialHandler credentialHandler, Uri configurationServiceEndpoint = null) { if (credentialHandler != null) { this.sourceDataProviderManager.AutoDiscoverSourceServiceEndpoints(this.StatusManager.AllSourceInformation, configurationServiceEndpoint, credentialHandler); this.sourceDataProviderManager.CreateSourceServiceClients(this.StatusManager.AllSourceInformation); } }
public UserServiceCallingContext(ICredentialHandler credentialHandler, IDictionary <string, ICredentials> cachedCredentials) { if (credentialHandler == null) { throw new ArgumentNullException("credentialHandler"); } this.credentialHandler = credentialHandler; this.cachedCredentials = (cachedCredentials ?? new Dictionary <string, ICredentials>()); }
public void AutoDiscoverSourceServiceEndpoints(SourceInformationCollection allSourceInformation, Uri configurationServiceEndpoint, ICredentialHandler credentialHandler) { this.serviceClientFactory.CredentialHandler = credentialHandler; if (configurationServiceEndpoint != null && configurationServiceEndpoint.IsAbsoluteUri && configurationServiceEndpoint.Scheme == Uri.UriSchemeHttps) { if (this.IsStopRequested) { Tracer.TraceInformation("SourceDataProviderManager.CreateServiceClients: Stop requested when trying to auto discover with configuration service server", new object[0]); return; } Uri autoDiscoverUrl = new Uri(configurationServiceEndpoint.GetLeftPart(UriPartial.Authority) + "/autodiscover/autodiscover.svc"); this.AutoDiscoverServiceEndpoints((from sourceInformation in allSourceInformation.Values where this.IsServiceEndpointNeededForSource(sourceInformation) select sourceInformation).ToList <SourceInformation>(), autoDiscoverUrl, 0); if (this.IsStopRequested) { Tracer.TraceInformation("SourceDataProviderManager.CreateServiceClients: Stop requested when trying to auto discover with configuration service endpoint", new object[0]); return; } using (IServiceClient <ISourceDataProvider> serviceClient = this.serviceClientFactory.CreateSourceDataProvider(configurationServiceEndpoint, this.abortTokenForTasks)) { if (serviceClient.Connect()) { SourceDataProviderManager.VerifyAndSetServiceEndpoint((from sourceInformation in allSourceInformation.Values where this.IsServiceEndpointNeededForSource(sourceInformation) select sourceInformation).ToList <SourceInformation>(), serviceClient); } } } IEnumerable <IGrouping <string, SourceInformation> > enumerable = from sourceInformation in allSourceInformation.Values where this.IsServiceEndpointNeededForSource(sourceInformation) group sourceInformation by SourceDataProviderManager.GetDomainFromSmtpEmailAddress(sourceInformation.Configuration.Id.StartsWith("\\")?sourceInformation.Configuration.Name : sourceInformation.Configuration.Id); foreach (IGrouping <string, SourceInformation> grouping in enumerable) { if (this.IsStopRequested) { Tracer.TraceInformation("SourceDataProviderManager.CreateServiceClients: Stop requested when trying to auto discover with email domains of source mailboxes.", new object[0]); return; } this.AutoDiscoverServiceEndpointsWithEmailDomain(grouping.ToList <SourceInformation>(), grouping.Key.ToLowerInvariant()); } SourceInformation sourceInformation2 = allSourceInformation.Values.FirstOrDefault((SourceInformation sourceInformation) => this.IsServiceEndpointNeededForSource(sourceInformation)); if (sourceInformation2 != null && !this.IsStopRequested) { throw new ExportException(ExportErrorType.FailedToAutoDiscoverExchangeWebServiceUrl, sourceInformation2.Configuration.Id); } }
public UserServiceCallingContextFactory(ICredentialHandler credentialHandler = null) { this.CredentialHandler = credentialHandler; this.cachedCredentials = new Dictionary <string, ICredentials>(); }
public UserAutoDiscoverCallingContext(ICredentialHandler credentialHandler, IDictionary <string, ICredentials> cachedCredentials = null) : base(credentialHandler, cachedCredentials) { }
public UserEwsCallingContext(ICredentialHandler credentialHandler, string userRole, IDictionary <string, ICredentials> cachedCredentials = null) : base(credentialHandler, cachedCredentials) { this.userRole = userRole; }
public TokenHelper(ICredentialHandler credentialHandler, IJwtTokenHandler jwtTokenHandler) { _credentialHandler = credentialHandler ?? throw new ArgumentNullException(nameof(credentialHandler)); _jwtTokenHandler = jwtTokenHandler ?? throw new ArgumentNullException(nameof(jwtTokenHandler)); }