public static int GetUAAuthenAddress(string SPID,string ProvinceID, HttpContext SpecificContext, string SPDataCacheName, string ExtendField, out MBOSSClass.SSOAddressResp SSOAddress, out string ErrMsg, out string newExtendField)
    {
        newExtendField = "";
        int result = -20005;
        ErrMsg = "";
        SSOAddress = new MBOSSClass.SSOAddressResp();

        MBOSSClass Mboss = new MBOSSClass();
        //SPInfoManager spInfo = new SPInfoManager();
        try
        {
        //    Object SPData = spInfo.GetSPData(SpecificContext, SPDataCacheName);
        //    privateKeyFile = spInfo.GetCAInfo("35111111", 1, SPData, out UserName, out privateKeyPassword);
            result = Mboss.AuthenSelectArddess(SPID,ProvinceID,SpecificContext,SPDataCacheName, out SSOAddress, out ErrMsg);
        }
        catch (Exception err)
        {
            ErrMsg = err.Message;
            result = -20001;
        }
        finally
        {
            #region WriteLog
            StringBuilder msg = new StringBuilder();
            msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n\r\n");
            msg.Append("CAP03001身份认证地址 " + DateTime.Now.ToString("u") + "\r\n");
            msg.Append(";ProvinceID - " + ProvinceID);
            msg.Append(";SpecificContext - " + SpecificContext);
            msg.Append(";SPDataCacheName - " + SPDataCacheName);
            msg.Append(";ExtendField - " + ExtendField);
            msg.Append("\r\n");

            msg.Append("处理结果 - " + result);
            msg.Append("SSOAddress - " + SSOAddress.SSOAddress);
            msg.Append("AssertionAddress - " + SSOAddress.AssertionAddress);
            msg.Append("; 错误描述 - " + ErrMsg);
            msg.Append("; ExtendField - " + newExtendField + "\r\n");
            msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n");

            BTUCenterInterfaceLog.CenterForBizTourLog("GetUAAuthenAddress", msg);
            #endregion
        }

        return result;
    }
