public void Multiple_Create_calls_should_return_different_authenticators_instances()
        {
            var subject        = new AuthenticatorFactory(() => new PlainAuthenticator(new UsernamePasswordCredential("source", "user", "password"), serverApi: null));
            var authenticator1 = subject.Create();
            var authenticator2 = subject.Create();

            authenticator1.Should().NotBeSameAs(authenticator2);
        }
Example #2
0
        /// <summary>
        /// Initializes the authenticator that will be used in the run, including setting up the badgebox if needed.
        /// </summary>
        /// <param name="provider">The authentication provider to create</param>
        /// <param name="device">The device that will be used for the run.</param>
        private IAuthenticator GetAuthenticator(AuthenticationProvider provider, IDevice device)
        {
            IAuthenticator authenticator = AuthenticatorFactory.Create(_deviceInfo.AssetId, device, provider, _executionData);

            authenticator.WorkflowLogger = _workflowLogger;
            return(authenticator);
        }
Example #3
0
        /// <summary>
        /// Sets up the scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override void SetupJob(IDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            UpdateStatus(string.Format("Setting up device at address {0} for user {1}", device.Address, ExecutionData.Credential.UserName));

            string entryButtonTitle = "My workflow (FutureSmart)";

            IAuthenticator auth = AuthenticatorFactory.Create(device, ExecutionData.Credential, AuthenticationProvider.Auto);

            auth.WorkflowLogger = WorkflowLogger;

            AuthenticationMode am = (_data.ApplicationAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

            if (am.Equals(AuthenticationMode.Eager))
            {
                UpdateStatus("Authenticating by pressing the Sign In button first.");
            }
            else
            {
                UpdateStatus(string.Format("Authenticating by pressing the {0} button first.", entryButtonTitle));
            }

            _hpecApp = HpecFactory.Create(device);
            _hpecApp.WorkflowLogger = WorkflowLogger;

            _hpecApp.Launch(auth, am);
        }
Example #4
0
        /// <summary>
        /// Initializes the authenticator that will be used in the run.
        /// </summary>
        /// <param name="provider">The authentication provider to create.</param>
        /// <param name="device">The device that will be used for the run.</param>
        protected void InitializeAuthenticator(AuthenticationProvider provider, IDevice device)
        {
            // Only AutoStore authentication (Lazy) is allowed by the application at this time.
            // Also, card auth is not supported at this time.

            Authenticator = AuthenticatorFactory.Create(device, ExecutionData.Credential, provider);
            Authenticator.WorkflowLogger = WorkflowLogger;
        }
        public void Create_should_create_authenticator_based_on_the_provided_delegate()
        {
            var subject       = new AuthenticatorFactory(() => new PlainAuthenticator(new UsernamePasswordCredential("source", "user", "password"), serverApi: null));
            var authenticator = subject.Create();

            var typedAuthenticator = authenticator.Should().BeOfType <PlainAuthenticator>().Subject;

            typedAuthenticator.DatabaseName.Should().Be("source");
        }
        public void Authentication(string appName)
        {
            // Create Authenticator
            IAuthenticator auth = AuthenticatorFactory.Create(_device, _credential, AuthenticationProvider.Windows);

            var preparationManager = new SiriusUIv2PreparationManager(_device);

            try
            {
                preparationManager.InitializeDevice(true);

                switch (appName)
                {
                case "Sign In":
                    throw new DeviceWorkflowException("Sign In from home screen not supported for this device");

                case "HP AC Secure Pull Print":
                case "My workflow (FutureSmart)":
                case "Pull Print":
                    _device.ControlPanel.PressByValue("Apps");
                    WaitForScreenLabel("view_oxpd_home", TimeSpan.FromSeconds(30));

                    string displayedTitle = GetButtonDisplayedTitle(appName);
                    _device.ControlPanel.ScrollToItemByValue("oxpd_home_table", displayedTitle);
                    _device.ControlPanel.PressByValue(displayedTitle);

                    WaitForScreenLabel("view_sips_form", TimeSpan.FromSeconds(30));
                    auth.Authenticate();
                    break;

                default:
                    AuthenticationHelper.LaunchApp(_device, appName, auth);
                    break;
                }
            }
            catch (Exception ex)
            {
                var currentScreen = _device.ControlPanel.ActiveScreenLabel();
                ExecutionServices.SystemTrace.LogDebug("Active screen = " + currentScreen);
                throw new DeviceInvalidOperationException($"Unable to authenticate: current screen = {currentScreen}", ex);
            }
            finally
            {
                try
                {
                    preparationManager.NavigateHome();
                }
                catch
                {
                    //ignored
                }
            }
        }
