private bool IsXsrfSafe(
			string cookie,
			string xsrfToken,
			IAccessToken accessToken,
			AuthenticationMode authMode
		) {

			if( authMode == AuthenticationMode.SkipXsrfValidation ) {
				return true;
			}

			bool isBrowserUser = !string.IsNullOrEmpty( cookie );
			if( !isBrowserUser ) {
				return true;
			}

			// we must now validate that the xsrf tokens match

			string xsrfTokenFromAccessToken = accessToken.GetXsrfToken();

			bool xsrfTokensEqual = xsrfTokenFromAccessToken == xsrfToken;
			bool xsrfTokenContainsValue = !string.IsNullOrEmpty( xsrfToken );

			if( !xsrfTokensEqual || !xsrfTokenContainsValue ) {
				return false;
			}

			return true;
		}
        public string BuildConnectionString(DatabaseEndpoint endpoint, AuthenticationMode authMode, string sqlLogin = null, string sqlPassword = null)
        {
            var connectionStringBuilder = new SqlConnectionStringBuilder
            {
                DataSource = endpoint.ServerName,
                ApplicationName = "Galen.Ci.EntityFramework"
            };

            if (authMode == AuthenticationMode.Integrated)
            {
                connectionStringBuilder.IntegratedSecurity = true;
            }
            else
            {
                connectionStringBuilder.UserID = sqlLogin;
                connectionStringBuilder.Password = sqlPassword;
            }

            if (!string.IsNullOrEmpty(endpoint.DatabaseName))
            {
                connectionStringBuilder.InitialCatalog = endpoint.DatabaseName;
            }

            return connectionStringBuilder.ConnectionString;
        }
		internal AuthConfig (object parent)
		{
			if (parent is AuthConfig) {
				has_parent = true;
				AuthConfig p = (AuthConfig) parent;
				mode = p.mode;
				cookieName = p.cookieName;
				cookiePath = p.cookiePath;
				loginUrl = p.loginUrl;
				protection = p.protection;
				timeout = p.timeout;
				pwdFormat = p.pwdFormat;
#if NET_1_1
				requireSSL = p.requireSSL;
				slidingExpiration = p.slidingExpiration;
#endif
#if NET_2_0
				cookie_domain = p.cookie_domain;
				cookie_mode = p.cookie_mode;
				cookies_supported = p.cookies_supported;
				default_url = p.default_url;
				enable_crossapp_redirects = p.enable_crossapp_redirects;
#endif
				credentialUsers = new Hashtable (p.CredentialUsers);
			}
		}
		private async Task<ID2LPrincipal> AuthenticateHelper(
			string cookie,
			string xsrfToken,
			string bearerToken,
			AuthenticationMode authMode
		) {
		
			bool cookieExists = !string.IsNullOrEmpty( cookie );
			bool bearerTokenExists = !string.IsNullOrEmpty( bearerToken );

			if( !cookieExists && !bearerTokenExists ) {
				return ANONYMOUS_PRINCIPAL;
			}

			string token = bearerTokenExists ? bearerToken : cookie;
			
			IAccessToken accessToken = await m_accessTokenValidator
				.ValidateAsync( token )
				.SafeAsync();

			// TODO .. we should consider doing the xsrf check without validating the jwt
			bool isXsrfSafe = IsXsrfSafe( cookie, xsrfToken, accessToken, authMode );
			if( !isXsrfSafe ) {
				throw new XsrfException( "Request is lacking XSRF protection" );
			}

			ID2LPrincipal principal = new D2LPrincipal( accessToken );

			return principal;
		}
Exemple #5
0
 /// <summary>
 /// Check the OpenID identity URL and confirm whether or not the authentication
 /// mode should be changed due to quirks in the OpenID Provider's implementation.
 /// </summary>
 /// <param name="endPoint">OpenID identity URL</param>
 /// <param name="mode">Mode currently set</param>
 /// <returns>Correct AuthenticationMode for the provider</returns>
 internal static AuthenticationMode CheckOpenIDMode(string endPoint, AuthenticationMode mode)
 {
     if (endPoint.ToUpperInvariant().Contains("://GETOPENID.COM/"))
     {
         return AuthenticationMode.Stateless;
     }
     return mode;
 }
 public Auth0JwtBearerAuthenticationOptions(string issuer = "https://login.auth0.com/", string clientId = null, string clientSecret = null, AuthenticationMode authenticationMode = AuthenticationMode.Active, string authenticationType = "Bearer")
     : base(authenticationType)
 {
     Issuer = issuer;
     Audience = clientId;
     SymmetricKey = clientSecret;
     AuthenticationMode = authenticationMode;
     AuthenticationType = authenticationType;
 }
 protected void ShowLoginScreen(AuthenticationMode authMode, string appSecret, string email, AuthValidationMode authValidationMode)
 {
     dynamic parms = new DynamicNavigationParameters();
     parms.authmode = authMode;
     parms.appsecret = appSecret;
     parms.email = email;
     parms.validationmode = authValidationMode;
     this.Frame.Navigate(typeof(LoginPage), parms);
 }
Exemple #8
0
 /// <summary>
 /// Find response sign-out details for a specific authentication middleware
 /// </summary>
 /// <param name="authenticationType">The authentication type to look for</param>
 /// <param name="authenticationMode">The authentication mode the middleware is running under</param>
 public static bool LookupSignOut(IEnumerable<string> authenticationTypes, string authenticationType, AuthenticationMode authenticationMode)
 {
     bool singOutHasAuthenticationTypes = authenticationTypes != null && authenticationTypes.Any();
     if (!singOutHasAuthenticationTypes)
     {
         return authenticationMode == AuthenticationMode.Active;
     }
     return authenticationTypes.Contains(authenticationType, StringComparer.Ordinal);
 }
 internal async void OnOpened(AuthenticationMode authmode, AuthValidationMode validationMode)
 {
     VM.IsBusy = true;
     if (await AuthManager.Current.CheckAndHandleExistingTokenAsync(authmode, validationMode))
     {
         this.CloseRequested(this, EventArgs.Empty);
     }
     VM.IsBusy = false;
 }
		Task<ID2LPrincipal> IRequestAuthenticator.AuthenticateAsync(
			HttpRequest request,
			AuthenticationMode authMode
		) {
			string cookie = request.GetCookieValue();
			string bearerToken = request.GetBearerTokenValue();
			string xsrfToken = request.GetXsrfValue();

			return AuthenticateHelper( cookie, xsrfToken, bearerToken, authMode );
		}
        /// <summary>
        /// Gets the <see cref="MobileAppAuthenticationOptions" /> that will be used by the <see cref="MobileAppAuthenticationHandler"/>./>
        /// </summary>
        /// <returns>The <see cref="MobileAppAuthenticationOptions" /> to use.</returns>
        private static MobileAppAuthenticationOptions GetMobileAppAuthenticationOptions(HttpConfiguration config, AuthenticationMode mode)
        {
            IMobileAppSettingsProvider settingsProvider = config.GetMobileAppSettingsProvider();
            MobileAppSettingsDictionary settings = settingsProvider.GetMobileAppSettings();

            MobileAppAuthenticationOptions serviceOptions = new MobileAppAuthenticationOptions
            {
                AuthenticationMode = mode,
                SigningKey = settings.SigningKey,
            };

            return serviceOptions;
        }
 public JwtTokenAuthenticationOptions(string issuer = null,
                                      string audience = null,
                                      string clientSecret = null,
                                      AuthenticationMode authenticationMode = AuthenticationMode.Active,
                                      string authenticationType = "Bearer")
     : base(authenticationType)
 {
     Issuer = issuer;
     Audience = audience;
     SymmetricKey = clientSecret;
     AuthenticationMode = authenticationMode;
     AuthenticationType = authenticationType;
 }