Exemple #2
0
        public static string Version = ""; //System.Configuration.ConfigurationManager.AppSettings["Version"];

        #endregion Fields

        #region Methods

        /// <summary>
        /// ��ԭXML���м��ܣ���д��DigitalSign�ڵ�
        /// </summary>
        /// <param name="OldXML">ԭXML</param>
        /// <param name="privateKeyFile">˽Կ</param>
        /// <param name="privateKeyPassword">˽Կ����</param>
        /// <param name="ResultXML">���ؼ��ܹ���xml</param>
        /// <param name="ErrMsg">������Ϣ</param>
        /// <returns></returns>
        public static int AddDigitalSignXML(string OldXML, byte[] privateKeyFile, string privateKeyPassword, out string ResultXML, out string ErrMsg)
        {
            ErrMsg = "";
            ResultXML = "";
            string NewXML = "";
            int Result = -19999;
            MBOSSClass mboss = new MBOSSClass();
            try
            {
                //����˽Կ����
                Result = mboss.DigSignByprivateKey(OldXML, privateKeyFile, privateKeyPassword, out NewXML, out  ErrMsg);

                if (Result != 0)
                    return Result;

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(OldXML);
                //�޸�XML�������ܹ���xmlд��ԭDigitalSign�ڵ�
                //���ݽڵ������Ҹ����ڵĽڵ�
                //XmlNode DigitalSignNode = doc.SelectSingleNode("descendant::CAPRoot/SessionHeader/DigitalSign");
                XmlNode DigitalSignNode = doc.SelectSingleNode("/CAPRoot/SessionHeader/DigitalSign");

                //�����ܹ���xmlд��ԭDigitalSign�ڵ�
                DigitalSignNode.InnerText = NewXML;

                ResultXML = doc.OuterXml;

                ResultXML = ResultXML.Replace("<DigitalSign></DigitalSign>", "<DigitalSign/>");
                ResultXML = ResultXML.Replace(" />", "/>");
                Result = 0;

            }
            catch (Exception err)
            {
                Result = -29999;
                ErrMsg = err.Message;
            }

            return Result;
        }
    protected void QueryAssertionByTicket()
    {
        MBOSSClass mboss = new MBOSSClass();
        StringBuilder strLog = new StringBuilder();
        string xml = "";
        int Result = -19999;
        string ErrMsg = String.Empty;
        string UAProvinceID = "35";
        string SPID = UAProvinceID + "999991";
        string CustID = "", RealName = "", NickName = "", UserName = "", OutID = "", UserAccount = "", CustType = "", ProvinceID = "", AuthenName = "", AuthenType = "";
        string AssertionAddress = String.Empty;
        string SSOAddress = String.Empty;
        string SecretKey = String.Empty;
        try
        {
            //获取到集团断言查询地址,这里要注意个问题,取地址是从数据库中去,测试库上的地址已经改为新的断言地址,在正式库上是否要改?
            Result = mboss.GetMBOSSAddress(this.Context, SPID, out AssertionAddress, out SSOAddress, out ErrMsg);
            if (Result != 0)
            {
                strLog.Append("没有获取到集团断言查询地址;\r\n");
                //SendJF();   没有获取到集团断言查询地址
                return;
            }
            PageUtility.SetCookie(AssertionAddress, "AssertionAddress", this.Page);
            PageUtility.SetCookie(SSOAddress, "SSOAddress", this.Page);
            //35000 20130808 5146985330
            string TransactionID = "35000" + DateTime.Now.ToString("yyyyMMdd") + Convert.ToString(LongRandom(1000000000, 9999999999, new Random()));                   //获取流水号
            //密钥
            Result = mboss.GetMBOSSSecretKey(this.Context, SPID, out SecretKey, out ErrMsg);
            if (Result != 0)
            {
                strLog.Append("没有获取到密钥;\r\n");
                //没有获取到密钥;
                return;
            }

            //断言
            MBOSSClass.BilByCompilingResult bil = new MBOSSClass.BilByCompilingResult();
            //查询断言并解析
            Result = mboss.SendUATicket(UAProvinceID, SPID, UATicket, AssertionAddress, this.Context, "SPCAData", TransactionID, out bil, out xml, out ErrMsg);
            AuthenType = bil.AccountType;
            AuthenName = bil.AccountID;
            strLog.AppendFormat("断言查询返回的报文:{0}\r\n",xml);
            if (Result != 0)
            {
                //Response.Redirect("../ErrorInfo.aspx?Result=-19999&ErrorInfo=请从网厅登陆1&FunctionName=请从网厅登陆1", true);
                Response.Redirect("../ErrorInfo.aspx?Result=-19999&ErrorInfo=断言解析错误!", true);
                return;
            }

            //用户入库是否存在,没有则新增,有则update
            string dealType = String.Empty;
            int  type = 0;
            string areaid = String.Empty;

            Result = BTForBusinessSystemInterfaceRules.MUserAuthV2(SPID, UAProvinceID, bil.AccountID, bil.AccountType, bil.AccountInfos, Context,
            out  ErrMsg, out  CustID, out  UserAccount, out  CustType, out  OutID, out  ProvinceID,
            out  RealName, out  UserName, out  NickName, out dealType, out type, out areaid);

            if (Result != 0)
            {
                Response.Redirect("../ErrorInfo.aspx?Result=" + Result + "&ErrorInfo=" + ErrMsg + "&FunctionName=请从网厅登陆4", true);
                return;
            }

            //如果客户信息不全,则去crm查询一把  这里要注意的是,必须根据集团返回的断言中的UAID 当成省码传给枢纽
            string TestStr = String.Empty;
            Result = CrmSSO.UserAuthCrm1(bil.ProvinceID, bil.AccountInfos[0].areaid, bil.AccountType, bil.AccountID, UAProvinceID, "", "0", UAProvinceID + "999991", this.Context, out RealName, out UserName, out NickName, out OutID, out CustType, out CustID, out ErrMsg, out TestStr);
            if (Result != 0)
            {
                Response.Redirect("../ErrorInfo.aspx?Result=" + Result + "&ErrorInfo=" + ErrMsg + "&FunctionName=请从网厅登陆5", true);
                return;
            }
            strLog.Append(Result + "==" + UAProvinceID + "=UAProvinceID;" + bil.AccountType + " =bil.AccountType;" + bil.AccountID + "=bil.AccountID;" + "" + "" + RealName + "=RealName;" + UserName + "=UserName;" + NickName + "=NickName;" + OutID + "=OutID;" + CustType + "=CustType;" + CustID + "=CustID1;" + ErrMsg + "=ErrMsg\r\n");
            if (dealType == "0")            //通知积分系统
                CIP2BizRules.InsertCustInfoNotify(CustID, "2", System.Configuration.ConfigurationManager.AppSettings["ScoreBesttoneSPID"], "", "0", out ErrMsg);

            //生成ticket
            Result = CIPTicketManager.insertCIPTicket(TransactionID, SPID, CustID, RealName, NickName, UserName, OutID, "", AuthenName, AuthenType, out ErrMsg);
            Response.Redirect(ReturnUrl + "?Ticket=" + TransactionID);
        }
        catch (Exception e)
        {
            strLog.AppendFormat(e.Message);
        }
        finally
        {
            try
            {
                CommonBizRules.WriteDataCustAuthenLog(SPID, CustID, ProvinceID, AuthenType, AuthenName, "2", Result, ErrMsg);

            }
            catch { }
        }
    }
    public static int SendSSOAuthanXML(string ProvinceID,string SPID, string RedirectURL, HttpContext SpecificContext, string SPDataCacheName, MBOSSClass.AcceptAccountTypeList[] AcceptAccountTypes, string ExtendField, string TransactionID, out string ResultXML, out string ErrMsg, out string newExtendField)
    {
        int result = -20005;
        ResultXML = "";
        ErrMsg = "";
        newExtendField = "";
        MBOSSClass Mboss = new MBOSSClass();
        //SPInfoManager spInfo = new SPInfoManager();
        //byte[] privateKeyFile;
        //string UserName = "";
        //string privateKeyPassword = "";
        try
        {
            //Object SPData = spInfo.GetSPData(SpecificContext, SPDataCacheName);
            //privateKeyFile = spInfo.GetCAInfo("35111111", 1, SPData, out UserName, out privateKeyPassword);
            result = Mboss.SSOAuthanXML(ProvinceID,SPID, RedirectURL, AcceptAccountTypes, SpecificContext, SPDataCacheName, out ResultXML, out ErrMsg, out TransactionID);
        }
        catch (Exception err)
        {
            result = -20005;
            ErrMsg = err.Message;
        }
        finally
        {
            #region WriteLog
            StringBuilder msg = new StringBuilder();
            msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n\r\n");
            msg.Append(" CAP01003 发送身份认证请求 " + DateTime.Now.ToString("u") + "\r\n");
            msg.Append(";RedirectURL - " + RedirectURL);
            msg.Append(";SpecificContext - " + SpecificContext);
            msg.Append(";SPDataCacheName - " + SPDataCacheName + "\r\n");
            if (AcceptAccountTypes != null)
            {
                for (int i = 0; i < AcceptAccountTypes.Length; i++)
                {
                    msg.Append(";AcceptAccountType - " + AcceptAccountTypes[i].AcceptAccountType);
                }
            }
            else
            {
                msg.Append(";AcceptAccountType - " + "");
            }
            msg.Append("\r\n ;ExtendField - " + ExtendField);
            msg.Append("\r\n");

            msg.Append("处理结果 - " + result);
            msg.Append("ResultXML - " + ResultXML);
            msg.Append("; 错误描述 - " + ErrMsg);
            msg.Append("; ExtendField - " + newExtendField + "\r\n");
            msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n");

            BTUCenterInterfaceLog.CenterForBizTourLog("SendSSOAuthanXML", msg);
            #endregion
        }
        return result;
    }
    public static int SendUATicket(string UAProvinceID,string SPID,string ticket, string CustID, string URL, HttpContext SpecificContext, string SPDataCacheName, string ExtendField,string TransactionID, out string ErrMsg, out string newExtendField)
    {
        int result = -20005;
        //byte[] privateKeyFile;
        //byte[] publicKeyFile;
        //string privateKeyPassword = "";
        //string UserName = "";
        string ticketXML = "";
        newExtendField = "";
        ErrMsg = "";

        MBOSSClass.BilByCompilingResult bcr = new MBOSSClass.BilByCompilingResult();

        //SPInfoManager spInfo = new SPInfoManager();
        MBOSSClass mbss = new MBOSSClass();

        try
        {
            //Object SPData = spInfo.GetSPData(SpecificContext, SPDataCacheName);
            //publicKeyFile = spInfo.GetCAInfo("35111111", 0, SPData, out UserName, out privateKeyPassword);
            //privateKeyFile = spInfo.GetCAInfo("35111111", 1, SPData, out UserName, out privateKeyPassword);
            result = mbss.SendUATicket(UAProvinceID,SPID, ticket, URL, SpecificContext, SPDataCacheName, TransactionID, out bcr, out ticketXML, out ErrMsg);
        }
        catch (Exception err)
        {
            result = -20006;
            ErrMsg = err.Message;
        }
        finally
        {
            #region WriteLog
            StringBuilder msg = new StringBuilder();
            msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n\r\n");
            msg.Append(" CAP02001票据解读接口 " + DateTime.Now.ToString("u") + "\r\n");
            msg.Append(";ticket - " + ticket);
            msg.Append(";SpecificContext - " + SpecificContext);
            msg.Append(";SPDataCacheName - " + SPDataCacheName + "\r\n");
            msg.Append(";ExtendField - " + ExtendField);
            msg.Append("\r\n");

            msg.Append("处理结果 - " + result);
            msg.Append("UATicketXML - " + ticketXML);
            msg.Append("; 错误描述 - " + ErrMsg);
            msg.Append("; ExtendField - " + newExtendField + "\r\n");
            msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n");

            BTUCenterInterfaceLog.CenterForBizTourLog("SendUATicket", msg);
            #endregion
        }
        return result;
    }
    protected void Query_Assertion()
    {
        MBOSSClass mboss = new MBOSSClass();

        SPInfoManager spInfo = new SPInfoManager();

        int Result = ErrorDefinition.IError_Result_UnknowError_Code;
        string  ErrMsg = "";
        string UserName = "";
        string privateKeyPassword = "";
        string CAP01002_XML = Request["SSORequestXML"];
        string DigitalSign = MBOSSClass.GetNewXML(CAP01002_XML, "DigitalSign");
        string DigitalSignValue = MBOSSClass.GetValueFromXML(CAP01002_XML, "DigitalSign");
        //从中取出RedirectURL
        string RedirectURL = MBOSSClass.GetValueFromXML(CAP01002_XML, "RedirectURL");
        //验证 CAP01002_XM 合法性
        byte[] PublicKeyFile = new byte[0];

        try
        {
            Object SPData = spInfo.GetSPData(this.Context, "");  //SPDataCacheName 这里要去问tongbo
            PublicKeyFile = spInfo.GetCAInfo(SPID, 0, SPData, out UserName, out privateKeyPassword);
        }
        catch (Exception err)
        {
            //验证签名未通过
            ErrMsg = err.Message;
            Result = -20001;
            Response.Redirect(RedirectURL, true);
            return;
        }

        Result = mboss.VerifySignByPublicKey(DigitalSign, PublicKeyFile, DigitalSignValue, out ErrMsg);
        if (Result != 0)
        {
            // 签名校验未通过,直接将请求原路打回
            Response.Redirect(RedirectURL, true);
            return;
        }
    }