Example #7
0
        public void Authentication(string appName)
        {
            // Create Authenticator
            IAuthenticator auth = AuthenticatorFactory.Create(_device, _credential, AuthenticationProvider.Auto);

            try
            {
                var jediWindJammerPrepManager = new JediWindjammerPreparationManager(_device);
                jediWindJammerPrepManager.InitializeDevice(true);

                switch (appName)
                {
                case "Sign In":
                    _device.ControlPanel.PressToNavigate("mSignInButton", "SignInForm", ignorePopups: true);

                    if (_device.ControlPanel.GetControls().Contains("m_RadioButton"))
                    {
                        //Using PressScreen since the small screen doesn't seem to like the mOKButton
                        _device.ControlPanel.PressScreen(250, 250);
                    }

                    auth.Authenticate();
                    break;

                case "Follow-You Printing":
                case "HP AC Secure Pull Print":
                case "My workflow (FutureSmart)":
                case "Pull Print":
                case "Scan To Me":
                case "Scan To My Files":
                case "Scan To Folder":
                case "Public Distributions":
                case "Routing Sheet":
                case "Personal Distributions":
                    _device.ControlPanel.ScrollPressWait("mAccessPointDisplay", "Title", appName, "SignInForm", StringMatch.StartsWith, TimeSpan.FromSeconds(60));
                    auth.Authenticate();
                    break;

                default:
                    AuthenticationHelper.LaunchApp(_device, appName, auth);
                    break;
                }
            }
            catch (Exception ex)
            {
                var    currentScreen = _device.ControlPanel.CurrentForm();
                string message       = $"Unable to authenticate.  Verify EWS authentication configuration and that {appName} button invokes the intended auth method. (current screen: {currentScreen}";
                ExecutionServices.SystemTrace.LogDebug(message + $"; Exception: {ex.Message}");
                throw new DeviceInvalidOperationException(message + ")", ex);
            }
        }
        /// <summary>
        /// Selects a control panel activity to run and calls the appropriate method to run it
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        private PluginExecutionResult RunControlPanelActivity(IDevice device)
        {
            UpdateStatus("Running Control Panel Activity...");
            PluginExecutionResult controlPanelActivityResult = new PluginExecutionResult(PluginResult.Failed);

            //Initializing the authenticator
            IAuthenticator authenticator = AuthenticatorFactory.Create(device, ExecutionData.Credential);

            authenticator.WorkflowLogger = WorkflowLogger;

            object controlPanelData = null;
            //Selecting a random control Panel activity.
            Type ControlPanelActivityToRun = SelectRandomActivity(_data.SelectedControlPanelActivities);

            Attribute[] attributes = Attribute.GetCustomAttributes(ControlPanelActivityToRun);
            foreach (Attribute attr in attributes)
            {
                if (attr is ControlPanelActivity)
                {
                    ControlPanelActivity controlPanelAttribute = (ControlPanelActivity)attr;
                    switch (controlPanelAttribute.ActivityName)
                    {
                    case "Copy":
                        //Copy activity is selected
                        UpdateStatus("Selected Control Panel Activity: Copy");
                        controlPanelData           = _data.SelectedControlPanelActivities.OfType <CopyActivityData>().Single();
                        controlPanelActivityResult = ExecuteCopy(device, controlPanelData, authenticator);
                        break;

                    case "Scan":
                        //Scan activity is selected
                        controlPanelData           = _data.SelectedControlPanelActivities.OfType <ScanActivityData>().Single();
                        controlPanelActivityResult = ExecuteScan(device, controlPanelData, authenticator);
                        break;

                    case "Fax":
                        //Fax activity is selected
                        UpdateStatus("Selected Control Panel Activity: Fax");
                        controlPanelData           = _data.SelectedControlPanelActivities.OfType <FaxActivityData>().Single();
                        controlPanelActivityResult = ExecuteFax(device, controlPanelData, authenticator);
                        break;
                    }
                }
            }

            return(controlPanelActivityResult);
        }