Exemple #13
0
        private bool IsCratePresents(ActivityDTO activityDTO, AuthenticationMode mode)
        {
            var result = false;

            foreach (var crate in activityDTO.CrateStorage.Crates)
            {
                if ((int)mode == crate.Contents["Mode"].ToObject <int>())
                {
                    result = true;
                    break;
                }
            }

            return(result);
        }
        protected void ShowLoginScreen(AuthenticationMode authMode, string appSecret, string email, AuthValidationMode authValidationMode)
        {
            var vm = new LoginVM();
            vm.AuthMode = authMode;
            vm.Email = email;
            vm.AppSecret = appSecret;

            var dialog = new LoginDialog();
            dialog.DataContext = vm;
            dialog.CloseRequested += Dialog_CloseRequested;
            authPopup = new Popup();
            authPopup.Child = dialog;
            authPopup.IsOpen = true;
            dialog.OnOpened(authMode, authValidationMode);
        }
Exemple #15
0
        internal static string ToSerializedValue(this AuthenticationMode value)
        {
            switch (value)
            {
            case AuthenticationMode.SharedKey:
                return("SharedKey");

            case AuthenticationMode.AAD:
                return("AAD");

            case AuthenticationMode.TaskAuthenticationToken:
                return("TaskAuthenticationToken");
            }
            return(null);
        }
        /// <summary>
        /// Launches the Print 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)
        {
            _launchHelper.WorkflowLogger = WorkflowLogger;

            bool appLoaded = false;

            if (authenticationMode == AuthenticationMode.Lazy)
            {
                bool signInScreenLoaded = PressPrintFromJobStorageButton("#hpid-signin-body");
                if (signInScreenLoaded)
                {
                    appLoaded = Authenticate(authenticator, "#hpid-print-job-storage-app-screen");
                }
                else if (_controlPanel.CheckState("#hpid-print-job-storage-app-screen", OmniElementState.Exists))
                {
                    // The application launched without prompting for credentials
                    appLoaded = true;
                    Pacekeeper.Reset();
                }
            }
            else
            {
                switch (authenticator.Provider)
                {
                case AuthenticationProvider.Card:
                case AuthenticationProvider.Skip:
                    break;

                default:
                    _launchHelper.PressSignInButton();
                    break;
                }

                Authenticate(authenticator, JediOmniLaunchHelper.SignInOrSignoutButton);
                appLoaded = PressPrintFromJobStorageButton("#hpid-print-job-storage-app-screen");
            }

            if (appLoaded)
            {
                RecordEvent(DeviceWorkflowMarker.AppShown);
            }
            else
            {
                throw new DeviceWorkflowException("Could not launch Print From Job Storage application.");
            }

            _fwVersionIndex = GetFwVersionIndex();
        }
Exemple #17
0
        /// <summary>
        /// Sets up the CloudConnector scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        protected override void SetupJob(IDevice device)
        {
            var devicePrepManager = DevicePreparationManagerFactory.Create(device);

            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            _UdocxScanApp = UdocxScanAppFactory.Create(device);
            _UdocxScanApp.WorkflowLogger = WorkflowLogger;
            devicePrepManager.Reset();
            InitializeAuthenticator(_activityData.AuthProvider, device, ExecutionData);
            AuthenticationMode am = (_activityData.UdocxScanAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

            Launch();
        }
Exemple #18
0
        private void InitializeUserIdentity(string username)
        {
            string             authenticationType;
            AuthenticationMode authenticationMode = ((AuthenticationSection)WebConfigurationManager.GetSection("system.web/authentication")).Mode;

            switch (authenticationMode)
            {
            case AuthenticationMode.Forms:
                authenticationType = authenticationMode.ToString();
                break;

            default:
                throw new UnsupportedAuthenticationType();
            }
            identity = new GenericIdentity(username, authenticationType);
        }
 /// <summary>
 /// Opens Contacts screen with the specified authenticator using the given 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))
     {
         if (PressContactsHomescreenButton())
         {
             // sign in form is present
             Authenticate(authenticator, "#hpid-contacts-app-screen");
         }
     }
     else
     {
         throw new NotImplementedException("Eager authentication has not been implemented for this solution.");
     }
     RecordEvent(DeviceWorkflowMarker.AppShown);
 }