Exemple #7
0
        /// <summary> ��ȡ��֤��ʽxml�ַ���
        /// ��ȡ��֤��ʽxml�ַ���
        /// </summary>
        /// <param name="DeleteUserAccountRecords"></param>
        /// <returns></returns>
        public static string GenerateXmlForAuthenRecords(MBOSSClass.AuthenRecord[] AuthenRecords)
        {
            string Result = "";

            XmlDocument xmldoc;
            XmlNode xmlnode;
            XmlElement xmlelem;
            XmlElement xmlelem2;
            XmlElement xmlelem3;
            XmlText xmltext;
            try
            {
                xmldoc = new XmlDocument();
                //����XML����������
                xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                xmldoc.AppendChild(xmlnode);
                //����һ����Ԫ��
                xmlelem = xmldoc.CreateElement("", "ROOT", "");
                xmldoc.AppendChild(xmlelem);

                for (int i = 0; i < AuthenRecords.Length; i++)
                {
                    //��������һ��Ԫ��
                    xmlelem2 = xmldoc.CreateElement("AuthenRecord");
                    xmlelem2 = xmldoc.CreateElement("", "AuthenRecord", "");

                    xmlelem3 = xmldoc.CreateElement("", "AuthenType", "");
                    xmltext = xmldoc.CreateTextNode(AuthenRecords[i].AuthenType.ToString());
                    xmlelem3.AppendChild(xmltext);
                    xmlelem2.AppendChild(xmlelem3);

                    xmlelem3 = xmldoc.CreateElement("", "AuthenName", "");
                    xmltext = xmldoc.CreateTextNode(AuthenRecords[i].AuthenName.ToString());
                    xmlelem3.AppendChild(xmltext);
                    xmlelem2.AppendChild(xmlelem3);

                    xmlelem3 = xmldoc.CreateElement("", "areaid", "");
                    xmltext = xmldoc.CreateTextNode(AuthenRecords[i].areaid .ToString());
                    xmlelem3.AppendChild(xmltext);
                    xmlelem2.AppendChild(xmlelem3);

                    xmldoc.ChildNodes.Item(1).AppendChild(xmlelem2);
                }
                //���洴���õ�XML�ĵ�

                // xmldoc.Save(@".\DeleteUserAccountRecord.xml");
                Result = xmldoc.OuterXml;

            }
            catch
            { }

            return Result;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        int Result = ErrorDefinition.IError_Result_UnknowError_Code;
        string ErrMsg = "";

        string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
        string token = PageUtility.GetCookie(CookieName);
        string ProvinceID = "";
        string CustID = "";
        string RealName = "";
        string UserName = "";
        string NickName = "";
        string OuterID = "";
        string CustType = "";
        string AuthenName = "";
        string AuthenType = "";

        if (String.IsNullOrEmpty(token))
        {
            Response.Redirect("../../ErrorInfo.aspx?Result=-19999&ErrorInfo=请先登录积分商城", true);
            return;
        }

        UserToken UT = new UserToken();
        string key = System.Configuration.ConfigurationManager.AppSettings["ScoreSystemSecret"];
        Result = UT.ParseScoreUserToken(token, key, out ProvinceID, out CustID, out RealName, out UserName, out NickName, out OuterID, out CustType, out AuthenName, out AuthenType, out ErrMsg);

        MBOSSClass mboss = new MBOSSClass();
        SPInfoManager spInfo = new SPInfoManager();

        string privateKeyPassword = "";
        string CAP01002_XML = Request["SSORequestXML"];
        string DigitalSign = MBOSSClass.GetNewXML(CAP01002_XML, "DigitalSign");
        string DigitalSignValue = MBOSSClass.GetValueFromXML(CAP01002_XML, "DigitalSign");
        //从中取出RedirectURL
        string RedirectURL = MBOSSClass.GetValueFromXML(CAP01002_XML, "RedirectURL");
        //验证 CAP01002_XM 合法性
        byte[] PublicKeyFile = new byte[0];

        try
        {
            Object SPData = spInfo.GetSPData(this.Context, "");  //SPDataCacheName 这里要去问tongbo
            PublicKeyFile = spInfo.GetCAInfo(SPID, 0, SPData, out UserName, out privateKeyPassword);
        }
        catch (Exception err)
        {
            //验证签名未通过
            ErrMsg = err.Message;
            Result = -20001;
            Response.Redirect(RedirectURL, true);
            return;
        }

        Result = mboss.VerifySignByPublicKey(DigitalSign, PublicKeyFile, DigitalSignValue, out ErrMsg);
        if (Result != 0)
        {
            // 签名校验未通过,直接将请求原路打回
            Response.Redirect(RedirectURL, true);
            return;
        }
    }
    protected void ssoFunc()
    {
        string QH = System.Configuration.ConfigurationManager.AppSettings["HQList"];
        //上海,广州处理
        string UAOUTID = System.Configuration.ConfigurationManager.AppSettings["UAOUTIDLIst"];

        string UAProvinceID =Request.Cookies["UAProvinceID"].Value.ToString();
        //是否是SSO的省
        if (QH.IndexOf(UAProvinceID) < 0 && UAOUTID.IndexOf(UAProvinceID) < 0)
        {
            Response.Redirect("../ErrorInfo.aspx?Result=-19999&ErrorInfo=未开通单点登录&FunctionName=请从 http://jf.ct10000.com 直接登入集团积分商城", true);
            return;
        }

        MBOSSClass mboss = new MBOSSClass();
        string AssertionAddress = Request.Cookies["AssertionAddress"].Value.ToString();             //获取断言查询地址
        string TransactionID = Request.Cookies["TransactionID"].Value.ToString();                   //获取流水号

        string xml="";
        int result = -19999;
        string ErrMsg = "";

        string SPID = UAProvinceID + "999991";
        string CustID = "", RealName = "",NickName = "",UserName = "",OutID = "",UserAccount = "",CustType = "",ProvinceID = "" ,AuthenName = "",AuthenType = "";
        try
        {

            SPInfoManager spInfo = new SPInfoManager();
            Object SPData = spInfo.GetSPData(this.Context, "SPData");
            //密钥
            string key = spInfo.GetPropertyBySPID(SPID, "SecretKey", SPData);
            //断言
            MBOSSClass.BilByCompilingResult bil = new MBOSSClass.BilByCompilingResult();
            //查询断言并解析
            result = mboss.SendUATicket(UAProvinceID,SPID, UATicket, AssertionAddress, this.Context, "SPCAData",TransactionID, out bil, out xml, out ErrMsg);
            AuthenType = bil.AccountType;
            AuthenName = bil.AccountID;

            if (result != 0)
            {
                Response.Redirect("../ErrorInfo.aspx?Result=-19999&ErrorInfo=请从网厅登陆1&FunctionName=请从网厅登陆1", true);
                return;
            }
            //用户入库是否存在
            int type=0;
            string p = bil.AccountID;
            string dealType = "";
            string areaid = "";
            string jtUAProvinceID = "";

            log("UAProvinceID:集团ua:" + UAProvinceID );

            if ("35".Equals(UAProvinceID))
            {
                if (!"".Equals(bil.ProvinceID))
                    jtUAProvinceID = bil.ProvinceID;
                else
                    jtUAProvinceID = UAProvinceID;

                result = 0;
                type = 1;
            }
            else
            {
                result = BTForBusinessSystemInterfaceRules.MUserAuthV2(SPID, UAProvinceID, bil.AccountID, bil.AccountType, bil.AccountInfos, Context,
                    out  ErrMsg, out  CustID, out  UserAccount, out  CustType, out  OutID, out  ProvinceID,
                    out  RealName, out  UserName, out  NickName, out dealType, out type, out areaid);
                log(bil.ProvinceID+"-!35-BTForBusinessSystemInterfaceRules.MUserAuthV2:" + result + "-bil.ProvinceID=" + bil.ProvinceID + "-UAProvinceID=" + UAProvinceID + "-areaid=" + areaid + "-custid=" + CustID + "-OutID=" + OutID + "-ErrMsg=" + ErrMsg);
            }

            string CustID1 = CustID;
            string RealName1="";
            string UserName1="";
            string NickName1="";
            string CustType1="";
            log("MUserAuthV2:" + result + ";CustID=" + CustID + " @----@" + ErrMsg + "==" + type);
            if (result!=0)
            {
                Response.Redirect("../ErrorInfo.aspx?Result=-19999&ErrorInfo="+ErrMsg+"&FunctionName=请从网厅登陆2", true);
                return;
            }
            //模式3情况下,获取证件号和类型
            string TestStr = "";
            if (type == 1 )
            {
                string OutID1 = "";
                if (QH.IndexOf(UAProvinceID) >= 0)
                {
                    if (bil.AccountType == "9" || bil.AccountType == "10" || bil.AccountType == "11")
                    {
                        if (areaid != "")
                        {
                            bil.AccountID = areaid + "-" + bil.AccountID;
                        }
                    }
                }
                else if (UAOUTID.IndexOf(UAProvinceID) >= 0)
                {
                    bil.AccountID = OutID;
                    bil.AccountType = "99";

                    RealName = bil.AccountID;
                }
                else
                {
                    if (bil.AccountType == "9" || bil.AccountType == "10" || bil.AccountType == "11")
                    {
                        string phone = "";
                        areaid = BTForBusinessSystemInterfaceRules.PhoneToArea(UAProvinceID, bil.AccountID, out phone);
                        if (areaid != "")
                        {
                            bil.AccountID = areaid +"-"+ phone;
                        }
                    }
                }

                int result1 = -1234;
                if ("35".Equals(UAProvinceID))
                {
                    log("CrmSSO.UserAuthCrm1:provinceid=" + bil.ProvinceID + ";areacode:" + bil.AccountInfos[0].areaid + ";accountid:" + bil.AudienceID + "|TestStr=" + TestStr);
                    result1 = CrmSSO.UserAuthCrm1(bil.ProvinceID, bil.AccountInfos[0].areaid, bil.AccountType, bil.AccountID, p, "", "0", UAProvinceID + "999991", this.Context, out RealName1, out UserName1, out NickName1, out OutID1, out CustType1, out CustID1, out ErrMsg, out TestStr);
                }
                else {
                    result1 = CrmSSO.UserAuthCrm(UAProvinceID, bil.AccountType, bil.AccountID, p, "", "0", UAProvinceID + "999991", this.Context, out RealName1, out UserName1, out NickName1, out OutID1, out CustType1, out CustID1, out ErrMsg, out TestStr);
                }

                if (result1 == 0)
                {
                    OutID = OutID1;
                    CustID = CustID1;
                    CustType = CustType1;
                }
                else {
                    Response.Redirect("../ErrorInfo.aspx?Result="+result1+"&ErrorInfo=" + ErrMsg + "&FunctionName=请从网厅登陆5", true);
                    return;
                }
                UserName = RealName1;
                NickName = RealName1;
                log(result1 + "==" + UAProvinceID + "=UAProvinceID;" + bil.AccountType + " =bil.AccountType;" + bil.AccountID + "=bil.AccountID;" + "" + "" + RealName + "=RealName;" + UserName + "=UserName;" + NickName +
                 "=NickName;" + OutID + "=OutID;" + CustType + "=CustType;" + CustID + "=CustID1;" + ErrMsg + "=ErrMsg");
            }

            if (dealType == "0" )            //通知积分系统
                CIP2BizRules.InsertCustInfoNotify(CustID, "2", System.Configuration.ConfigurationManager.AppSettings["ScoreBesttoneSPID"], "", "0", out ErrMsg);

            //生成cookie
            UserToken UT = new UserToken();
            string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, OutID, CustType,AuthenName,AuthenType,key, out ErrMsg);
            string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
            PageUtility.SetCookie(UserTokenValue, CookieName, this.Page);

            //生成ticket
            result = CIPTicketManager.insertCIPTicket(TransactionID, SPID, CustID, RealName, NickName, UserName, OutID, "", AuthenName, AuthenType, out ErrMsg);
            log("insertCIPTicket:" + ErrMsg + result);
            if (result != 0)
            {
                Response.Redirect("../ErrorInfo.aspx?Result=-19999&ErrorInfo=请从网厅登陆3&FunctionName=请从网厅登陆3", true);
                return;
            }

            string Url = Request.Cookies["ReturnURL"].Value.ToString(); // System.Configuration.ConfigurationManager.AppSettings["SSOReturnURL"]; ;

            PageUtility.ExpireCookie("ReturnURL", this.Page);
            PageUtility.ExpireCookie("SPID", this.Page);
            PageUtility.ExpireCookie("UAProvinceID", this.Page);
            PageUtility.ExpireCookie("TransactionID", this.Page);

            Response.Redirect(Url + "?Ticket=" + TransactionID);
        }
        catch (System.Exception ex)
        {
            ErrMsg=ex.Message;
        }
        finally
        {
            try
            {
                CommonBizRules.WriteDataCustAuthenLog(SPID, CustID, ProvinceID, AuthenType, AuthenName,"2", result, ErrMsg);
            }
            catch { }
        }
    }
        /// <summary> 
        /// ������֤v2
        /// ���ߣ�tongbo   ʱ�䣺2009-8-14
        /// </summary>
        public static int MUserAuthV3(string SPID, string UAProvinceID,string JFProvinceID, string AuthenName, string AuthenType, MBOSSClass.AuthenRecord[] AuthenRecords, HttpContext Context, out string ErrMsg, out string CustID, out string UserAccount, out string CustType, out string outerid, out string ProvinceID,
            out string RealName, out string UserName, out string NickName, out string dealType, out int type, out string areaid)
        {
            areaid = "";
            type = 0;
            int Result = ErrorDefinition.IError_Result_UnknowError_Code;
            ErrMsg = "";
            CustID = "";
            UserAccount = "";
            CustType = "";
            UserName = "";
            NickName = "";
            RealName = "";
            string UProvinceID = "";
            string SysID = "";

            int CrmResult = ErrorDefinition.IError_Result_UnknowError_Code;

            outerid = "";
            ProvinceID = "";
            dealType = "0";

            try
            {
                //5, E�ҿ�
                //6��c���ֻ��û���
                //7��c���ֻ��û��ֻ���
                //8��ʡ����ͨ��
                //��Զ����֤
                //string AuthenTypeSpan = "5,6,7,8";
                //if (AuthenTypeSpan.IndexOf(AuthenType) < 0) //������֤
                //{
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                string MSProvinceID = System.Configuration.ConfigurationManager.AppSettings["MSProvinceID"];
                if (UAProvinceID != "" && MSProvinceID.IndexOf(UAProvinceID) >= 0)
                {
                    cmd.CommandText = "dbo.up_Customer_OV3_Interface_MUserAuthV1";
                }
                else
                {
                    cmd.CommandText = "dbo.up_Customer_OV3_Interface_MUserAuthV3";
                    type = 1;
                }

                SqlParameter parSPID = new SqlParameter("@SPID", SqlDbType.VarChar, 8);
                parSPID.Value = SPID;
                cmd.Parameters.Add(parSPID);

                SqlParameter parAuthenName = new SqlParameter("@AuthenName", SqlDbType.VarChar, 256);
                parAuthenName.Value = AuthenName;
                cmd.Parameters.Add(parAuthenName);

                SqlParameter parAuthenType = new SqlParameter("@AuthenType", SqlDbType.VarChar, 2);
                parAuthenType.Value = AuthenType;
                cmd.Parameters.Add(parAuthenType);

                SqlParameter parAuthenRecords = new SqlParameter("@AuthenRecords", SqlDbType.Text);
                MBOSSClass.AuthenRecord[] au = new MBOSSClass.AuthenRecord[0];
                parAuthenRecords.Value = MBOSSClass.GenerateXmlForAuthenRecords(AuthenRecords == null ? au : AuthenRecords);
                cmd.Parameters.Add(parAuthenRecords);
                ErrMsg = MBOSSClass.GenerateXmlForAuthenRecords(AuthenRecords == null ? au : AuthenRecords);

                SqlParameter parProvinceID = new SqlParameter("@ProvinceID ", SqlDbType.VarChar, 2);
                parProvinceID.Value = UAProvinceID;
                cmd.Parameters.Add(parProvinceID);

                SqlParameter parJFProvinceID = new SqlParameter("@JFProvinceID ", SqlDbType.VarChar, 2);
                parJFProvinceID.Value = JFProvinceID;
                cmd.Parameters.Add(parJFProvinceID);

                SqlParameter parResult = new SqlParameter("@Result", SqlDbType.Int);
                parResult.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parResult);

                SqlParameter parErrMsg = new SqlParameter("@ErrMsg ", SqlDbType.VarChar, 256);
                parErrMsg.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parErrMsg);

                SqlParameter parCustID = new SqlParameter("@CustID ", SqlDbType.VarChar, 16);
                parCustID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parCustID);

                SqlParameter parUserAccount = new SqlParameter("@UserAccount ", SqlDbType.VarChar, 16);
                parUserAccount.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parUserAccount);

                SqlParameter parCustType = new SqlParameter("@CustType ", SqlDbType.VarChar, 2);
                parCustType.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parCustType);

                SqlParameter parUProvinceID = new SqlParameter("@UProvinceID ", SqlDbType.VarChar, 2);
                parUProvinceID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parUProvinceID);

                SqlParameter parSysID = new SqlParameter("@SysID ", SqlDbType.VarChar, 4);
                parSysID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parSysID);

                SqlParameter parAreaID = new SqlParameter("@AreaID ", SqlDbType.VarChar, 4);
                parAreaID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parAreaID);

                SqlParameter parOuterID = new SqlParameter("@outerid ", SqlDbType.VarChar, 30);
                parOuterID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parOuterID);

                SqlParameter parUserName = new SqlParameter("@UserName ", SqlDbType.VarChar, 30);
                parUserName.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parUserName);

                SqlParameter parRealName = new SqlParameter("@RealName ", SqlDbType.VarChar, 30);
                parRealName.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parRealName);

                SqlParameter parNickName = new SqlParameter("@NickName ", SqlDbType.VarChar, 30);
                parNickName.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parNickName);

                SqlParameter pardealType = new SqlParameter("@dealType ", SqlDbType.VarChar, 1);
                pardealType.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(pardealType);

                DBUtility.Execute(cmd, DBUtility.BestToneCenterConStr);

                Result = int.Parse(parResult.Value.ToString());
                ErrMsg = parErrMsg.Value.ToString();
                CustID = parCustID.Value.ToString();
                UserAccount = parUserAccount.Value.ToString();
                CustType = parCustType.Value.ToString();
                UProvinceID = parUProvinceID.Value.ToString();
                SysID = parSysID.Value.ToString();
                areaid = parAreaID.Value.ToString();

                outerid = parOuterID.Value.ToString();
                ProvinceID = UProvinceID;
                dealType = pardealType.Value.ToString();

                NickName = parNickName.Value.ToString();
                UserName = parUserName.Value.ToString();
                RealName = parRealName.Value.ToString();

                return Result;

            }
            catch (Exception ex)
            {
                Result = ErrorDefinition.IError_Result_System_UnknowError_Code;
                ErrMsg = ex.Message;
            }

            return Result;
        }