Example #9
0
        private void AuthenticateOmni(string deviceIP, string userName)
        {
            IDevice device = DeviceFactory.Create(deviceIP, "!QAZ2wsx");
            //AuthenticationCredential credential = new AuthenticationCredential(userName, "1qaz2wsx", "etl.boi.rd.hpicorp.net");
            AuthenticationCredential credential = new AuthenticationCredential("03000");

            JediOmniPreparationManager prepMgr = new JediOmniPreparationManager(((JediOmniDevice)device));
            JediOmniLaunchHelper       helper  = new JediOmniLaunchHelper((JediOmniDevice)device);

            // Set up the device for Authentication
            prepMgr.Reset();
            helper.PressSignInButton();

            IAuthenticator authenticator = AuthenticatorFactory.Create(device, credential, AuthenticationProvider.Auto);

            authenticator.Authenticate();
        }
        public static FacebookProfile GetAuthenticatedProfileForFacebook(HttpRequestBase request)
        {
            FacebookProfile result = new FacebookProfile();

            if (request.QueryString["code"] != null)
            {
                string code = request.QueryString["code"];

                if (!string.IsNullOrWhiteSpace(code))
                {
                    IAuthenticator <FacebookProfile> authenticator = AuthenticatorFactory.Create <FacebookAuthenticator>(code);
                    result = authenticator.Authenticate();
                }
            }

            return(result);
        }
Example #11
0
        /// <summary>
        /// Gets the authenticator for the given device and requested solution.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceInfo">Device information</param>
        /// <returns>IAuthenticator</returns>
        private IAuthenticator GetAuthenticator(IDevice device, IDeviceInfo deviceInfo)
        {
            AuthenticationCredential authCredential = null;

            if (_activityData.AuthProvider == AuthenticationProvider.Card || _activityData.AuthMethod.GetDescription().Contains("Badge"))
            {
                authCredential = new AuthenticationCredential(_executionData, deviceInfo.AssetId, deviceInfo.Address);
            }
            else
            {
                authCredential = new AuthenticationCredential(_executionData.Credential);
            }

            IAuthenticator auth = AuthenticatorFactory.Create(device, authCredential, _activityData.AuthProvider);

            auth.WorkflowLogger = _workflowLogger;
            return(auth);
        }
        public static LinkedInProfile GetAuthenticatedProfileForLinkedIn(HttpRequestBase request)
        {
            LinkedInProfile result = new LinkedInProfile();

            if (request.QueryString["oauth_verifier"] != null && request.QueryString["oauth_token"] != null)
            {
                string oauthVerifier = request.QueryString["oauth_verifier"];
                string oauthToken    = request.QueryString["oauth_token"];

                if (!string.IsNullOrEmpty(oauthToken) && !string.IsNullOrEmpty(oauthVerifier))
                {
                    IAuthenticator <LinkedInProfile> authenticator = AuthenticatorFactory.Create <LinkedInAuthenticator>(oauthToken);
                    result = authenticator.Authenticate();
                }
            }

            return(result);
        }