Exemple #20
0
        /// <summary>
        /// Sets up the scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <exception cref="ArgumentNullException">device</exception>
        protected override void SetupJob(IDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            AuthenticationMode am = (_activityData.AutoStoreAuthentication == true) ? AuthenticationMode.Lazy : AuthenticationMode.Eager;

            ScanLog.ScanType = _activityData.AutoStoreScanButton;
            InitializeAuthenticator(_activityData.AuthProvider, device);
            UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}");

            _autoStoreApplication = GetApp(device);
            _autoStoreApplication.Launch(Authenticator, am);
        }
        /// <summary>Launch the solution.</summary>
        private void Launch()
        {
            AuthenticationMode am = (_activityData.HPRoamAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

            if (am.Equals(AuthenticationMode.Eager))
            {
                OnStatusUpdate("Authenticating by pressing the Sign In button first.");
            }
            else // AuthenticationMode.Lazy
            {
                OnStatusUpdate("Authenticating by pressing the Hp Roam Button first.");
            }

            _hpRoamApp.Launch(Authenticator, am);
            OnStatusUpdate("Authentication complete.");
        }
Exemple #22
0
        private bool SanityCheckPassphrase(string passphrase, AuthenticationMode mode, WEPStatus encryption)
        {
            if (encryption == WEPStatus.WEPEnabled)
            {
                // A WEP key can be 10, 26 or 32 hex digits OR 5, 13, or 16 ascii characters
                switch (passphrase.Length)
                {
                // HEX
                case 10:
                case 26:
                case 32:
                    try
                    {
                        for (int i = 0; i < passphrase.Length; i += 2)
                        {
                            var test = int.Parse(passphrase.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
                        }
                    }
                    catch
                    {
                        return(false);
                    }

                    return(true);

                // ASCII
                case 5:
                case 13:
                case 16:
                    return(true);

                default:
                    return(false);
                }
            }

            if ((encryption == WEPStatus.AESEnabled) || (encryption == WEPStatus.TKIPEnabled))
            {
                // The encryption key for WPA-PSK/TKIP must be between 8 and 63 characters
                if ((passphrase.Length < 8) || (passphrase.Length > 63))
                {
                    return(false);
                }
            }

            return(true);
        }
 public CommonModule(
     string productInfo,
     string iothubHostName,
     string edgeDeviceId,
     string edgeHubModuleId,
     string edgeDeviceHostName,
     Option <string> edgeHubGenerationId,
     AuthenticationMode authenticationMode,
     Option <string> edgeHubConnectionString,
     bool optimizeForPerformance,
     bool usePersistentStorage,
     string storagePath,
     Option <string> workloadUri,
     Option <string> workloadApiVersion,
     TimeSpan scopeCacheRefreshRate,
     bool persistTokens,
     IList <X509Certificate2> trustBundle,
     string proxy,
     MetricsConfig metricsConfig,
     bool useBackupAndRestore,
     Option <string> storageBackupPath,
     Option <ulong> storageMaxTotalWalSize,
     Option <StorageLogLevel> storageLogLevel)
 {
     this.productInfo             = productInfo;
     this.iothubHostName          = Preconditions.CheckNonWhiteSpace(iothubHostName, nameof(iothubHostName));
     this.edgeDeviceId            = Preconditions.CheckNonWhiteSpace(edgeDeviceId, nameof(edgeDeviceId));
     this.edgeHubModuleId         = Preconditions.CheckNonWhiteSpace(edgeHubModuleId, nameof(edgeHubModuleId));
     this.edgeDeviceHostName      = Preconditions.CheckNotNull(edgeDeviceHostName, nameof(edgeDeviceHostName));
     this.edgeHubGenerationId     = edgeHubGenerationId;
     this.authenticationMode      = authenticationMode;
     this.edgeHubConnectionString = edgeHubConnectionString;
     this.optimizeForPerformance  = optimizeForPerformance;
     this.usePersistentStorage    = usePersistentStorage;
     this.storagePath             = storagePath;
     this.scopeCacheRefreshRate   = scopeCacheRefreshRate;
     this.workloadUri             = workloadUri;
     this.workloadApiVersion      = workloadApiVersion;
     this.persistTokens           = persistTokens;
     this.trustBundle             = Preconditions.CheckNotNull(trustBundle, nameof(trustBundle));
     this.proxy                  = Preconditions.CheckNotNull(proxy, nameof(proxy));
     this.metricsConfig          = Preconditions.CheckNotNull(metricsConfig, nameof(metricsConfig));
     this.useBackupAndRestore    = useBackupAndRestore;
     this.storageBackupPath      = storageBackupPath;
     this.storageMaxTotalWalSize = storageMaxTotalWalSize;
     this.storageLogLevel        = storageLogLevel;
 }
Exemple #24
0
        public Authentication(HttpRequest httpRequest, IAuthenticationModes iAuthenticationMode)
        {
            if (iAuthenticationMode is BasicAuth basicAuth)
            {
                string basicrheader = httpRequest.Headers["Authorization"];
                if (basicrheader == null)
                {
                    throw new HttpException(401, "no authorization");
                }
                if (!basicrheader.StartsWith("Basic "))
                {
                    throw new HttpException(401, "not a basic authorization");
                }

                var    encoding    = Encoding.GetEncoding("iso-8859-1");
                string credentials = encoding.GetString(Convert.FromBase64String(basicrheader.Substring(6)));
                if (credentials != string.Format("{0}:{1}", basicAuth.Username, basicAuth.Password))
                {
                    throw new HttpException(401, "invalid token");
                }
                authenticationMode = AuthenticationMode.BasicAuth;
                return; // call is authenticated
            }
            if (iAuthenticationMode is HTTPHeader httpHeader)
            {
                string bearerheader = httpRequest.Headers["Authorization"];
                if (bearerheader == null)
                {
                    throw new HttpException(401, "no authorization");
                }
                if (!bearerheader.StartsWith("Bearer "))
                {
                    throw new HttpException(401, "not a bearer authorization");
                }
                if (bearerheader != "Bearer " + httpHeader.Token)
                {
                    throw new HttpException(401, "invalid token");
                }
                authenticationMode = AuthenticationMode.HTTPHeader;
                return; // call is authenticated
            }
            if (iAuthenticationMode is OAUth2)
            {
                //_authenticationMode = AuthenticationMode.OAuth2;
                throw new Exception("OAuth authentication is not yet implemented");
            }
        }
        public void MSAUTHWS_S04_TC01_VerifyLoginUnderPassportAuthentication()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(132, this.Site), "This case runs only when the requirement 132 is enabled.");

            // Invoke Mode operation.
            AuthenticationMode authMode = this.authwsAdapter.Mode();

            bool isVerifyPassportMode = AuthenticationMode.Passport == authMode;

            Site.Assume.IsTrue(isVerifyPassportMode, string.Format("The expected result of Mode is Passport, the actual result is{0}", authMode.ToString()));

            // Invoke Login operation.
            LoginResult loginResult = this.authwsAdapter.Login(this.validUserName, this.validPassword);

            Site.Assert.IsNotNull(loginResult, "Login result is not null");
            Site.Assert.IsNull(loginResult.CookieName, "The cookie name is null");
        }
        /// <summary>
        /// USFT API CLient
        /// </summary>
        /// <param name="username">Username to access api</param>
        /// <param name="apiKey">Api key for user</param>
        public UsftClient(string username, string apiKey, AuthenticationMode authMode = AuthenticationMode.USFT)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new Exception("Username required.");
            }

            if (string.IsNullOrWhiteSpace(apiKey))
            {
                throw new Exception("ApiKey required.");
            }

            Username       = username.Trim();
            ApiKey         = apiKey.Trim();
            Authentication = authMode;
            SetUriBase(uriBase_default);
        }
        protected void ShowLoginScreen(AuthenticationMode authMode, string appSecret, string email, AuthValidationMode authValidationMode)
        {
            var vm = new LoginVM();

            vm.AuthMode  = authMode;
            vm.Email     = email;
            vm.AppSecret = appSecret;

            var dialog = new LoginDialog();

            dialog.DataContext     = vm;
            dialog.CloseRequested += Dialog_CloseRequested;
            authPopup              = new Popup();
            authPopup.Child        = dialog;
            authPopup.IsOpen       = true;
            dialog.OnOpened(authMode, authValidationMode);
        }