Exemple #11
0
    protected void ssoFunc()
    {
        string UAProvinceID = Request["ProvinceID"];
        PageUtility.SetCookie(UAProvinceID, "UAProvinceID", this.Page);

        if (CommonUtility.IsParameterExist("UATicket", this.Page))
        {
            Response.Redirect("SelectAssertion.aspx?UATicket=" + Request["UATicket"]);
        }
        if (CommonUtility.IsParameterExist("ProvinceID", this.Page))
        {
            ReturnURL = Request.Cookies["ReturnURL"].Value.ToString();
        }
        else
            return ;

        USPID = UAProvinceID + "999991";

        //1判断全局Token是否存在
        try
        {
            MBOSSClass mboss = new MBOSSClass();
            //MBOSSClass.SSOAddressResp SSOAddress;
            //Result = mboss.AuthenSelectArddess(ProvinceID, this.Context, "SPCAData", out SSOAddress, out ErrMsg);
            //if (Result != 0)
            //{
            //    SendJF();
            //    return;
            //}
            //string SSOAddress1 = SSOAddress.SSOAddress;//省级UA的SSO接入地址
            //string AssertionAddress1 = SSOAddress.AssertionAddress;//省级UA的断言查询地址

            //获取SSO认证地址和断言查询地址
            Result = mboss.GetMBOSSAddress(this.Context, USPID, out AssertionAddress, out SSOAddress, out ErrMsg);
            if (Result != 0)
            {
                SendJF();
                return;
            }

            PageUtility.SetCookie(AssertionAddress, "AssertionAddress", this.Page);
            PageUtility.SetCookie(SSOAddress, "SSOAddress", this.Page);

            //SPID = this.Response.Cookies["SPID"].Value.ToString();
            //向归属地UA发送身份认证请求
            //MBOSSClass.AcceptAccountTypeList[] acs = new MBOSSClass.AcceptAccountTypeList[1];
            //MBOSSClass.AcceptAccountTypeList ac = new MBOSSClass.AcceptAccountTypeList();
            //ac.AcceptAccountType = "0000000";
            //acs[0] = ac;
            MBOSSClass.AcceptAccountTypeList[] acs = new MBOSSClass.AcceptAccountTypeList[1];
            MBOSSClass.AcceptAccountTypeList ac = new MBOSSClass.AcceptAccountTypeList();
            //ac.AcceptAccountType = "2000001";

            //acs[0] = ac;
            //MBOSSClass.AcceptAccountTypeList ac1 = new MBOSSClass.AcceptAccountTypeList();
            //ac1.AcceptAccountType = "2000002";
            //acs[1] = ac1;
            //MBOSSClass.AcceptAccountTypeList ac2 = new MBOSSClass.AcceptAccountTypeList();
            //ac2.AcceptAccountType = "2000003";
            //acs[2] = ac2;
            //MBOSSClass.AcceptAccountTypeList ac3 = new MBOSSClass.AcceptAccountTypeList();
            //ac3.AcceptAccountType = "2000004";
            //acs[3] = ac3;

            //MBOSSClass.AcceptAccountTypeList ac4 = new MBOSSClass.AcceptAccountTypeList();
            ac.AcceptAccountType = "0000000";
            acs[0] = ac;

            string ResultXML = "";
            string TransactionID = "";
            string SelectAssertion = System.Configuration.ConfigurationManager.AppSettings["SelectAssertion"];

            log("积分商城ReturnURL=" + ReturnURL);
            Result = mboss.SSOAuthanXML(UAProvinceID,SPID, SelectAssertion, acs, this.Context, "SPCAData", out ResultXML, out ErrMsg, out TransactionID);
            log(" mboss.SSOAuthanXML Result" + Result + "ResultXML " + ResultXML + "ErrMsg" + ErrMsg);

            if (Result != 0)
            {
                SendJF();
                return;
            }

            PageUtility.SetCookie(TransactionID, "TransactionID", this.Page);

            //post到sso认证地址
            Response.Write("<form name='frm' id='frm' action='" + SSOAddress + "' method='post'>");
            Response.Write("<input name='SSORequestXML' value='" + ResultXML + "'  type='hidden'  >");
            Response.Write("</form>");
            Response.Write("<script language='javascript'>frm.submit();</script>");
        }
        catch (Exception err)
        {
            SendJF();
            return;
        }
    }
