Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            if( context.Request.HttpMethod != "POST" ) {
                context.Response.Write("POST");
            }
            else {

                var service = new Mysoft.ESB.Services.SSOTicketServices();
                StringBuilder sb = new StringBuilder();

                //处理用户传递的参数
                foreach( string key in context.Request.Form.AllKeys ) {
                    if ( !key.StartsWith("esb_") ){

                        var value = HttpUtility.UrlEncode(context.Request.Form["key"]);

                        if( sb.Length == 0 ) {
                            sb.AppendFormat("{0}={1}", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(context.Request.Form[key]));
                        }
                        else {
                            sb.AppendFormat("&{0}={1}", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(context.Request.Form[key]));
                        }
                    }
                }

                //处理s_开头参数.例如用户名,cookie之类的值
                string usercode = "admin"; //需要从session中获取

                if( sb.Length == 0 ) {
                    sb.AppendFormat("s_uid={0}", usercode);
                }
                else {
                    sb.AppendFormat("&s_uid={0}", usercode);
                }

                //处理esb_开头参数
                int ts = service.GeTime();

                string esb_c = context.Request.Form["esb_c"];

                sb.AppendFormat("&esb_t={0}&esb_c={1}", ts, esb_c);
                string md5 = service.MD5(sb.ToString());

                sb.AppendFormat("&esb_p={0}", md5);

                string url = "http://localhost:9005/ESB/EsbSSO.ashx?" + sb.ToString();

                context.Response.Write(url);
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;

            string esbt = request.QueryString["esb_t"]; //时间戳,自1970.01.01以来的秒数
            string esbp = request.QueryString["esb_p"]; //除时间戳以外查询字符串的md5(16)值

            if( string.IsNullOrEmpty(esbt) ) {
                response.Write("缺少esb_t参数!");
                response.End();
            }

            int ts;
            if( !int.TryParse(esbt, out ts) ) {
                response.Write("esb_t参数不是数字!");
                response.End();
            }

            if( string.IsNullOrEmpty(esbp) ) {
                response.Write("缺少esb_p参数!");
                response.End();
            }

            var service = new Mysoft.ESB.Services.SSOTicketServices();

            int tz = service.GeTime() - ts;

            //url的可用周期为3分钟
            if( tz < 0 || tz > 1000 * 60 * 3 ) {
                response.Write("url已过期!");
                response.End();
            }

            //处理登录逻辑

            string userCode = request.QueryString["s_uid"];
        }