Exemple #28
0
        internal CWSClient(
            string username,
            string password,
            string serviceRoot,
            string serviceSuffix,
            string rcsAuthServiceURL,
            AuthenticationMode authMode)
        {
            fUsername          = username;
            fPassword          = password;
            fServiceRoot       = serviceRoot;
            fServiceSuffix     = serviceSuffix;
            fRCSAuthServiceURL = rcsAuthServiceURL;
            fAuthMode          = authMode;

            Authenticate();
        }
        public static bool IsDefaultCreditals(this AuthenticationMode authMode)
        {
            switch (authMode)
            {
            case AuthenticationMode.KerberosDefaultCreditals:
            case AuthenticationMode.KerberosNtlmDefaultCreditals:
            case AuthenticationMode.NtlmDefaultCreditals:
                return(true);

            case AuthenticationMode.NtlmCustomCreditals:
            case AuthenticationMode.NtlmDigestCustomCreditals:
            case AuthenticationMode.DigestCustomCreditals:
                return(false);
            }

            throw new Exception(@"AuthenticationMode");
        }
 /// <summary>
 /// Launches the Copy application using the specified authenticator, authentication mode, and quickset.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="authenticationMode">The authentication mode.</param>
 /// <param name="quickSetName">Name of the quick set.</param>
 /// <exception cref="DeviceWorkflowException">Not supported in Jedi Windjammer device</exception>
 public void LaunchFromQuickSet(IAuthenticator authenticator, AuthenticationMode authenticationMode, string quickSetName)
 {
     if (authenticationMode.Equals(AuthenticationMode.Lazy))
     {
         if (PressScanToEmailQuickSet(quickSetName))
         {
             Authenticate(authenticator, "EmailForm");
         }
     }
     else  // AuthenticationMode.Eager
     {
         RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
         _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
         Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);
         PressScanToEmailQuickSet(quickSetName);
     }
 }
    /// <summary>
    /// Page load event.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        var enabled = SecurityHelper.IsScreenLockEnabled(SiteContext.CurrentSiteName);

        Visible = enabled;

        if (!enabled)
        {
            return;
        }

        // Set title text and image
        screenLockTitle.TitleText = GetString("settingscategory.cmsscreenlock");
        lblInstructions.Text      = GetString("screenlock.instruction");

        var user = GetUserForAuthentication();

        txtUserName.Text = user.UserName;

        // Set account locked information
        if (AuthenticationHelper.DisplayAccountLockInformation(SiteContext.CurrentSiteName))
        {
            lblScreenLockWarningLogonAttempts.Text = GetString("invalidlogonattempts.unlockaccount.accountlocked");
        }
        else
        {
            lblScreenLockWarningLogonAttempts.Text = GetString("screenlock.loginfailure");
        }

        lblScreenLockWarningLogonAttempts.Text += " " + GetString("screenlock.loggedout");

        // Hide password field for Active directory users when Windows authentication is used
        if (user.UserIsDomain && AuthenticationMode.IsWindowsAuthentication())
        {
            lblPassword.Visible = false;
            txtScreenLockDialogPassword.Visible = false;
            btnScreenLockSignOut.Visible        = false;
        }
        else
        {
            lblInstructions.Text += " " + GetString("screenlock.instruction.part2");
        }

        ScriptHelper.RegisterJQueryDialog(Page);
    }
        /// <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="DeviceWorkflowException">
        /// Network Folder button was not found on device home screen.
        /// or
        /// or
        /// </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.Press("home_screen_table_menu.2");
                    _controlPanel.WaitForActiveScreenLabel("view_scan_home", TimeSpan.FromSeconds(10)); //Scan To Page
                    Pacekeeper.Sync();

                    RecordEvent(DeviceWorkflowMarker.AppButtonPress, "NetworkFolder");
                    _controlPanel.Press("scan_home_screen_table_menu.2");
                    Pacekeeper.Sync();

                    if (_controlPanel.ActiveScreenLabel() != "view_scan_folder_presets")
                    {
                        authenticator.Authenticate();
                    }

                    _controlPanel.WaitForActiveScreenLabel("view_scan_folder_presets", TimeSpan.FromSeconds(30)); //Network folder page
                    RecordEvent(DeviceWorkflowMarker.AppShown);
                    Pacekeeper.Sync();
                }
                catch (ElementNotFoundException ex)
                {
                    string currentScreen = _controlPanel.ActiveScreenLabel();
                    if (currentScreen == "view_scan_home")
                    {
                        throw new DeviceWorkflowException("Network Folder button was not found on device home screen.", ex);
                    }
                    else
                    {
                        throw new DeviceWorkflowException($"Cannot launch the Network Folder application from {currentScreen}.", ex);
                    }
                }
                catch (SiriusInvalidOperationException ex)
                {
                    throw new DeviceWorkflowException($"Could not launch Network Folder application: {ex.Message}", ex);
                }
            }
            else
            {
                throw new NotImplementedException("Eager authentication has not been implemented for this solution.");
            }
        }
        public static IAppBuilder UseAppServiceAuthentication(this IAppBuilder appBuilder, HttpConfiguration config, AppServiceAuthenticationMode appServiceAuthMode, AuthenticationMode mode = AuthenticationMode.Active)
        {
            if (appBuilder == null)
            {
                throw new ArgumentNullException("appBuilder");
            }

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            MobileAppAuthenticationOptions serviceOptions = GetMobileAppAuthenticationOptions(config, mode);
            IMobileAppTokenHandler tokenHandler = config.GetMobileAppTokenHandler();
            appBuilder.UseAppServiceAuthentication(config, appServiceAuthMode, serviceOptions, tokenHandler);

            return appBuilder;
        }
 /// <summary>
 /// Launches the Copy application using the specified authenticator, authentication mode, and quickset.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="authenticationMode">The authentication mode.</param>
 /// <param name="quickSetName">Name of the quick set.</param>
 public void LaunchFromQuickSet(IAuthenticator authenticator, AuthenticationMode authenticationMode, string quickSetName)
 {
     if (authenticationMode.Equals(AuthenticationMode.Eager))
     {
         RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
         _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
         Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);
         PressCopyWithQuickset(quickSetName);
     }
     else // AuthenticationMode.Lazy
     {
         if (PressCopyWithQuickset(quickSetName))
         {
             // authentication required
             Authenticate(authenticator, "CopyAppMainForm");
         }
     }
 }
