예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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;
            }
        }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="password"></param>
 private RubricaIdentity(SecurityCredentials credentials)
 {
     // Validazione credenziali utente
     this.ValidateCredentials(credentials);
 }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="credentials"></param>
 /// <returns></returns>
 internal static RubricaIdentity GetIdentity(SecurityCredentials credentials)
 {
     return(new RubricaIdentity(credentials));
 }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="credentials"></param>
 /// <returns></returns>
 public static bool Login(SecurityCredentials credentials)
 {
     return(SetPrincipal(RubricaIdentity.GetIdentity(credentials)));
 }