Exemple #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        log("step1");
        int Result = ErrorDefinition.IError_Result_UnknowError_Code;
        log("step2");
        if (CommonUtility.IsParameterExist("SSORequestXML", this.Page))  // 带着token过来的是网厅的认证请求
        {
            #region 隐藏
            MBOSSClass mboss = new MBOSSClass();

            SPInfoManager spInfo = new SPInfoManager();
            string SPID = "35999991";
            string UAProvinceID = "35";
            string SourceType = "";
            string uaURL = "";
            string privateKeyPassword = "";
            string UserName = "";
            string ErrMsg = "";

            string CAP01002_XML = Request["SSORequestXML"];

            string DigitalSign = MBOSSClass.GetNewXML(CAP01002_XML, "DigitalSign");

            string DigitalSignValue = MBOSSClass.GetValueFromXML(CAP01002_XML, "DigitalSign");
            //从中取出RedirectURL
            string RedirectURL = MBOSSClass.GetValueFromXML(CAP01002_XML, "RedirectURL");
            //验证 CAP01002_XM 合法性
            byte[] PublicKeyFile = new byte[0];

            try
            {
                Object SPData = spInfo.GetSPData(this.Context, "");  //SPDataCacheName 这里要去问tongbo
                PublicKeyFile = spInfo.GetCAInfo(SPID, 0, SPData, out UserName, out privateKeyPassword);
            }
            catch (Exception err)
            {
                //验证签名未通过
                ErrMsg = err.Message;
                Result = -20001;
                Response.Redirect(RedirectURL, true);
                return;
            }

            Result = mboss.VerifySignByPublicKey(DigitalSign, PublicKeyFile, DigitalSignValue, out ErrMsg);
            //<CAPRoot><SessionHeader><ServiceCode>CAP01003</ServiceCode><Version>mbossUacVersion1</Version><ActionCode>0</ActionCode><TransactionID>35000201109254969771818</TransactionID><SrcSysID>35000</SrcSysID><DigitalSign>302C02141DB53BC5D52562D69EFD959B32F6E10D4BF6421E02145983D67CC81B0F376CA688B39F6AD1896EA0E082</DigitalSign><DstSysID>18</DstSysID><ReqTime>20110925000030</ReqTime><Request><ReqType/><ReqCode/><ReqDesc/></Request></SessionHeader><SessionBody><SPSSOAuthReq><RedirectURL>http://Customer.besttone.com.cn/UserPortal/SSO/SelectAssertion.aspx</RedirectURL><AcceptAccountTypeList><AcceptAccountType>0000000</AcceptAccountType></AcceptAccountTypeList></SPSSOAuthReq></SessionBody></CAPRoot>
            log("从网厅来:" + CAP01002_XML );
            if (Result != 0)
            {
                // 签名校验未通过,直接将请求原路打回
                Response.Redirect(RedirectURL, true);
                return;
            }
            string sessionid = this.Page.Session.SessionID;
            string globaltoken  = Request.Cookies[sessionid].Value.ToString();
            uaURL = RedirectURL;
            if (globaltoken != null && !"".Equals(globaltoken)){
                this.sendTicket2UA(uaURL);
            }else{
                this.Response.Redirect(uaURL);
            }

            #endregion
        }
        else
        {
            //不带token的是积分商城过来的认证请求
            string direction = Request["Direction"];
            string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
            string key0 = System.Configuration.ConfigurationManager.AppSettings["ScoreSystemSecret"];

            if (CommonUtility.IsParameterExist("Direction", this.Page))
            {
                #region 反向登录到集团网厅方向
                string ProvinceID = Request["ProvinceID"];
                if ("uam".Equals(direction))
                {
                    //获取本地的token,如果没有token则返回到积分商城登录
                    //string token = Request.Cookies[CookieName].Value;
                    String token = PageUtility.GetCookie(CookieName);
                    if (String.IsNullOrEmpty(token))
                        Response.Redirect("http://www.ct10000.com");

                    string ProvinceID0 = "";  // 2013.01.23 添加
                    string CustID0 = "";
                    string RealName0 = "";
                    string UserName0 = "";
                    string NickName0 = "";
                    string OuterID0 = "";
                    string CustType0 = "";
                    string AuthenName0 = "";
                    string AuthenType0 = "";
                    string ErrMsg0 = "";

                    //解析token
                    UserToken UT0 = new UserToken();
                    // 2013.01.23 修改
                    //int Result0 = UT0.ParseUserToken(token, key0, out CustID0, out RealName0, out UserName0, out NickName0, out OuterID0, out CustType0, out AuthenName0, out AuthenType0, out ErrMsg0);
                    int Result0 = UT0.ParseScoreUserToken(token, key0,  out ProvinceID0, out CustID0, out RealName0, out UserName0, out NickName0, out OuterID0, out CustType0, out AuthenName0, out AuthenType0, out ErrMsg0);
                    //日志
                    log(String.Format("【token解析结果:】Result:{0},ErrMsg:{1},AuthenName:{2},AuthenType:{3},CustID:{4},OuterID:{5},CustType:{6}", Result0, ErrMsg0, AuthenName0, AuthenType0, CustID0, OuterID0, CustType0));

                    if (Result0 == 0)
                    {
                        //生成ticket,反向单点登录要求ticket前面加上省id
                        //string sDate = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                        //Random r = new Random();
                        //string ticket = ProvinceID + sDate + r.Next(10000, 99999).ToString();
                        string ticket = ProvinceID + CommonBizRules.CreateTicket();
                        //积分商城
                        SPID = "35000010";
                        //将ticket插入数据库
                        Result = CIPTicketManager.insertCIPTicket(ticket, SPID, CustID0, RealName0, NickName0, UserName0, OuterID0, "", AuthenName0, AuthenType0, out ErrMsg0);

                        log(String.Format("【ticket生成结果:{0}】Result:{1},ErrMsg:{2},ticket:{3}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Result, ErrMsg0, ticket));

                        if (Result != 0)
                        {
                            this.Response.Redirect("http://www.ct10000.com");
                        }
                        string uamURL = System.Configuration.ConfigurationManager.AppSettings["UAMUrl"] + "?AccountIndex=" + ticket;

                        log(String.Format("【登录网厅:{0}】uamURL:{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), uamURL));

                        this.Response.Redirect(uamURL);
                    }
                    else
                    {
                        this.Response.Redirect("http://www.ct10000.com");
                    }
                }
                else
                {
                    this.Response.Redirect("http://www.ct10000.com");
                }
            #endregion
            }
            else
            {
                if (!this.IsPostBack)
                {
                    #region 积分商城直接登录

                    string SPTokenRequest = Request["SPTokenRequest"];
                    log(String.Format("【SPTokenRequest参数为:{1}】SPTokenRequest:{0}", SPTokenRequest, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));

                    string key = System.Configuration.ConfigurationManager.AppSettings["ScoreSystemSecret"];
                    string JFLoginUrl = System.Configuration.ConfigurationManager.AppSettings["JFLoginUrl"];
                    //生成全局token写入cookie,该全局token为了将来网厅请求时候,查询该客户登陆状态用
                    UserToken UT = new UserToken();

                    ProvinceID = Request["ProvinceID"];
                    AuthenType = Request["AuthenType"];
                    AuthenName = Request["AuthenName"];
                    Password = Request["Password"];
                    ReturnURL = Request["ReturnURL"];   // 这个ReturnUrl 用来还给积分商城ticket用
                    AccountType = Request["AccountType"];

                    string RealName = "";
                    string UserName = "";
                    string NickName = "";
                    string CustType = "";
                    string CustID = "";
                    string ErrMsg = "";
                    string OutID = "";
                    string UserAccount = "";
                    string SPID = "";

                    //解析SPTokenRequest参数
                    int Resultjf = SSOClass.ParseJFLoginRequest(SPTokenRequest, this.Context, out SPID, out ProvinceID, out AuthenType, out AuthenName, out Password, out ReturnURL, out ErrMsg);

                    if (Resultjf != 0)
                    {
                        //日志
                        log(String.Format("【解析SPTokenRequest参数失败:{0}】Result:{1},ErrMsg:{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Result, ErrMsg));
                        string err = System.Web.HttpUtility.UrlEncode("积分商城请求的token解密失败!ErrMsg=" + ErrMsg, Encoding.UTF8);
                        Response.Redirect(JFLoginUrl + "?Result=" + Resultjf + "&ErrMsg=" + err, true);
                        return;
                    }
                    //日志
                    log(String.Format("【解析SPTokenRequest参数成功:{0}】SPID:{1},ProvinceID:{2},AuthenType:{3},AuthenName:{4},ReturnURL:{5}",
                        DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SPID, ProvinceID, AuthenType, AuthenName, ReturnURL));

                    string o_ProvinceID = "";
                    Result = BTForBusinessSystemInterfaceRules.UserAuthV2(SPID, AuthenName, AuthenType, Password, this.Context, ProvinceID, "", "",
                        out  ErrMsg, out  CustID, out  UserAccount, out  CustType, out  OutID, out  o_ProvinceID, out  RealName, out  UserName, out  NickName);

                    //日志
                    log(String.Format("【Crm认证结果:{0}】Result:{1},ErrMsg:{2},CustID:{3},UserAccount:{4},CustType:{5},OutID:{6},ProvinceID:{7}",
                        DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Result, ErrMsg, CustID, UserAccount, CustType, OutID, o_ProvinceID));

                    if (Result != 0)
                    {
                        string err = System.Web.HttpUtility.UrlEncode(ErrMsg, Encoding.UTF8);
                        string jf_loginUrl = "";
                        if (ReturnURL.IndexOf("?") > 0)
                        {
                            jf_loginUrl = ReturnURL + "&Result=" + Result + "&ErrMsg=" + err;
                        }
                        else
                        {
                            jf_loginUrl = ReturnURL + "?Result=" + Result + "&ErrMsg=" + err;
                        }

                        //直接将请求原路打回 --假设请求中有ReturnURL
                        Response.Redirect(jf_loginUrl + "", true);
                        return;
                    }
                    //生成token 修改 2013.01.23
                    string UserTokenValue = UT.GenerateJFUserToken(ProvinceID,CustID, RealName, UserName, NickName, OutID, CustType, AuthenName, AuthenType, key, out ErrMsg);
                    //UT.GenerateUserToken(CustID, RealName, UserName, NickName, OutID, CustType, AuthenName, AuthenType, key, out ErrMsg);
                    log("token-Result:" + Result);
                    string CookieName0 = System.Configuration.ConfigurationManager.AppSettings["CookieName"];  //CookieName = CIPUT
                    PageUtility.SetCookie(UserTokenValue, CookieName0, this.Page);

                    //生成流水号
                    //string TransactionId = "";
                    //string sDate = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    //Random r = new Random(Guid.NewGuid().GetHashCode());
                    //TransactionId = "35999999" + sDate + r.Next(10000, 99999).ToString();
                    String TransactionId = "35999999" + CommonBizRules.CreateTransactionID();

                    //生成ticket
                    //sDate = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    //r = new Random();
                    //string Ticket = sDate + r.Next(10000, 99999).ToString();
                    String Ticket = CommonBizRules.CreateTicket();

                    StringBuilder msg0 = new StringBuilder();
                    msg0.Append("++++++++++++++++++++++++++++++++++++++token===++++++++++++++++++++" + UserTokenValue + "++++++++++++++++++++++++++\r\n");
                    BTUCenterInterfaceLog.CenterForBizTourLog("REVERSE-SSO", msg0);

                    this.sendTicket2JF(Ticket, CustID, RealName, UserAccount, OutID, UserName, AuthenName, AuthenType, NickName);

                    #endregion
                }
            }
        }
    }