Exemple #35
0
 /// <summary>
 /// Launches the FAX solution with the specified authenticator using the given authentication mode.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="authenticationMode">The authentication mode.</param>
 /// <exception cref="DeviceWorkflowException">Fax application button was not found on device home screen.</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))
     {
         if (PressFaxSolutionButton("SignInForm"))
         {
             Authenticate(authenticator);
         }
     }
     else
     {
         RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
         _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
         Authenticate(authenticator);
         PressFaxSolutionButton("SendFaxAppMainForm");
     }
     RecordEvent(DeviceWorkflowMarker.AppShown);
 }
 /// <summary>
 /// Launches the FAX solution with the specified authenticator using the given authentication mode.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="authenticationMode">The authentication mode.</param>
 /// <exception cref="DeviceWorkflowException"></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
         {
             _executionManager.PressApplicationButton(_executionManager.FaxButton);
         }
         catch (PhoenixInvalidOperationException ex)
         {
             throw new DeviceWorkflowException($"Could not launch Copy application: {ex.Message}", ex);
         }
     }
     else
     {
         throw new NotImplementedException("Eager authentication has not been implemented for this solution.");
     }
 }
Exemple #37
0
 /// <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="System.NotImplementedException"></exception>
 public void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode)
 {
     if (authenticationMode.Equals(AuthenticationMode.Lazy))
     {
         if (PressScanToNetworkFolderButton("SignInForm"))
         {
             Authenticate(authenticator, "FolderAppMainForm");
         }
     }
     else // AuthenticationMode.Eager
     {
         RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
         _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
         Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);
         PressScanToNetworkFolderButton("FolderAppMainForm");
     }
     RecordEvent(DeviceWorkflowMarker.AppShown);
 }
 /// <summary>
 /// Launches the Copy application using the specified authenticator and authentication mode.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="authenticationMode">The authentication mode.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 public void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode)
 {
     if (authenticationMode.Equals(AuthenticationMode.Lazy))
     {
         if (PressScanToEmailButton("SignInForm", TimeSpan.FromSeconds(6)))
         {
             Authenticate(authenticator, "EmailForm");
         }
     }
     else  // AuthenticationMode.Eager
     {
         RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
         _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
         Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);
         PressScanToEmailButton("EmailForm", TimeSpan.FromSeconds(3));
     }
     RecordEvent(DeviceWorkflowMarker.AppShown);
 }
Exemple #39
0
        /// <summary>
        /// Launches Blueprint with the specified authenticator using the given authentication mode
        /// </summary>
        /// <param name="authenticator">The authenticator.</param>
        /// <param name="authenticationMode">The authentication mode, eager or lazy.</param>
        public override void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode)
        {
            if (authenticationMode.Equals(AuthenticationMode.Eager))
            {
                RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
                _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
                Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);

                RecordEvent(DeviceWorkflowMarker.AppButtonPress, SolutionButtonTitle);
                _controlPanel.ScrollPressWait("mAccessPointDisplay", "Title", SolutionButtonTitle, JediWindjammerLaunchHelper.OxpdFormIdentifier, StringMatch.Contains, TimeSpan.FromSeconds(30));
            }
            else // AuthenticationMode.Lazy
            {
                RecordEvent(DeviceWorkflowMarker.AppButtonPress, SolutionButtonTitle);
                _controlPanel.ScrollPressWait("mAccessPointDisplay", "Title", SolutionButtonTitle, JediWindjammerLaunchHelper.SIGNIN_FORM, TimeSpan.FromSeconds(30));
                Authenticate(authenticator, JediWindjammerLaunchHelper.OxpdFormIdentifier);
            }
        }
        /// <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>
        /// <exception cref="System.NotImplementedException"></exception>
        public void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode)
        {
            if (authenticationMode.Equals(AuthenticationMode.Lazy))
            {
                try
                {
                    _controlPanel.Press("home_screen_table_menu.2");
                    _controlPanel.WaitForActiveScreenLabel("view_scan_home", TimeSpan.FromSeconds(10)); //Scan To Page
                    Pacekeeper.Sync();

                    RecordEvent(DeviceWorkflowMarker.AppButtonPress);
                    _controlPanel.Press("scan_home_screen_table_menu.3");
                    Pacekeeper.Sync();

                    if (_controlPanel.ActiveScreenLabel() != "view_scan_email_job_menu_home")
                    {
                        authenticator.Authenticate();
                    }
                    _controlPanel.WaitForActiveScreenLabel("view_scan_email_job_menu_home", TimeSpan.FromSeconds(30)); //Email Form
                    RecordEvent(DeviceWorkflowMarker.AppShown);
                    Pacekeeper.Sync();
                }
                catch (ElementNotFoundException ex)
                {
                    string currentForm = _controlPanel.ActiveScreenLabel();
                    if (currentForm == "view_scan_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)
                {
                    throw new DeviceWorkflowException($"Could not launch Email application: {ex.Message}", ex);
                }
            }
            else // AuthenticationMode.Eager
            {
                throw new NotImplementedException("Eager Authentication has not been implemented in SiriusUIv2EmailApp.");
            }
        }
 public void UpdateAuthentication(IDisqusAuthentication authentication)
 {
     if (String.IsNullOrEmpty(authentication.AuthenticationToken))
     {
         AuthMode = AuthenticationMode.None;
     }
     else if (authentication.AuthenticationToken == "self")
     {
         AuthMode = AuthenticationMode.Self;
     }
     else if (authentication.AuthenticationToken == "mod")
     {
         AuthMode = AuthenticationMode.Moderator;
     }
     else
     {
         AuthMode = AuthenticationMode.Authenticated;
     }
 }
Exemple #42
0
 /// <summary>
 /// Launches the Print to USB application using the specified authenticator and authentication mode.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="authenticationMode">The authentication mode.</param>
 public void LaunchPrintFromUsb(IAuthenticator authenticator, AuthenticationMode authenticationMode)
 {
     if (authenticationMode.Equals(AuthenticationMode.Eager))
     {
         RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
         _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
         Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);
         PressRetrieveFromUsbButton("OpenFromUsbMainForm");
     }
     else // AuthenticationMode.Lazy
     {
         if (PressRetrieveFromUsbButton("SignInForm"))
         {
             // authentication required
             Authenticate(authenticator, "OpenFromUsbMainForm");
         }
     }
     RecordEvent(DeviceWorkflowMarker.AppShown);
 }
Exemple #43
0
 /// <summary>
 /// Launches the Scan to USB application using the specified authenticator and authentication mode.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 /// <param name="authenticationMode">The authentication mode.</param>
 public void LaunchScanToUsb(IAuthenticator authenticator, AuthenticationMode authenticationMode)
 {
     if (authenticationMode.Equals(AuthenticationMode.Eager))
     {
         RecordEvent(DeviceWorkflowMarker.DeviceButtonPress, "Sign In");
         _controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);
         Authenticate(authenticator, JediWindjammerLaunchHelper.HOMESCREEN_FORM);
         PressSaveToUsbButton();
     }
     else // AuthenticationMode.Lazy
     {
         if (PressSaveToUsbButton())
         {
             // authentication required
             Authenticate(authenticator, SAVE_TO_USB_FORM);
         }
     }
     RecordEvent(DeviceWorkflowMarker.AppShown);
 }
		internal AuthConfig (object parent)
		{
			if (parent is AuthConfig) {
				has_parent = true;
				AuthConfig p = (AuthConfig) parent;
				mode = p.mode;
				cookieName = p.cookieName;
				cookiePath = p.cookiePath;
				loginUrl = p.loginUrl;
				protection = p.protection;
				timeout = p.timeout;
				pwdFormat = p.pwdFormat;
#if NET_1_1
				requireSSL = p.requireSSL;
				slidingExpiration = p.slidingExpiration;
#endif
				credentialUsers = new Hashtable (p.CredentialUsers);
			}
		}
