/// <summary> /// Validazione credenziali utente /// </summary> /// <param name="credentials"></param> /// <returns></returns> public static SecurityCredentialsResult ValidateCredentials(SecurityCredentials credentials) { SecurityCredentialsResult result = null; const string SP_GET = "GetUserCredentials"; Dpa.DataAccess.Database db = RubricaDatabase.CreateDatabase(); using (Dpa.DataAccess.DBCommandWrapper cw = db.GetStoredProcCommandWrapper(RubricaDatabase.GetSpNameForPackage(SP_GET))) { cw.AddInParameter("pNomeUtente", DbType.String, credentials.UserName); cw.AddInParameter("pPassword", DbType.String, SecurityCredentials.GetPasswordHash(credentials.UserName, credentials.Password)); using (IDataReader reader = db.ExecuteReader(cw)) { if (reader.Read()) { result = new SecurityCredentialsResult { UserName = credentials.UserName, Amministratore = (Dpa.DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "Amministratore", false) == "1") }; } } } return(result); }
/// <summary> /// Validazione credenziali utente /// </summary> /// <returns></returns> protected virtual void ValidateCredentials(SecurityCredentials credentials) { SecurityCredentialsResult result = SecurityHelper.ValidateCredentials(credentials); this._isAuthenticated = (result != null); if (this._isAuthenticated) { this._name = result.UserName; this._isAdminRole = result.Amministratore; } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="password"></param> private RubricaIdentity(SecurityCredentials credentials) { // Validazione credenziali utente this.ValidateCredentials(credentials); }
/// <summary> /// /// </summary> /// <param name="credentials"></param> /// <returns></returns> internal static RubricaIdentity GetIdentity(SecurityCredentials credentials) { return(new RubricaIdentity(credentials)); }
/// <summary> /// /// </summary> /// <param name="credentials"></param> /// <returns></returns> public static bool Login(SecurityCredentials credentials) { return(SetPrincipal(RubricaIdentity.GetIdentity(credentials))); }