Example #13
0
        /// <summary>
        /// Do login for using Card(BadgeBox)
        /// </summary>
        /// <param name="executionData">The plugin execution data.</param>
        /// <returns></returns>
        public void RegusKioskCardAuthenticate(PluginExecutionData executionData)
        {
            IAuthenticator auth = null;

            // Gets the authenticator for the given device and requested solution.
            auth = AuthenticatorFactory.Create(DeviceInfo.AssetId, Device, AuthenticationProvider.Card, executionData);
            auth.WorkflowLogger = WorkflowLogger;
            try
            {
                RecordEvent(DeviceWorkflowMarker.AuthenticationBegin);
                auth.Authenticate();
            }
            catch (DeviceInvalidOperationException)
            {
                UpdateStatus($"Kiosk needs checking other way to verify login.\n ");
            }

            VerifyLogin(RegusKioskAuthType.Card, null);
        }
Example #14
0
        /// <summary>
        /// Initializes the authenticator.
        /// </summary>
        /// <param name="provider">The provider.</param>
        protected virtual void InitializeAuthenticator(AuthenticationProvider provider)
        {
            switch (provider)
            {
            case AuthenticationProvider.HpId:
                ExternalCredentialInfo   externalCredential = ExecutionData.ExternalCredentials.Where(x => x.Provider == ExternalCredentialType.HpId).FirstOrDefault();
                AuthenticationCredential authCredential     = new AuthenticationCredential(externalCredential.UserName, externalCredential.Password, ExecutionData.Credential.Domain);
                Authenticator = AuthenticatorFactory.Create(Device, authCredential, provider);
                break;

            default:
                Authenticator = AuthenticatorFactory.Create(DeviceInfo.AssetId, Device, provider, ExecutionData);
                break;
            }

            if (Authenticator != null)
            {
                Authenticator.WorkflowLogger = _workflowLogger;
            }
        }
Example #15
0
        /// <summary>
        /// Do login for using Card(BadgeBox)
        /// </summary>
        /// <param name="asset">The asset info for Card login.</param>
        /// <param name="credential">The credential info for Card login.</param>
        /// <returns>IAuthenticator</returns>
        public void KioskCardAuthenticate(Framework.Assets.AssetInfoCollection asset, System.Net.NetworkCredential credential)
        {
            IAuthenticator auth = null;

            // Gets the authenticator for the given device and requested solution.
            BadgeBoxInfo bbi = SetBadgeBox(asset, DeviceInfo);

            auth = AuthenticatorFactory.Create(Device, credential, bbi, AuthenticationProvider.Card);
            auth.WorkflowLogger = WorkflowLogger;
            try
            {
                RecordEvent(DeviceWorkflowMarker.AuthenticationBegin);
                auth.Authenticate();
            }
            catch (DeviceInvalidOperationException)
            {
                UpdateStatus($"Kiosk needs checking other way to verify login.\n ");
            }

            VerifyLogin(KioskAuthType.Card, null);
        }
        /// <summary>
        /// Execution Entry point
        /// Individual function differences separated into delagate methods.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="assetInfo"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool ExecuteJob(JediDevice device, AssetInfo assetInfo, Framework.Plugin.PluginExecutionData data)
        {
            ITraySettingsApp traySettingsApp = TraySettingsAppFactory.Create(device);

            try
            {
                NetworkCredential        cred    = new NetworkCredential("admin", device.AdminPassword);
                AuthenticationCredential auhcred = new AuthenticationCredential(cred);
                IAuthenticator           auth    = AuthenticatorFactory.Create(device, auhcred, AuthenticationProvider.Auto);
                if (CheckExecuteStatus(_traySettings))
                {
                    traySettingsApp.Launch(auth, AuthenticationMode.Lazy);
                    traySettingsApp.ManageTraySettings(this._traySettings);
                }
                return(true);
            }
            catch (Exception ex)
            {
                _failedSettings.AppendLine($"Failed to set field speed Dial: {ex.Message}");
                throw new DeviceWorkflowException("Manage Trays cannot be created.");
            }
        }