Exemple #45
0
 /// <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="DeviceWorkflowException"></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
         {
             _executionManager.PressApplicationButton(_executionManager.ScanButton);
             _executionManager.PressSolutionButton("Scan Menu", "cScanToNetworkFolder");
         }
         catch (PhoenixInvalidOperationException ex)
         {
             throw new DeviceWorkflowException($"Could not launch Select network folder page: {ex.Message}", ex);
         }
     }
     else
     {
         throw new NotImplementedException("Eager authentication has not been implemented for this solution.");
     }
 }
 public static bool IsDefined(AuthenticationMode value)
 {
     return value == AuthenticationMode.AnonymousForCertificate
     || value == AuthenticationMode.AnonymousForSslNegotiated
     || value == AuthenticationMode.CertificateOverTransport
     || value == AuthenticationMode.IssuedToken
     || value == AuthenticationMode.IssuedTokenForCertificate
     || value == AuthenticationMode.IssuedTokenForSslNegotiated
     || value == AuthenticationMode.IssuedTokenOverTransport
     || value == AuthenticationMode.Kerberos
     || value == AuthenticationMode.KerberosOverTransport
     || value == AuthenticationMode.MutualCertificate
     || value == AuthenticationMode.MutualCertificateDuplex
     || value == AuthenticationMode.MutualSslNegotiated
     || value == AuthenticationMode.SecureConversation
     || value == AuthenticationMode.SspiNegotiated
     || value == AuthenticationMode.UserNameForCertificate
     || value == AuthenticationMode.UserNameForSslNegotiated
     || value == AuthenticationMode.UserNameOverTransport
     || value == AuthenticationMode.SspiNegotiatedOverTransport;
 }
