Exemple #1
0
    /// <summary>
    /// 登陆
    /// </summary>
    /// <param name="Session">Session</param>
    /// <param name="userName">用户名</param>
    /// <param name="password">密码</param>
    /// <returns>成功为true,失败为false</returns>
    public static bool Login(System.Web.SessionState.HttpSessionState Session, string userName, string password)
    {
        if (userName == "" || password == "")
        {
            return(false);
        }
        DataBase db     = new DataBase(); /*实例化一个数据库。*/
        String   str    = Encrypt.encrypt(password);
        DataSet  result = db.RunProcReturn("select * from tb_user where username=@username and password=@password", new SqlParameter[] {
            db.MakeInParam("username", System.Data.SqlDbType.VarChar, 20, userName),
            db.MakeInParam("password", System.Data.SqlDbType.VarChar, 200, str)
        }, "tb_user");                        /*查询数据库中与输入的用户名密码相同的集。*/

        if (result.Tables[0].Rows.Count != 0) /*  如数据库中有用户名密码与输入的用户名密码相同,则将username和password、uid放入session中。*/
        {
            Session.Add("username", userName);
            Session.Add("password", password);
            Session.Add("uid", result.Tables[0].Rows[0]["id"].ToString());
            Session.Add("isadmin", result.Tables[0].Rows[0]["isadmin"]);
            Session.Remove("loginerror");
            return(true);
        }
        else
        {
            Session.Add("loginerror", true);
            return(false);
        }
    }
Exemple #2
0
        // string nombreUsuario )
        /// <summary>
        /// Crea una sesión de usuario
        /// </summary>
        /// <param name="sesion"></param>
        /// <param name="nombreUsuario"></param>
        public static void Crear(HttpSessionState sesion, 
            BDLigotea.Usuario usuario )
        {
            sesion.Add(LRegistro.SESION_USUARIO, usuario.Nick);
            sesion.Add(LRegistro.SESION_ID, usuario.IdUsuario);

            // Dentro de la clase es igual que
            //sesion.Add(SESION_USUARIO, nombreUsuario);
        }
        public CommandResult Run(HttpRequestData request, IOptions options, HttpSessionState session)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            string rpEntityId = request.QueryString["rp"].FirstOrDefault().Replace('+', ' ');
            var providerData = options.OpenIDProviders[rpEntityId];
            var urls = new OpenIDUrls(options.RPOptions, request.ApplicationUrl);
            providerData.RegisterClient(options.RPOptions, urls);

            OIDCAuthorizationRequestMessage requestMessage = generateRequestMessage(providerData, urls);
            string requestObject = null;

            if (providerData.Sign && options.RPOptions.SignCertificate != null)
            {
                OIDCAuthorizationRequestMessage rObject = generateRequestObject(providerData, urls, requestMessage.State, requestMessage.Nonce);
                requestObject = JWT.Encode(rObject.SerializeToJsonString(), getCertificateKey(options.RPOptions.SignCertificate), JwsAlgorithm.RS256);
                requestMessage.Request = requestObject;
            }

            if (providerData.Encrypt && options.RPOptions.EncCertificate != null)
            {
                if (requestObject == null)
                {
                    OIDCAuthorizationRequestMessage rObject = generateRequestObject(providerData, urls, requestMessage.State, requestMessage.Nonce);
                    requestObject = rObject.SerializeToJsonString();
                }

                requestObject = JWT.Encode(requestObject, getCertificateKey(options.RPOptions.EncCertificate), JweAlgorithm.RSA1_5, JweEncryption.A128CBC_HS256);
                requestMessage.Request = requestObject;
            }

            session.Add("op", rpEntityId);
            session.Add("nonce", requestMessage.Nonce);
            session.Add("state", requestMessage.State);

            return new CommandResult()
            {
                HttpStatusCode = HttpStatusCode.SeeOther,
                Location = new Uri(providerData.ProviderMatadata.AuthorizationEndpoint + "?" + requestMessage.SerializeToQueryString())
            };
        }
Exemple #4
0
        public static UserSession GetSession(HttpSessionState session)
        {
            // if not there create it
            if (session[sessionIndex] == null)
                session.Add(sessionIndex, new UserSession());

            return (UserSession)session[sessionIndex];
        }
Exemple #5
0
 public static SessionData GetInstance(HttpSessionState obj)
 {
     if (null != obj[C_SESSION_OBJ_KEY])
     {
         return (SessionData)obj[C_SESSION_OBJ_KEY];
     }
     else
     {
         obj.Add(C_SESSION_OBJ_KEY, new SessionData());
         return (SessionData)obj[C_SESSION_OBJ_KEY];
     }
 }
Exemple #6
0
        public static int InvalidPasswordAttempts(HttpSessionState session, int increment = 0)
        {
            if (session == null)
            {
                return 0;
            }

            int retVal = 0;

            if (session["InvalidPasswordAttempts"] == null)
            {
                retVal = retVal + increment;
                session.Add("InvalidPasswordAttempts", retVal);
            }
            else
            {
                retVal = Conversion.TryCastInteger(session["InvalidPasswordAttempts"]) + increment;
                session["InvalidPasswordAttempts"] = retVal;
            }

            if (increment > 0)
            {
                Log.Warning("{Count} Invalid attempt to sign in from {Host}/{IP} using {Browser}.", retVal, GetUserHostAddress(), GetUserIpAddress(), GetBrowser().Browsers);
            }

            return retVal;
        }
 public void setGtSession(HttpSessionState session)
 {
     session.Add(GeetestLib.gtSessionKey, this);
 }
 public void setGtServerStatusSession(HttpSessionState session, int statusCode)
 {
     session.Add(GeetestLib.gtServerStatusSessionKey, statusCode);
 }
Exemple #9
0
 /// <summary>
 /// set a user data
 /// </summary>
 /// <param name="session"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static HttpSessionState setInfo(HttpSessionState session, Data data)
 {
     session.Add(sName, data);
     return session;
 }
Exemple #10
0
 public static void SaveUseInfo(SessionInfo oSessionInfo, System.Web.SessionState.HttpSessionState oSession)
 {
     oSession.Add(sUserInfoID, oSessionInfo);
 }
 public static string GenerateChallenge(HttpSessionState session)
 {
     string challenge = GenerateChallenge();
     session.Add(ChallengeSessionKey, challenge);
     return challenge;
 }
Exemple #12
0
 /// <summary>
 /// 跳转到提示页面
 /// </summary>
 /// <param name="response">传入Response</param>
 /// <param name="session">传入Session</param>
 /// <param name="tip">提示信息</param>
 /// <param name="url">跳转Url</param>
 public static void goRedirect(HttpResponse response, System.Web.SessionState.HttpSessionState session, string tip, string url)
 {
     session.Add("tip", tip);
     response.Redirect("~/redirect.aspx?url=" + url);
 }
 /// <summary>
 /// Default Constructor
 /// </summary>
 public DefAppWebAdmin(HttpSessionState session)
 {
     _innerSession = session;
     _innerSession.Add(DefAppWebAdmin.DEFAPPNAME, this);
 }