Example #17
0
        /// <summary>
        /// Execution Entry point
        /// Individual function differences separated into delagate methods.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="assetInfo"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool ExecuteJob(JediDevice device, AssetInfo assetInfo, Framework.Plugin.PluginExecutionData data)
        {
            IContactsApp contactsApp = ContactsAppFactory.Create(device);

            try
            {
                if (DisplayName.Value)
                {
                    NetworkCredential        cred    = new NetworkCredential("admin", device.AdminPassword);
                    AuthenticationCredential auhcred = new AuthenticationCredential(cred);
                    IAuthenticator           auth    = AuthenticatorFactory.Create(device, auhcred, AuthenticationProvider.Auto);
                    contactsApp.Launch(auth, AuthenticationMode.Lazy);
                    int speedDialNumber;
                    speedDialNumber = contactsApp.CreateSpeedDial(DisplayName.Key, SpeedDialNumber.Key, FaxNumbers.Key);
                }
            }
            catch (Exception ex)
            {
                _failedSettings.AppendLine($"Failed to set field speed Dial: {ex.Message}");
                throw new DeviceWorkflowException("Speed dial cannot be created.", ex);
            }
            return(true);
        }
Example #18
0
        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();
        }
Example #19
0
        private PluginExecutionResult RunApp(IDevice device)
        {
            try
            {
                PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed);

                _activityData = _executionData.GetMetadata <PrintFromUsbActivityData>();

                IUsbApp        usbApp = UsbAppFactory.Create(device);
                IAuthenticator auth   = AuthenticatorFactory.Create(device, _executionData.Credential, AuthenticationProvider.Auto);

                usbApp.WorkflowLogger = auth.WorkflowLogger = _workflowLogger;

                var preparationManager = DevicePreparationManagerFactory.Create(device);
                preparationManager.InitializeDevice(true);
                preparationManager.WorkflowLogger = _workflowLogger;

                // need to add the ability for user to set eager or lazy authentication
                //AuthenticationMode am = (_data.ApplicationAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

                usbApp.Pacekeeper = auth.Pacekeeper = new Pacekeeper(TimeSpan.FromSeconds(2));
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                usbApp.LaunchPrintFromUsb(auth, AuthenticationMode.Lazy);
                UpdateStatus("The Print From USB app is launched");

                usbApp.SelectUsbPrint(_activityData.UsbName);
                UpdateStatus("The USB is selected");

                usbApp.SelectFile();
                UpdateStatus("File to Print is selected");

                if (usbApp.ExecutePrintJob())
                {
                    UpdateStatus("The selected file is printed");
                    result = new PluginExecutionResult(PluginResult.Passed);
                }

                preparationManager.NavigateHome();
                if (preparationManager.SignOutRequired())
                {
                    preparationManager.SignOut();
                }
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.ActivityEnd);
                return(result);
            }
            catch (DeviceCommunicationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error."));
            }
            catch (DeviceInvalidOperationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error."));
            }
            catch (DeviceWorkflowException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error."));
            }
            catch (Exception ex)
            {
                GatherTriageData(device, ex.ToString());
                throw;
            }
        }
Example #20
0
 /// <summary>
 /// Initializes the authenticator that will be used in the run, including setting up the badgebox if needed.
 /// </summary>
 /// <param name="provider">The authentication provider to create</param>
 /// <param name="device">The device that will be used for the run.</param>
 /// <param name="executionData">This is to pass the credentials for authentication</param>
 protected void InitializeAuthenticator(AuthenticationProvider provider, IDevice device, PluginExecutionData executionData)
 {
     Authenticator = AuthenticatorFactory.Create(ScanLog.DeviceId, device, provider, executionData);
     Authenticator.WorkflowLogger = WorkflowLogger;
 }
 public static string GetUrlParametersUsing <TAuthenticator>(string token) where TAuthenticator : AuthenticatorBase, new()
 {
     return(AuthenticatorFactory.Create <TAuthenticator>(token).GetUrlParameters());
 }