Exemple #47
0
        /// <summary>
        /// Find response challenge details for a specific authentication middleware
        /// </summary>
        /// <param name="authenticationType">The authentication type to look for</param>
        /// <param name="authenticationMode">The authentication mode the middleware is running under</param>
        /// <returns>The information instructing the middleware how it should behave</returns>
        public AuthenticationResponseChallenge LookupChallenge(string authenticationType, AuthenticationMode authenticationMode)
        {
            if (authenticationType == null)
            {
                throw new ArgumentNullException("authenticationType");
            }

            AuthenticationResponseChallenge challenge = _response.AuthenticationResponseChallenge;
            bool challengeHasAuthenticationTypes = challenge != null && challenge.AuthenticationTypes != null && challenge.AuthenticationTypes.Length != 0;
            if (challengeHasAuthenticationTypes == false)
            {
                return authenticationMode == AuthenticationMode.Active ? (challenge ?? new AuthenticationResponseChallenge(null, null)) : null;
            }
            foreach (var challengeType in challenge.AuthenticationTypes)
            {
                if (string.Equals(challengeType, authenticationType, StringComparison.Ordinal))
                {
                    return challenge;
                }
            }
            return null;
        }
 protected HttpWebRequest SetupWebRequest(Options o, string url,
     AuthenticationMode validCredentials = AuthenticationMode.UseValidCredentials)
 {
     var request = (HttpWebRequest) WebRequest.Create(url);
     request.Method = "GET";
     request.Accept = "application/json";
     if (!String.IsNullOrEmpty(o.ApiKey) && validCredentials != AuthenticationMode.UseNoCredentials)
     {
         string headerName = !String.IsNullOrEmpty(o.ApiKeyHeader)
             ? o.ApiKeyHeader
             : Options.DefaultApiKeyHeaderName;
         request.Headers.Add(headerName,
             validCredentials == AuthenticationMode.UseValidCredentials ? o.ApiKey : Options.InvalidApiKey);
     }
     if (!String.IsNullOrEmpty(o.User) && validCredentials != AuthenticationMode.UseNoCredentials)
     {
         request.Credentials = validCredentials == AuthenticationMode.UseValidCredentials
             ? new NetworkCredential(o.User, o.Pass)
             : new NetworkCredential(Options.InvalidUserName, Options.InvalidPassword);
     }
     return request;
 }
        /// <summary>
        /// Creates the client.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="authenticationMode">The authentication mode.</param>
        /// <returns></returns>
        public static LocatorHub.LocatorHub CreateClient(string url, string username, string password, AuthenticationMode authenticationMode, string tokenUrl)
        {
            LocatorHub.LocatorHub client = new LocatorHub.LocatorHub();
            string locatorUrl  = url;

            if (locatorUrl.StartsWith("DATAHUB:"))
            {
                locatorUrl = locatorUrl.Replace("DATAHUB:", "");
                string token = LocatorManager.GetToken(LocatorManager.GetTokenUrlFromLocatorUrl(locatorUrl), DataHubConfiguration.Current.UserName, DataHubConfiguration.Current.Password);
                locatorUrl = String.Format("{0}?Token={1}", locatorUrl, token);
            }
            else
            {
                switch (authenticationMode)
                {

                    case AuthenticationMode.Token:
                        string locatorTokenURl = tokenUrl;
                        if (String.IsNullOrEmpty(locatorTokenURl))
                        {
                            locatorTokenURl = LocatorManager.GetTokenUrlFromLocatorUrl(url);
                        }
                        string token = LocatorManager.GetToken(locatorTokenURl, username, password);
                        locatorUrl = String.Format("{0}?Token={1}", url, token);
                        break;
                    case AuthenticationMode.Windows:
                        client.Credentials = new NetworkCredential(username, password);
                        break;
                    case AuthenticationMode.CurrentWindows:
                        client.Credentials = CredentialCache.DefaultNetworkCredentials;
                        break;
                }
            }

            client.Url = locatorUrl;

            return client;
        }
        protected WebClientEx SetupWebClient(Options o,
            AuthenticationMode validCredentials = AuthenticationMode.UseValidCredentials)
        {
            var c = new WebClientEx();
            c.Headers.Add(HttpRequestHeader.Accept, "application/json");

            if (!String.IsNullOrEmpty(o.ApiKey) && validCredentials != AuthenticationMode.UseNoCredentials)
            {
                string headerName = !String.IsNullOrEmpty(o.ApiKeyHeader)
                    ? o.ApiKeyHeader
                    : Options.DefaultApiKeyHeaderName;
                c.Headers.Add(headerName,
                    validCredentials == AuthenticationMode.UseValidCredentials ? o.ApiKey : Options.InvalidApiKey);
            }
            if (!String.IsNullOrEmpty(o.User) && validCredentials != AuthenticationMode.UseNoCredentials)
            {
                c.Credentials = validCredentials == AuthenticationMode.UseValidCredentials
                    ? new NetworkCredential(o.User, o.Pass)
                    : new NetworkCredential(Options.InvalidUserName, Options.InvalidPassword);
            }

            return c;
        }
		private async Task RunTest(
			string request_xsrfHeader,
			string request_d2lApiCookie,
			string request_authorizationHeader,
			string accessToken_xsrfClaim,
			AuthenticationMode authMode,
			Type expectedExceptionType = null,
			PrincipalType? expected_principalType = null
		) {

			IAccessToken token = AccessTokenMock.Create(
				xsrfClaim: accessToken_xsrfClaim
			).Object;

			IAccessTokenValidator tokenValidator = AccessTokenValidatorMock.Create(
				accessToken: ACCESS_TOKEN,
				accessTokenAfterValidation: token,
				expectedExceptionType: expectedExceptionType
			).Object;

			IRequestAuthenticator authenticator = new RequestAuthenticator( tokenValidator );

			var httpRequestMessage = new HttpRequestMessage()
				.WithAuthHeader( request_authorizationHeader )
				.WithXsrfHeader( request_xsrfHeader )
				.WithCookie( RequestValidationConstants.D2L_AUTH_COOKIE_NAME, request_d2lApiCookie );

			ID2LPrincipal principal = null;
			Exception exception = null;
			try {
				principal = await authenticator.AuthenticateAsync(
					httpRequestMessage,
					authMode: authMode
					).SafeAsync();
			} catch( Exception e ) {
				exception = e;
			}
			
			CheckExpectations(
				principal,
				exception,
				expectedExceptionType,
				expected_principalType );

			exception = null;

			HttpRequest httpRequest = RequestBuilder.Create()
				.WithAuthHeader( request_authorizationHeader )
				.WithXsrfHeader( request_xsrfHeader )
				.WithCookie( RequestValidationConstants.D2L_AUTH_COOKIE_NAME, request_d2lApiCookie );

			try {
				principal = await authenticator.AuthenticateAsync(
					httpRequest,
					authMode: authMode
					).SafeAsync();
			} catch( Exception e ) {
				exception = e;
			}
			
			CheckExpectations(
				principal,
				exception,
				expectedExceptionType,
				expected_principalType );
		}
Exemple #52
0
			/// <summary>
			/// Creates an instance of a user defined in the security database.
			/// </summary>
			/// <param name="username">Username of the user.</param>
			/// <param name="password">Password of the user.</param>
			/// <param name="applicationName">Name of the application for which user data is to be retrieved.</param>
			/// <param name="securityServer">Security server from which user data is to be retrieved.</param>
			/// <param name="authenticationMode">Mode of authentication to be used for authenticating credentials.</param>
			public User(string username, string password, string applicationName, SecurityServer securityServer, AuthenticationMode authenticationMode) : this(username, password, applicationName, securityServer, authenticationMode, true)
			{
				
				
			}
Exemple #53
0
			/// <summary>
			/// Creates an instance of a user defined in the security database.
			/// </summary>
			/// <param name="username">Username of the user.</param>
			/// <param name="password">Password of the user.</param>
			/// <param name="applicationName">Name of the application for which user data is to be retrieved.</param>
			/// <param name="securityServer">Security server from which user data is to be retrieved.</param>
			/// <param name="authenticationMode">Mode of authentication to be used for authenticating credentials.</param>
			/// <param name="authenticate">True if user credentials are to be authenticated; otherwise False.</param>
			/// <remarks>
			/// This constructor is only to be used internally by the security provider control and its sub-components.
			/// </remarks>
			internal User(string username, string password, string applicationName, SecurityServer securityServer, AuthenticationMode authenticationMode, bool authenticate)
			{
				
				m_username = username;
				m_password = password;
				m_applicationName = applicationName;
				m_securityServer = securityServer;
				m_authenticationMode = authenticationMode;
				m_groups = new List<Group>();
				m_roles = new List<Role>();
				m_applications = new List<Application>();
				
				this.RefreshData(); // Retrieve user data.
				if (authenticate)
				{
					this.Authenticate(password); // Authenticate user crendentials.
				}
				else
				{
					m_isAuthenticated = true; // Pretend user credentials are authenticated.
				}
				
			}
        protected void AddBindingTemplate(Dictionary<AuthenticationMode, SecurityBindingElement> bindingTemplates, AuthenticationMode mode)
        {
            this.AuthenticationMode = mode;
            try
            {
                bindingTemplates[mode] = (SecurityBindingElement)this.CreateBindingElement(true);
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
            }
        }
