private HttpRequestMessage CreateRequest(string endPoint, HttpMethod method, DateTime?modifiedSince = null, string accept = "application/json", HttpContent content = null, string query = null) { if (!string.IsNullOrWhiteSpace(query)) { endPoint = string.Format("{0}?{1}", endPoint, query); } var uri = new Uri(_baseUri, endPoint); var request = new HttpRequestMessage(method, uri) { Content = content }; request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); if (modifiedSince.HasValue) { request.Headers.IfModifiedSince = modifiedSince; } _auth?.Authenticate(request, _consumer, _user); var escapedUserAgent = Uri.EscapeDataString("Xero-NetStandard - " + _consumer.ConsumerKey); request.Headers.UserAgent.Add(new ProductInfoHeaderValue(new ProductHeaderValue(escapedUserAgent))); if (!string.IsNullOrWhiteSpace(UserAgent)) { var escapedCustomUserAgent = Uri.EscapeDataString(UserAgent); request.Headers.UserAgent.Add(new ProductInfoHeaderValue(new ProductHeaderValue(escapedCustomUserAgent))); } return(request); }
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { IHeaderDictionary headers = context.HttpContext.Request.Headers; if (!headers.ContainsKey(AuthorizationHeader)) { context.Result = new StatusCodeResult(403); return; } string[] authValues = headers[AuthorizationHeader].ToArray(); if (authValues.Length != 1) { context.Result = new StatusCodeResult(403); return; } string auth = authValues.Single(); if (!auth.StartsWith(BasicPrefix)) { context.Result = new StatusCodeResult(403); return; } auth = auth.Substring(BasicPrefix.Length).Trim(); byte[] decoded = Convert.FromBase64String(auth); Encoding iso = Encoding.GetEncoding("ISO-8859-1"); string[] authPair = iso.GetString(decoded).Split(':'); if (!authenticator.Authenticate(authPair[0], authPair[1])) { context.Result = new StatusCodeResult(403); return; } await next(); }
public AuthenticationResult Authenticate(User user, string password) { if (cache.ContainsKey(user.Username)) { var entry = cache[user.Username]; if (DateTime.Now.Subtract(entry.Timestamp).TotalSeconds < CacheValidity) { return(entry.Item); } else { cache.Remove(user.Username); } } var result = realAuthenticator.Authenticate(user, password); var newEntry = new CacheEntry <AuthenticationResult>(user, DateTime.Now, result); cache.Add(user.Username, newEntry); return(result); }
/// <summary> /// 调用认证接口 /// </summary> /// <param name="strSignInName">登录名</param> /// <param name="strPasspord">密码</param> /// <returns>用户认证的结果</returns> private ISignInUserInfo DefaultAuthenticate(string strSignInName, string strPasspord) { LogOnIdentity loi = new LogOnIdentity(strSignInName, strPasspord); OnBeforeAuthenticate(loi); ISignInUserInfo result = null; IAuthenticator2 auth2 = this.GetAuthenticator2(); if (auth2 != null) { SignInPerformanceCounters.DoAction(() => result = auth2.Authenticate(loi.LogOnName, loi.Password, loi.Context)); } else { IAuthenticator auth = GetAuthenticator(); SignInPerformanceCounters.DoAction(() => result = auth.Authenticate(loi.LogOnName, loi.Password)); } return(result); }
/// <summary> /// Launches The AutoStore solution with the given authenticator with either eager or lazy authentication. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <param name="authenticationMode">The authentication mode.</param> /// <exception cref="DeviceWorkflowException"> /// Login screen not found. /// or /// Eager authentication is not allowed by the AutoStore application at this time. /// </exception> public override void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode) { if (authenticationMode.Equals(AuthenticationMode.Lazy)) { EmailToAddress = authenticator.Credential.UserName + "@" + authenticator.Credential.Domain; if (PressAutoStoreButton()) { authenticator.LazyAuthOnly = true; authenticator.Authenticate(); } else { throw new DeviceWorkflowException("Login screen not found within 15 seconds."); } } else // AuthenticationMode.Eager { throw new DeviceWorkflowException("Eager authentication is not allowed by the AutoStore application at this time."); } AutoStoreReady(); RecordEvent(DeviceWorkflowMarker.AppShown); }
public void GetReleaseEnvironmentStatus_ReleaseHasApprovals_ReturnsPendingApproval() { IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>(); IAuthenticator authenticator = Substitute.For <IAuthenticator>(); VstsConfig vstsConfig = new VstsConfig(); authenticator.Authenticate().Returns(new AuthenticationResult { Success = true }); releaseClient.GetRelease(Arg.Any <int>(), Arg.Any <string>()).Returns(GetTestRelease(EnvironmentStatus.InProgress)); releaseClient.GetApprovals(Arg.Any <int>(), Arg.Any <string>()).Returns( new List <ReleaseApproval> { new ReleaseApproval() }); this.sut = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig); SolutionDeploy.Core.DeploymentStatus result = this.sut.GetReleaseEnvironmentStatus("123", "123"); Assert.Equal(SolutionDeploy.Core.DeploymentStatus.PendingApproval, result); }
private void AuthenticateWindjammer(string deviceIP, string userName) { IDevice device = DeviceFactory.Create(deviceIP, "!QAZ2wsx"); AuthenticationCredential credential = new AuthenticationCredential(userName, "1qaz2wsx", "etl.boi.rd.hpicorp.net"); JediWindjammerPreparationManager prepMgr = new JediWindjammerPreparationManager(((JediWindjammerDevice)device)); JediWindjammerControlPanel controlPanel = ((JediWindjammerDevice)device).ControlPanel; // Set up the device for Authentication //prepMgr.Reset(); controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM); //IEnumerable<string> controls = controlPanel.GetControls(); //foreach (string s in controls) //{ // System.Diagnostics.Debug.WriteLine(s); //} IAuthenticator authenticator = AuthenticatorFactory.Create(device, credential, AuthenticationProvider.Auto); authenticator.Authenticate(); }
/// <summary> /// Signs into WindJammer using the authenticator method and ignores authentication Mode /// </summary> /// <param name="authenticator"></param> /// <param name="authenticationMode"></param> public override void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode) { if (authenticator == null) { throw new ArgumentNullException(nameof(authenticator)); } Widget appButton = _controlPanel.ScrollToItem("Title", _buttonTitle); if (appButton != null) { UpdateStatus("Pressing {0}", _buttonTitle); RecordEvent(DeviceWorkflowMarker.AppButtonPress); _controlPanel.Press(appButton); bool promptedForCredentials = _controlPanel.WaitForScreen(_signInScreen, TimeSpan.FromSeconds(6)); if (promptedForCredentials) { UpdateStatus("Entering credentials"); authenticator.Authenticate(); _controlPanel.WaitForScreen(_scanScreen, TimeSpan.FromSeconds(15)); RecordEvent(DeviceWorkflowMarker.AppShown); } GetCurrentForm(); } else { if (GetCurrentForm() == _homeScreen) { throw new DeviceWorkflowException(string.Format("Application {0} button was not found on device home screen.", _buttonTitle)); } else { throw new DeviceInvalidOperationException(string.Format("Cannot launch the {0} application: Not at device home screen.", _buttonTitle)); } } }
private void Authenticate(IAuthenticator authenticator, string waitForm) { try { authenticator.Authenticate(); if (_controlPanel.WaitForForm(waitForm, StringMatch.Contains, TimeSpan.FromSeconds(30))) { RecordEvent(DeviceWorkflowMarker.AppShown); } } catch (WindjammerInvalidOperationException ex) { string currentForm = _controlPanel.CurrentForm(); switch (currentForm) { case "OxpUIAppMainForm": // The application launched successfully. This happens sometimes. RecordEvent(DeviceWorkflowMarker.AppShown); break; case "OneButtonMessageBox": string message = _controlPanel.GetProperty("mMessageLabel", "Text"); if (message.StartsWith("Invalid", StringComparison.OrdinalIgnoreCase)) { throw new DeviceWorkflowException(string.Format("Could not launch the SafeCom application: {0}", message), ex); } else { throw new DeviceInvalidOperationException(string.Format("Could not launch the SafeCom application: {0}", message), ex); } default: throw new DeviceInvalidOperationException(string.Format("Could not launch the SafeCom application: {0}", ex.Message), ex); } } }
public async Task <HttpResponse> ExecuteAsync() { using (var client = new System.Net.Http.HttpClient(_messageHandler)) { AddDefaults(); _message.RequestUri = _baseAddress.AddPathParameters( _path, _pathParameters); _authenticator?.Authenticate(this); if (_message.Content == null) { _parameterHandler.AddParameters( _message, MediaTypeEnum.Form, _queryParameters); } else { //TODO: allow content throw new NotImplementedException(); } var response = await client .SendAsync(_message) .ConfigureAwait(false); return(new HttpResponse( response.Content, response.Headers, response.StatusCode, response.ReasonPhrase, GetSerializer(response))); } }
/// <summary> /// Signs into Sirius Device using authenticator information and desired authentication Mode /// </summary> /// <param name="authenticator"></param> /// <param name="authenticationMode"></param> public override void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode) { LaunchApp(); if (_controlPanel.WaitForActiveScreenLabel("view_sips_form", DefaultScreenWait)) { UpdateStatus("Entering credentials..."); authenticator.Authenticate(); _controlPanel.WaitForActiveScreenLabel("view_sips_nolistorform_txtonly", TimeSpan.FromSeconds(30)); RecordEvent(DeviceWorkflowMarker.AppShown); } // Fill in additional values for certain HPCR workflow types string buttonTitle = _buttonTitle; if (_buttonTitle.StartsWith(HpcrAppTypes.ScanToFolder.GetDescription(), StringComparison.OrdinalIgnoreCase)) { UpdateStatus("Pressing button that starts with {0} ({1})", buttonTitle, _buttonTitle); _controlPanel.WaitForActiveScreenLabel("view_sips_vert1colImgTxt_single", TimeSpan.FromSeconds(5)); _controlPanel.ScrollToItemByValue("sips_single_vert1colImgTxt", _scanDestination); _controlPanel.PressByValue(_scanDestination); } else if (_buttonTitle.StartsWith(HpcrAppTypes.PersonalDistributions.GetDescription(), StringComparison.OrdinalIgnoreCase)) { UpdateStatus("Pressing {0}", _buttonTitle); _controlPanel.WaitForActiveScreenLabel("view_sips_vert1colTxtOnly_single", TimeSpan.FromSeconds(5)); _controlPanel.ScrollToItemByValue("sips_single_vert1colImgTxt", _scanDestination); _controlPanel.PressByValue(_scanDestination); } else if (_buttonTitle.StartsWith(HpcrAppTypes.PublicDistributions.GetDescription(), StringComparison.OrdinalIgnoreCase)) { UpdateStatus("Pressing {0}", _buttonTitle); _controlPanel.WaitForActiveScreenLabel("view_sips_vert1colTxtOnly_single", TimeSpan.FromSeconds(5)); _controlPanel.ScrollToItemByValue("sips_single_vert1colImgTxt", _scanDestination); _controlPanel.PressByValue(_scanDestination); } }
/// <summary> /// Authenticate /// </summary> /// <param name="authenticator">authenticator</param> /// <param name="waitForm">wait form</param> private void Authenticate(IAuthenticator authenticator, string waitForm) { _controlPanel.SignalUserActivity(); authenticator.Authenticate(); _controlPanel.WaitForAvailable(waitForm); }
private static void Authenticate(IAuthenticator authenticator) { authenticator.Authenticate(); }
/// <summary> /// Authenticates an request /// </summary> /// <param name="authenticator">Authentication method</param> /// <param name="request">Request to be authenticated</param> public void Authenticate(IAuthenticator authenticator, IRequest request) { authenticator.Authenticate(request); }
private void Server_DataRecieved(string host, byte[] requestData) { // Match host session var session = sessions.GetSession(host); if (session == null) { if (UnknownSession != null) { UnknownSession(string.Format("Session not found for host: {0}.", host)); } return; } // Commit request session phase Request request = null; if (session.CurrentPhase == SessionPhase.Hello) { request = MatchRequest <HelloRequest>(requestData); if (request == null) { return; } } else if (session.CurrentPhase == SessionPhase.Encryption) { var data = DecryptRequest(requestData, asymetricCrypter); if (data == null) { return; } request = MatchRequest <KeyExchangeRequest>(data); } else if (session.CurrentPhase == SessionPhase.Authentication) { var data = DecryptRequest(requestData, session.Crpter); if (data == null) { return; } request = MatchRequest <AuthenticateRequest>(data); } else { var data = DecryptRequest(requestData, session.Crpter); if (data == null) { return; } request = MatchRequest <Request>(data); } request.Session = session; Response response = null; // Authenitacate request user AuthenticationResult result = AuthenticationResult.Denied; if (request.RequiresAuthentication) { string password = session.Crpter.DecryptString(request.User.PasswordEnc); result = authenticator.Authenticate(request.User, password); } if (!request.RequiresAuthentication || result == AuthenticationResult.Granted) { // Check user permissions for request (authorize request user) Permission[] permissions = null; if (request.RequiresAuthorization) { permissions = authorizator.ListPermissions(request.User); } if (!request.RequiresAuthorization || request.MatchesPermissions(permissions)) { try { // EXECUTE REQUEST ProgramOutput.Info("Executing request: {0}...", request.ToString()); response = request.Execute(); } catch (Exception ex) { response = new CannotExecuteResponse(ex); if (ExecuteError != null) { ExecuteError(request, ex); } } } else { response = new AccessDeniedResponse(); if (AccessDenied != null) { AccessDenied(request); } } } else if (result == AuthenticationResult.Denied) { response = new UnauthorizedResponse(request.User); if (Unauthorized != null) { Unauthorized(request); } } if (!(request is GoodbyeRequest)) { // Serialize response byte[] responseData = null; try { responseData = formatter.Format(response); } catch (Exception ex) { Console.WriteLine(ex.Message); if (InvalidResponse != null) { InvalidResponse(request); } return; } // Encrypt response if (session.CurrentPhase == SessionPhase.Authentication || session.CurrentPhase == SessionPhase.Established) { responseData = EncryptResponse(responseData, session.Crpter); } if (responseData == null) { return; } // Send response try { ProgramOutput.Info("Responding: {0}, status code: {1}", response, response.Code); server.SendMessage(host, responseData); } catch (SocketException) { if (NetProblem != null) { NetProblem(request); } return; } session.NextPhase(); } }
/// <summary> /// Authenticates the specified authenticator. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <param name="waitForm">The relavent Id for Sign In/Sign out button on DUT.</param> private void Authenticate(IAuthenticator authenticator, string waitForm) { authenticator.Authenticate(); _controlPanel.WaitForAvailable(waitForm); RecordEvent(DeviceWorkflowMarker.AppShown); }
private async Task <IActionResult> ScopeAwareAuthentication(string username, string password, Models.User.Action scope) { var user = await _authenticator.Authenticate(username, password, scope); if (user == null) { _response.Errors.Add(Errors.AUTHENTICATION_FAILED, ""); } if (HasErrors()) { return(StatusCode(403, _response)); } _response.Message = Messages.AUTHENTICATION_SUCCEEDED; switch (scope) { case Models.User.Action.ManageApi: case Models.User.Action.ManageDaemon: // Intentionally hidden to keep the JWT length manageable user.Cert = null; user.CertKey = null; var userJson = JsonConvert.SerializeObject(user, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } ); var claims = new[] { new Claim(ClaimTypes.UserData, userJson), }; var key = _cryptoService.GetJWTSigningKey(); var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha512); // Hardcoded alg for now, perhaps allow changing later var accessExpires = DateTime.Now.AddMinutes(AppConfig.JWTTokenExpiryInMinutes > 0 ? AppConfig.JWTTokenExpiryInMinutes : 60); // 60 minutes by default var token = new JwtSecurityToken ( // Can't issue aud/iss since we have no idea what the accessing URL will be. // This is not a typical webapp with static `Host` claims: claims, expires: accessExpires, signingCredentials: credentials, issuer: _identityProvider.GetFQDN() ); var accessToken = new Token { token = new JwtSecurityTokenHandler().WriteToken(token), expires = ((DateTimeOffset)accessExpires).ToUnixTimeSeconds() }; var refreshExpires = accessExpires.AddMinutes(AppConfig.JWTRefreshTokenDelta > 0 ? AppConfig.JWTRefreshTokenDelta : 30); var refreshToken = new Token { token = null, expires = ((DateTimeOffset)refreshExpires).ToUnixTimeSeconds() }; _response.Message = Messages.JWT_TOKEN_ISSUED; _response.Result = new AuthResponse { Access = accessToken, Refresh = refreshToken }; break; } return(Ok(_response)); }
public async Task <bool> Authenticate() { _AuthenticationResult = await _Authenticator.Authenticate(_TenantAuthority, _ResourceUri, _ClientId, _ReturnUri); return(true); }
/// <summary> /// Authenticates the specified authenticator /// </summary> /// <param name="authenticator"></param> /// <param name="waitForm"></param> /// <param name="parameters"></param> private void Authenticate(IAuthenticator authenticator, string waitForm, Dictionary <string, object> parameters) { authenticator.Authenticate(parameters); _controlPanel.WaitForAvailable(waitForm); }
/// <summary> /// Authenticates using the specified authenticator. /// </summary> /// <param name="authenticator">The authenticator.</param> private void Authenticate(IAuthenticator authenticator) { authenticator.Authenticate(); _controlPanel.WaitForScreenLabel(HpacAppLabel, TimeSpan.FromSeconds(40)); RecordEvent(DeviceWorkflowMarker.AppShown); }
/// <summary> /// Releases all documents on a device configured to release all documents on sign in. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <returns><c>true</c> if the printer release jobs, <c>false</c> otherwise.</returns> public void SignInReleaseAll(IAuthenticator authenticator) { PressSignInButton(); authenticator.Authenticate(); PrintAll(); }
/// <summary> /// Launches Scan to Network Folder using the specified authenticator and authentication mode. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <param name="authenticationMode">The authentication mode.</param> /// <exception cref="DeviceInvalidOperationException"> /// </exception> /// <exception cref="DeviceWorkflowException"> /// Network Folder button was not found on device home screen. /// or /// Sign-in required to launch the Email application. /// </exception> /// <exception cref="System.NotImplementedException">Eager authentication has not been implemented for this solution.</exception> public void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode) { if (authenticationMode.Equals(AuthenticationMode.Lazy)) { try { _controlPanel.ScrollPress("sfolderview_p", "group.group.scan"); _controlPanel.WaitForScreenLabel("Home", TimeSpan.FromSeconds(1)); //Scan To Page Pacekeeper.Pause(); _controlPanel.ScrollPress("sfolderview_p", "command.scan_folder"); Pacekeeper.Pause(); if (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault() != "Scan_NetworkFolder_FolderList") //Scan_NetworkFolder_HomeGlass;Scan_NetworkFolder_HomeADF { authenticator.Authenticate(); } //Veda: This is not needed //_controlPanel.WaitForScreenLabel("view_scan_folder_presets", TimeSpan.FromSeconds(30)); //Network folder page Pacekeeper.Pause(); } catch (ElementNotFoundException ex) { string currentScreen = _controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault(); if (currentScreen == "Home") { throw new DeviceInvalidOperationException($"Cannot launch the Network application from {currentScreen}.", ex); } if (currentScreen == "Scan_NetworkFolder_HomeGlass") { //Some times this happens } else { throw new DeviceWorkflowException("Network Folder button was not found on device home screen.", ex); } } catch (SiriusInvalidOperationException ex) { switch (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault()) { case "Scan_NetworkFolder_HomeGlass": case "Scan_NetworkFolder_HomeADF": // The application launched successfully. This happens sometimes. break; case "AnA_Login_With_Windows_Authentication": case "AnA_Login_With_LDAP_Authentication": { throw new DeviceWorkflowException("Sign-in required to launch the Email application.", ex); } default: { throw new DeviceInvalidOperationException($"Could not launch Email application: {ex.Message}", ex); } } } } else { throw new NotImplementedException("Eager authentication has not been implemented for this solution."); } }
public IPrincipal Authenticate(string user, string password) { return(_authenticator.Authenticate(user, password)); }
private async Task Authenticate(string userName) { await _authenticator.Authenticate(userName, HttpContext); }
public Task Process(PingRequest request, CancellationToken cancellationToken) { request.AuthenticationResult = _authenticator.Authenticate(request.User); return(Task.FromResult(request)); }
private bool Login(string serviceUrl, IAuthenticator authenticator, string username, string deviceToken) { bool cancelled; IDoxSession session = authenticator.Authenticate(username, deviceToken, out cancelled); var validated = ValidateSession(serviceUrl, session, username); if (!validated && !cancelled) { WsMessage.ShowMessage(IntPtr.Zero, "Please logon with your business or enterprise account", MessageButtons.WsOK, MessageBranding.WsDefault, MessageType.WsErrorIcon, "You must be a business or enterprise user", -1); } return !cancelled && validated; }
public IHttpActionResult GetAuth(string Username, string Password) { return(Ok(_authService.Authenticate(Username, Password))); }
/// <summary> /// Authenticates the specified authenticator. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <param name="waitForm">The wait form.</param> private void Authenticate(IAuthenticator authenticator, string waitForm) { authenticator.Authenticate(); _controlPanel.WaitForAvailable(waitForm); }
/// <summary> /// Shows the Google authentication web view so the user can authenticate /// and gets the user's Google profile from Google API /// </summary> public async Task Authenticate() { using (new Busy(this)) { if (!string.IsNullOrEmpty(Settings.AzureUserId)) { //We already have an exsting google auth token that is still valid, no need to do anything else AzureService.Instance.Client.CurrentUser = new MobileServiceUser(Settings.AzureUserId) { MobileServiceAuthenticationToken = Settings.AzureAuthToken }; bool clearCookies = true; bool didErr = false; try { var success = await GetUserProfile(); if (success) { return; } } catch (MobileServiceInvalidOperationException mse) { //Bad or stale credentials, clear out and retry if (mse.Response.StatusCode == HttpStatusCode.Forbidden) { clearCookies = false; } didErr = true; Debug.WriteLine(mse); } catch (Exception e) { Debug.WriteLine(e); didErr = true; } if (didErr) { await LogOut(clearCookies); await Authenticate(); return; } } try { AuthenticationStatus = "Loading..."; MobileServiceUser user = await _authenticator.Authenticate(); await SetIdentityValues(user); await GetUserProfile(); } catch (Exception e) { MessagingCenter.Send(new object(), Messages.ExceptionOccurred, e); Debug.WriteLine("**SPORT AUTHENTICATION ERROR**\n\n" + e.GetBaseException()); //InsightsManager.Report(e); } } }
/// <summary> /// Launches the Email application using the specified authenticator and authentication mode. /// </summary> /// <param name="authenticator">The authenticator.</param> /// <param name="authenticationMode">The authentication mode.</param> public void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode) { if (authenticationMode.Equals(AuthenticationMode.Lazy)) { try { _controlPanel.ScrollPress("sfolderview_p", "group.group.scan"); _controlPanel.WaitForScreenLabel("Home", _shortTimeSpan); //Scan To Page Pacekeeper.Pause(); _controlPanel.ScrollPress("sfolderview_p", "command.scan_email"); Pacekeeper.Pause(); if (!_controlPanel.WaitForScreenLabel("Scan_Email_EmailPageGlass", _shortTimeSpan)) { //if there are two sender's profile, we will have this intermediate screen which needs to be handled, selecting the first one as default if (_controlPanel.WaitForScreenLabel("Scan_Email_SenderProfile", _shortTimeSpan)) { _controlPanel.Press("model.ScanEmailProfilesModel.0"); Pacekeeper.Pause(); } if (_controlPanel.WaitForScreenLabel("AnA_Login_With_Windows_Authentication", _shortTimeSpan) || _controlPanel.WaitForScreenLabel("AnA_Login_With_LDAP_Authentication", _shortTimeSpan)) //Scan To Page { Pacekeeper.Pause(); } } if (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault() != "Scan_Email_EmailPageGlass") { if (authenticator == null) { throw new DeviceWorkflowException("Credentials are not supplied"); } authenticator.Authenticate(); } _controlPanel.WaitForScreenLabel("Scan_Email_EmailPageGlass", _longTimeSpan); //Email Form Pacekeeper.Pause(); } catch (ElementNotFoundException ex) { string currentForm = _controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault(); if (currentForm.Equals("Home")) { throw new DeviceWorkflowException($"Email application button was not found on device home screen.", ex); } else { throw new DeviceWorkflowException($"Cannot launch the Email application from {currentForm}.", ex); } } catch (SiriusInvalidOperationException ex) { switch (_controlPanel.GetScreenInfo().ScreenLabels.FirstOrDefault()) { case "Scan_Email_EmailPageGlass": // The application launched successfully. This happens sometimes. break; case "AnA_Login_With_Windows_Authentication;AnA_Login_With_LDAP_Authentication": { throw new DeviceWorkflowException($"Sign-in required to launch the Email application.", ex); } case "Scan_Email_NotSetup": { throw new DeviceWorkflowException("Scan To Email is not configured"); } default: { throw new DeviceWorkflowException($"Could not launch Email application: {ex.Message}", ex); } } } } else // AuthenticationMode.Eager { throw new NotImplementedException("Eager Authentication has not been implemented in SiriusUIv3EmailApp."); } }
public Rights Authenticate() { return(authenticator.Authenticate(Name, Id)); }