Exemple #55
0
			/// <summary>
			/// Initializes a new instance of PCS.Web.UI.SecureUserControl class.
			/// </summary>
			/// <param name="applicationName">Name of the application as in the security database.</param>
			/// <param name="securityServer">One of the PCS.Security.Application.SecurityServer values.</param>
			/// <param name="authenticationMode">One of the PCS.Security.Application.AuthenticationMode values.</param>
			public SecureUserControl(string applicationName, SecurityServer securityServer, AuthenticationMode authenticationMode)
			{
				
				m_securityProvider = new WebSecurityProvider();
				m_securityProvider.BeforeLoginPrompt += new System.EventHandler`1[[System.ComponentModel.CancelEventArgs, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](m_securityProvider_BeforeLoginPrompt);
Exemple #56
0
        /// <summary>
        /// Find response sign-out details for a specific authentication middleware
        /// </summary>
        /// <param name="authenticationType">The authentication type to look for</param>
        /// <param name="authenticationMode">The authentication mode the middleware is running under</param>
        /// <returns>The information instructing the middleware how it should behave</returns>
        public AuthenticationResponseRevoke LookupSignOut(string authenticationType, AuthenticationMode authenticationMode)
        {
            if (authenticationType == null)
            {
                throw new ArgumentNullException("authenticationType");
            }

            AuthenticationResponseRevoke revoke = _context.Authentication.AuthenticationResponseRevoke;
            if (revoke == null)
            {
                return null;
            }
            if (revoke.AuthenticationTypes == null || revoke.AuthenticationTypes.Length == 0)
            {
                return authenticationMode == AuthenticationMode.Active ? revoke : null;
            }
            for (int index = 0; index != revoke.AuthenticationTypes.Length; ++index)
            {
                if (String.Equals(authenticationType, revoke.AuthenticationTypes[index], StringComparison.Ordinal))
                {
                    return revoke;
                }
            }
            return null;
        }
Exemple #57
0
 /// <summary>
 /// Constructor that intializes the authentication mode for this app.
 /// </summary>
 /// <param name="mode">Mode in which to run app.</param>
 public MainController(AuthenticationMode mode)
     : base(mode)
 {
     InitializeAppProperties();
 }
        protected async void CheckForExistingLoginAsync(AuthValidationMode authValidationMode, AuthenticationMode authMode)
        {
            string serializedAuthStatus = AuthManager.Instance.RetrieveProtectedString(Constants.AuthStatusKey);
            if (!String.IsNullOrEmpty(serializedAuthStatus))
            {
                var aS = AuthStatus.DeserializeFromString(serializedAuthStatus);
                //consider that a change in Authmode is possible between versions of an app, so check if the saved token may be trusted
                if (AuthenticationMode.Authorize.Equals(authMode) && !aS.IsAuthorized || AuthenticationMode.Identify.Equals(authMode) && aS.IsAuthorized)
                {
                    return;
                }

                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    this.VM.IsShowOverlay = true;
                    try
                    {
                        SystemTray.ProgressIndicator.IsVisible = true;
                        if (await aS.CheckIfStillValidAsync())
                        {
                            AuthManager.Instance.CurrentAuthStatus = aS;
                            NavigationService.Navigate(AuthManager.Instance.SuccessRedirect);
                        }
                        else
                        {
                            Dispatcher.BeginInvoke(() => { MessageBox.Show(LocalizedStrings.LocalizedResources.AuthNoMemberError); });
                        }
                    }
                    catch (WebTransferException)
                    {
                        
                        if (AuthValidationMode.Graceful.Equals(authValidationMode))
                        {
                            NavigationService.Navigate(AuthManager.Instance.SuccessRedirect); 
                        }
                        else
                        {
                            Dispatcher.BeginInvoke(() => { MessageBox.Show(LocalizedStrings.LocalizedResources.AuthNetworkError); });
                        }
                    }
                    finally
                    {
                        SystemTray.ProgressIndicator.IsVisible = false;
                        this.VM.IsShowOverlay = false;
                    }
                }
                else
                {
                    if (AuthValidationMode.Graceful.Equals(authValidationMode))
                    {
                        NavigationService.Navigate(AuthManager.Instance.SuccessRedirect);
                    }
                    Dispatcher.BeginInvoke(() => { MessageBox.Show(LocalizedStrings.LocalizedResources.AuthNetworkError); });
                }
            }
        }
        internal void AuthenticateUser(Uri successRedirect, AuthenticationMode authMode = AuthenticationMode.Authorize,
            TokenValidationPolicy tokenValidationPolicy = TokenValidationPolicy.EveryLogin, AuthValidationMode authValidationMode = AuthValidationMode.Graceful,
            string email = null, string appSecret = null)
        {
            if (AuthenticationMode.Identify.Equals(authMode) && String.IsNullOrEmpty(appSecret))
            {
                throw new ApplicationException(LocalizedStrings.LocalizedResources.Authentication_AppSecretMissing);
            }
            this.SuccessRedirect = successRedirect;

            bool needsLogin = TokenValidationPolicy.EveryLogin.Equals(tokenValidationPolicy);

            if (!needsLogin && TokenValidationPolicy.OnNewVersion.Equals(tokenValidationPolicy))
            {
                string lastAuthorizedVersion = IsolatedStorageSettings.ApplicationSettings.GetValue(Constants.AuthLastAuthorizedVersionKey) as String;
                needsLogin = (lastAuthorizedVersion == null) || (new Version(lastAuthorizedVersion) < new Version(ManifestHelper.GetAppVersion()));
            }

            if (needsLogin)
            {
                ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(new Uri("/HockeyApp;component/Views/LoginPage.xaml?authmode=" + HttpUtility.UrlEncode(authMode.ToString())
                                                                + "&appsecret=" + HttpUtility.UrlEncode(appSecret)
                                                                + "&email=" + HttpUtility.UrlEncode(email ?? "")
                                                                + "&validationmode=" + HttpUtility.UrlEncode(authValidationMode.ToString() ?? ""), UriKind.Relative));
            }
            else
            {
                ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(successRedirect);
            }
        }
Exemple #60
0
			/// <summary>
			/// Initializes a new instance of PCS.Web.UI.SecurePage class.
			/// </summary>
			/// <param name="applicationName">Name of the application as in the security database.</param>
			/// <param name="securityServer">One of the PCS.Security.Application.SecurityServer values.</param>
			/// <param name="authenticationMode">One of the PCS.Security.Application.AuthenticationMode values.</param>
			public SecurePage(string applicationName, SecurityServer securityServer, AuthenticationMode authenticationMode)
			{
				
				m_securityProvider = new WebSecurityProvider();
				m_securityProvider.AccessDenied += new System.EventHandler`1[[System.ComponentModel.CancelEventArgs, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](m_securityProvider_AccessDenied);