예제 #1
0
        /// <summary>
        /// 解析从UDB查询用户信息返回的xml
        /// </summary>
        public static Int32 ParseAccountInfoQueryXml(String xmlStr, out UDBAccountInfo accountInfo, out String ErrMsg)
        {
            Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;

            ErrMsg      = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            accountInfo = new UDBAccountInfo();
            try
            {
                //加载xml
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlStr);
                XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
                manager.AddNamespace("UDB", "http://udb.chinatelecom.com");

                //解析xml数据
                Result = Convert.ToInt32(xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:ResultCode", manager).InnerText);
                accountInfo.UserType = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserType", manager).InnerText;

                XmlNode node = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:ReturnUserGroupList", manager);

                accountInfo.UserID          = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserID", manager).InnerText;
                accountInfo.UserIDType      = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserIDType", manager).InnerText;
                accountInfo.PUserID         = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:PUserID", manager).InnerText;
                accountInfo.Alias           = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Alias", manager).InnerText;
                accountInfo.BindingAccessNo = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:BindingAccessNo", manager).InnerText;
                accountInfo.ThirdSsUserID   = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:ThirdSsUserID", manager).InnerText;
                accountInfo.UserIDStatus    = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserIDStatus", manager).InnerText;
                accountInfo.UserIDSsStatus  = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserIDSsStatus", manager).InnerText;
                accountInfo.UserPayType     = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserPayType", manager).InnerText;
                accountInfo.PrePaySystemNo  = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:PrePaySystemNo", manager).InnerText;
                String temp_Description = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Description", manager).InnerText;
                accountInfo.Description = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Description", manager).InnerText;
                if (Result == 0 || Result == 5)
                {
                    //<Ex><PID>07</PID><NF>2</NF></Ex>
                    Int32 startIndex = temp_Description.IndexOf("<PID>");
                    Int32 endIndex   = temp_Description.IndexOf("</PID>");
                    accountInfo.ProvinceID = temp_Description.Substring(startIndex + 5, endIndex - startIndex - 5);
                    startIndex             = temp_Description.IndexOf("<NF>");
                    endIndex            = temp_Description.IndexOf("</NF>");
                    accountInfo.NumFlag = temp_Description.Substring(startIndex + 4, endIndex - startIndex - 4);
                }
                else
                {
                    ErrMsg = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Description", manager).InnerText;
                }
            }
            catch (Exception ex)
            {
                ErrMsg += ex.Message;
            }

            return(Result);
        }
예제 #2
0
    /// <summary>
    /// 开始UDBSSO功能
    /// </summary>
    protected void BeginUDBSSO()
    {
        StringBuilder strMsg = new StringBuilder();
        Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        String ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
        try
        {
            #region 获取参数并验证

            SPID = Request["SPID"];
            ReturnUrl = Request["ReturnUrl"] == null ? String.Empty : Request["ReturnUrl"];
            PassportLoginResponseValue = Request["PassportLoginResponse"];
            strMsg.AppendFormat("从门户过来【验证参数,DateTime:{0}】:SPID:{1},PassportLoginResponse:{2},ReturnUrl:{3}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SPID, PassportLoginResponseValue, ReturnUrl);
            UDBKey = System.Configuration.ConfigurationManager.AppSettings["UdbKey"];

            //解析PassportLoginResponseValue
            String[] tempArray = PassportLoginResponseValue.Split('$');
            DesSsDeviceNo = tempArray[0];
            String tempStr = CryptographyUtil.Decrypt(tempArray[1], UDBKey);
            String[] digestArray = tempStr.Split('$');
            Result = Convert.ToInt32(digestArray[0]);
            UDBTicket = digestArray[1];
            String timeStamp = digestArray[2];
            String digest = digestArray[3];

            String newDigest = CryptographyUtil.ToBase64String(CryptographyUtil.Hash(Result + DesSsDeviceNo + UDBTicket + timeStamp));
            strMsg.AppendFormat(",DesSsDeviceNo:{0},Result:{1},UDBTicket{2},timeStamp:{3},digest:{4},newDigest:{5}\r\n", DesSsDeviceNo, Result, UDBTicket, timeStamp, digest, newDigest);
            if (!digest.Equals(newDigest))
            {
                //digest不吻合,失败
                strMsg.AppendFormat(",ErrMsg:{0}", "digest有误不匹配");
                Redirect("ErrMsg", "digest有误不匹配");
            }
            if (Result != 0)
            {
                //失败,则返回
                strMsg.AppendFormat(",ErrMsg:{0}", "返回Ticket失败");
                Redirect("ErrMsg", "返回Ticket失败");
            }

            #endregion

            #region 根据UDBTkcket到UDB查询用户信息

            strMsg.Append("【开始查询信息】:");

            UDBAccountInfo accountInfo = new UDBAccountInfo();

            //根据UDBTicket到UDB查询用户信息
            //Result = _UDBMBoss.AccountInfoCheck("3500000000408201", "3500000000408201", UDBTicket, UDBKey, out accountInfo, out ErrMsg);
            Result = _UDBMBoss.AccountInfoQuery("3500000000408201", "3500000000408201", UDBTicket, UDBKey, out accountInfo, out ErrMsg);
            accountInfo.SourceSPID = UDBConstDefinition.DefaultInstance.UDBSPID;
            strMsg.AppendFormat(",Result:{0},UserID:{1},UserIDType:{2},UserType:{3},PUserID:{4},Alias:{5},UserIDStatus:{6},UserIDSsStatus:{7},Description:{8},ProvinceID:{9},NumFlag:{10}\r\n",
                Result, accountInfo.UserID, accountInfo.UserIDType, accountInfo.UserType, accountInfo.PUserID, accountInfo.Alias, accountInfo.UserIDStatus, accountInfo.UserIDSsStatus, accountInfo.Description, accountInfo.ProvinceID, accountInfo.NumFlag);
            if (Result == 0)
            {
                String CustID, OuterID, Status, CustType, CustLevel, RealName, UserName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                //检测对应用户是否在号百系统,不在,则注册进来
                strMsg.Append("【开始注册到号百】:");
                Result = UserRegistry.getUserRegistryUDB(accountInfo, out CustID, out ErrMsg);
                strMsg.AppendFormat("Result:{0},CustID:{1}\r\n", Result, CustID);

                //注册成功
                if (Result == 0)
                {
                    Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
                        out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
                        out AreaID, out RegistrationSource);

                    //登录tab写入cookie
                    PageUtility.SetCookie("LoginTabCookie", "UDBTab");

                    logger.Info("CustID="+CustID+"\r\nOuterID="+OuterID+"\r\nRealName="+RealName+"\r\nUserName="******"\r\nNickName="+NickName);
                    if (Result != 0)
                    {
                        strMsg.Append(",ErrMsg:客户不存在" + CustID);
                        //客户不存在
                        Redirect("ErrMsg", "客户不存在");
                    }
                    else
                    {

                        if (RealName != null && !"".Equals(RealName))
                        {
                            welcomeName = RealName;
                        }
                        else if (NickName != null && !"".Equals(NickName))
                        {
                            welcomeName = NickName;
                        }
                        else if (UserName != null && !"".Equals(UserName))
                        {
                            welcomeName = UserName;
                        }
                        else {
                            welcomeName = accountInfo.UserID;
                        }

                        if (ReturnUrl.IndexOf("?") > 0)
                        {
                            ReturnUrl = ReturnUrl + "&CustID=" + CustID + "&welcomeName=" + welcomeName+"&UserID="+accountInfo.UserID+"&PUserID="+accountInfo.PUserID;

                        }
                        else
                        {
                            ReturnUrl = ReturnUrl + "?CustID=" + CustID + "&welcomeName=" + welcomeName+"&UserID="+accountInfo.UserID+"&PUserID="+accountInfo.PUserID;
                        }

                        Response.Redirect(ReturnUrl, false);

                    }

                }
                else
                {
                    strMsg.Append(",ErrMsg:用户注册到号百失败");
                    Redirect("ErrMsg", "用户注册到号百失败" + ErrMsg);
                }
            }
            else if (Result == 5)
            {
                strMsg.Append(",ErrMsg:用户已删除");
                Redirect("ErrMsg", "用户已删除");
            }
            else
            {
                strMsg.Append(",ErrMsg:查询用户信息失败");
                Redirect("ErrMsg", "查询用户信息失败");
            }

            #endregion
        }
        catch (Exception ex)
        {
            strMsg.AppendFormat(",ErrMsg:{0}", ex.Message);
        }
        finally
        {
            WriteLog(strMsg.ToString());
        }
    }
예제 #3
0
파일: UDBMBOSS.cs 프로젝트: noikiy/lihongtu
        /// <summary>
        /// ����UDBTicket��ѯ�û���Ϣ
        /// </summary>
        public Int32 AccountInfoQuery(String SrcSsDeviceNo, String AuthSsDeviceNo, String UDBTicket, String key, out UDBAccountInfo accountInfo, out String ErrMsg)
        {
            Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            accountInfo = new UDBAccountInfo();
            StringBuilder strMsg = new StringBuilder();
            strMsg.AppendFormat("��AccountInfoQuery,DateTime:{3}��SrcSsDeviceNo:{0},AuthSsDeviceNo:{1},UDBTicket:{2}", SrcSsDeviceNo, AuthSsDeviceNo, UDBTicket, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            try
            {
                String timeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                String digest = CryptographyUtil.GenerateAuthenticator(SrcSsDeviceNo + AuthSsDeviceNo + UDBTicket + timeStamp, key);
                strMsg.AppendFormat(",timeStamp:{0},digest:{1}", timeStamp, digest);

                UDBAppSys serviceProxy = new UDBAppSys();
                serviceProxy.Url = UDBConstDefinition.DefaultInstance.BJSOAPUrl;
                AccountInfoCheckResult accountInfoResult = serviceProxy.AccountInfoCheck(digest, SrcSsDeviceNo, AuthSsDeviceNo, UDBTicket, timeStamp);

                if (accountInfoResult != null)
                {
                    Result = accountInfoResult.ResultCode;

                    accountInfo.UserID = accountInfoResult.UserID;
                    accountInfo.UserIDType = accountInfoResult.UserIDType;
                    accountInfo.PUserID = accountInfoResult.PUserID;
                    accountInfo.Alias = accountInfoResult.Alias;
                    accountInfo.BindingAccessNo = accountInfoResult.BindingAccessNo;
                    accountInfo.ThirdSsUserID = accountInfoResult.ThirdSsUserID;
                    accountInfo.UserIDStatus = accountInfoResult.UserIDStatus;
                    accountInfo.UserIDSsStatus = accountInfoResult.UserIDSsStatus;
                    accountInfo.UserPayType = accountInfoResult.UserPayType;
                    accountInfo.PrePaySystemNo = accountInfoResult.PrePaySystemNo;
                    accountInfo.UserType = accountInfoResult.UserType.ToString();
                    String temp_Description = accountInfoResult.Description;
                    ErrMsg = temp_Description;

                    strMsg.AppendFormat("����ѯ�����Result:{0},UserID:{1},UserIDType:{2},PUserID:{3},Alias:{4},BindingAccessNo:{5},ThirdSsUserID:{6},UserIDStatus:{7},UserIDSsStatus:{8},UserPayType:{9},PrePaySystemNo:{10},UserType:{11},temp_Description:{12}",
                        Result, accountInfo.UserID, accountInfo.UserIDType, accountInfo.PUserID, accountInfo.Alias, accountInfo.BindingAccessNo, accountInfo.ThirdSsUserID, accountInfo.UserIDStatus, accountInfo.UserIDSsStatus, accountInfo.UserPayType, accountInfo.PrePaySystemNo, accountInfo.UserType, temp_Description);

                    if (Result == 0 || Result == 5)
                    {
                        //<Ex><PID>07</PID><NF>2</NF></Ex>
                        Int32 startIndex = temp_Description.IndexOf("<PID>");
                        Int32 endIndex = temp_Description.IndexOf("</PID>");
                        accountInfo.ProvinceID = temp_Description.Substring(startIndex + 5, endIndex - startIndex - 5);
                        startIndex = temp_Description.IndexOf("<NF>");
                        endIndex = temp_Description.IndexOf("</NF>");
                        accountInfo.NumFlag = temp_Description.Substring(startIndex + 4, endIndex - startIndex - 4);
                    }
                }
                else
                {
                    strMsg.Append(",��ѯ�û���Ϣʧ��");
                }

                #region ����

                ////�������webservice����
                //Hashtable hs = new Hashtable();
                //hs.Add("Authenticator", digest);
                //hs.Add("SrcSsDeviceNo", SrcSsDeviceNo);
                //hs.Add("AuthSsDeviceNo", AuthSsDeviceNo);
                //hs.Add("UDBTicket", UDBTicket);
                //hs.Add("TimeStamp", timeStamp);
                //strMsg.AppendFormat(",url:{0}", UDBConstDefinition.DefaultInstance.BJSOAPUrl);

                //String method = UDBConstDefinition.DefaultInstance.UserWebServiceMethod;
                //if (method.ToUpper() == "GET")
                //{
                //    returnXml = WebServiceCommon.QueryGetWebService(UDBConstDefinition.DefaultInstance.BJSOAPUrl, "AccountInfoCheck", hs).OuterXml;
                //}
                //else if (method.ToUpper() == "POST")
                //{
                //    returnXml = WebServiceCommon.QueryPostWebService(UDBConstDefinition.DefaultInstance.BJSOAPUrl, "AccountInfoCheck", hs).OuterXml;
                //}
                //else
                //{
                //    returnXml = WebServiceCommon.QuerySoapWebService(UDBConstDefinition.DefaultInstance.BJSOAPUrl, "AccountInfoCheck", hs).OuterXml;
                //}

                //strMsg.AppendFormat(",returnXml:{0}", returnXml);
                ////�������ص��û���Ϣxml
                //Result = UDBBusiness.ParseAccountInfoQueryXml(returnXml, out accountInfo, out ErrMsg);

                #endregion

            }
            catch (Exception ex)
            {
                ErrMsg += ex.Message;
                strMsg.AppendFormat(",ErrMsg:{0}", ErrMsg);
            }
            finally
            {
                WriteLog(strMsg.ToString());
            }

            return Result;
        }
예제 #4
0
    /// <summary>
    /// 开始UDBSSO功能
    /// </summary>
    protected void BeginUDBSSO()
    {
        StringBuilder strMsg = new StringBuilder();
        Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        String ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
        try
        {
            #region 获取参数并验证

            SPID = Request["SPID"];
            String temp_ReturnUrl = Request["ReturnUrl"] == null ? String.Empty : Request["ReturnUrl"];
            PassportLoginResponseValue = Request["PassportLoginResponse"];
            strMsg.AppendFormat("【验证参数,DateTime:{0}】:SPID:{1},PassportLoginResponse:{2},temp_ReturnUrl:{3}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SPID, PassportLoginResponseValue, temp_ReturnUrl);
            //根据SPID查询应用系统对应的UDBSPID信息
            UDBSPInfoBO _udbspinfo_bo = new UDBSPInfoBO();
            UDBSPInfo _udbspinfo_entity = _udbspinfo_bo.GetBySPID(SPID);
            if (_udbspinfo_entity != null)
            {
                UDBSPID = _udbspinfo_entity.UDBSPID;
                UDBKey = _udbspinfo_entity.UDBKey;
                ReturnUrl = _udbspinfo_entity.RedirectUrl;
            }
            else
            {
                UDBSPID = UDBConstDefinition.DefaultInstance.BesttoneUDBSPID;
                UDBKey = UDBConstDefinition.DefaultInstance.BesttoneUDBKey;
                ReturnUrl = UDBConstDefinition.DefaultInstance.UDBLoginSuccessRedirectUrl;
            }

            if (String.IsNullOrEmpty(ReturnUrl))
            {
                //其他业务系统的Ticket解析页面是不固定的,通过参数ReturnUrl传递
                ReturnUrl = temp_ReturnUrl;
            }
            else
            {
                //针对精品商城,精品商城的Ticket解析页面是固定的,是配在数据库中,而此时参数ReturnUrl及为最终认证成功的跳转页面
                if (!String.IsNullOrEmpty(temp_ReturnUrl))
                {
                    if (ReturnUrl.IndexOf('?') >= 0)
                    {
                        ReturnUrl += "&ReturnUrl=" + HttpUtility.UrlEncode(temp_ReturnUrl);
                    }
                    else
                    {
                        ReturnUrl += "?ReturnUrl=" + HttpUtility.UrlEncode(temp_ReturnUrl);
                    }
                }
            }

            strMsg.AppendFormat(",ReturnUrl:{0}", ReturnUrl);

            //根据客户信息平台的SPID,获取在客户信息平台的key
            SPInfoManager spInfo = new SPInfoManager();
            Object SPData = spInfo.GetSPData(this.Context, "SPData");
            key = spInfo.GetPropertyBySPID(SPID, "SecretKey", SPData);

            //解析PassportLoginResponseValue
            String[] tempArray = PassportLoginResponseValue.Split('$');
            DesSsDeviceNo = tempArray[0];
            String tempStr = CryptographyUtil.Decrypt(tempArray[1], UDBKey);
            String[] digestArray = tempStr.Split('$');
            Result = Convert.ToInt32(digestArray[0]);
            UDBTicket = digestArray[1];
            String timeStamp = digestArray[2];
            String digest = digestArray[3];

            String newDigest = CryptographyUtil.ToBase64String(CryptographyUtil.Hash(Result + DesSsDeviceNo + UDBTicket + timeStamp));
            strMsg.AppendFormat(",DesSsDeviceNo:{0},Result:{1},UDBTicket{2},timeStamp:{3},digest:{4},newDigest:{5}\r\n", DesSsDeviceNo, Result, UDBTicket, timeStamp, digest, newDigest);
            if (!digest.Equals(newDigest))
            {
                //digest不吻合,失败
                strMsg.AppendFormat(",ErrMsg:{0}", "digest有误不匹配");
                Redirect("ErrMsg", "digest有误不匹配");
            }
            if (Result != 0)
            {
                //失败,则返回
                strMsg.AppendFormat(",ErrMsg:{0}", "返回Ticket失败");
                Redirect("ErrMsg", "返回Ticket失败");
            }

            #endregion

            #region 根据UDBTkcket到UDB查询用户信息

            strMsg.Append("【开始查询信息】:");

            UDBAccountInfo accountInfo = new UDBAccountInfo();

            //根据UDBTicket到UDB查询用户信息
            Result = _UDBMBoss.AccountInfoQuery(UDBSPID, UDBSPID, UDBTicket, UDBKey, out accountInfo, out ErrMsg);
            accountInfo.SourceSPID = UDBConstDefinition.DefaultInstance.UDBSPID;
            strMsg.AppendFormat(",Result:{0},UserID:{1},UserIDType:{2},UserType:{3},PUserID:{4},Alias:{5},UserIDStatus:{6},UserIDSsStatus:{7},Description:{8},ProvinceID:{9},NumFlag:{10}\r\n",
                Result, accountInfo.UserID, accountInfo.UserIDType, accountInfo.UserType, accountInfo.PUserID, accountInfo.Alias, accountInfo.UserIDStatus, accountInfo.UserIDSsStatus, accountInfo.Description, accountInfo.ProvinceID, accountInfo.NumFlag);

            if (Result == 0)
            {
                String CustID, OuterID, Status, CustType, CustLevel, RealName, UserName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                //检测对应用户是否在号百系统,不在,则注册进来
                strMsg.Append("【开始注册到号百】:");
                Result = UserRegistry.getUserRegistryUDB(accountInfo, out CustID, out ErrMsg);
                strMsg.AppendFormat("Result:{0},CustID:{1}\r\n", Result, CustID);

                //注册成功
                if (Result == 0)
                {
                    Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
                        out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
                        out AreaID, out RegistrationSource);
                    if (Result != 0)
                    {
                        strMsg.Append(",ErrMsg:客户不存在" + CustID);
                        //客户不存在
                        Redirect("ErrMsg", "客户不存在");
                    }
                    //生成token
                    UserToken UT = new UserToken();
                    String userTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, OuterID, CustType, accountInfo.UserID, UDBBusiness.ConvertAuthenType(accountInfo.NumFlag), key, out ErrMsg);
                    String CookieName = ConfigurationManager.AppSettings["CookieName"];
                    PageUtility.SetCookie(CookieName, userTokenValue, this.Page);

                    //生成Ticket
                    String ticket = CommonBizRules.CreateTicket();
                    Result = CIPTicketManager.insertCIPTicket(ticket, SPID, CustID, RealName, UserName, NickName, OuterID, "UDBTicket", accountInfo.UserID, UDBBusiness.ConvertAuthenType(accountInfo.NumFlag), out ErrMsg);
                    strMsg.AppendFormat("【生成ticket】:Result:{0},Ticket:{1}", Result, ticket);
                    if (Result != 0)
                    {
                        strMsg.Append(",ErrMsg:Ticket生成失败" + ticket);
                        Redirect("ErrMsg", "Ticket生成失败");
                    }
                    strMsg.Append(",Message:生成ticket成功,返回业务系统");
                    Redirect("Ticket", ticket);
                }
                else
                {
                    strMsg.Append(",ErrMsg:用户注册到号百失败");
                    Redirect("ErrMsg", "用户注册到号百失败" + ErrMsg);
                }
            }
            else if (Result == 5)
            {
                strMsg.Append(",ErrMsg:用户已删除");
                Redirect("ErrMsg", "用户已删除");
            }
            else
            {
                strMsg.Append(",ErrMsg:查询用户信息失败");
                Redirect("ErrMsg", "查询用户信息失败");
            }

            #endregion
        }
        catch(Exception ex)
        {
            strMsg.AppendFormat(",ErrMsg:{0}", ex.Message);
        }
        finally
        {
            WriteLog(strMsg.ToString());
        }
    }
예제 #5
0
    /// <summary>
    /// 开始UDBSSO功能
    /// </summary>
    protected void BeginUDBSSO()
    {
        StringBuilder strMsg = new StringBuilder();
        Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        String ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
        try
        {
            #region 获取参数并验证

            SPID = Request["SPID"];
            ReturnUrl = Request["ReturnUrl"] == null ? String.Empty : Request["ReturnUrl"];
            PassportLoginResponseValue = Request["PassportLoginResponse"];
            strMsg.AppendFormat("从门户过来【验证参数,DateTime:{0}】:SPID:{1},PassportLoginResponse:{2},ReturnUrl:{3}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SPID, PassportLoginResponseValue, ReturnUrl);
            UDBKey = System.Configuration.ConfigurationManager.AppSettings["UdbKey"];

            //解析PassportLoginResponseValue
            String[] tempArray = PassportLoginResponseValue.Split('$');
            DesSsDeviceNo = tempArray[0];
            String tempStr = CryptographyUtil.Decrypt(tempArray[1], UDBKey);
            String[] digestArray = tempStr.Split('$');
            Result = Convert.ToInt32(digestArray[0]);
            UDBTicket = digestArray[1];
            String timeStamp = digestArray[2];
            String digest = digestArray[3];

            String newDigest = CryptographyUtil.ToBase64String(CryptographyUtil.Hash(Result + DesSsDeviceNo + UDBTicket + timeStamp));
            strMsg.AppendFormat(",DesSsDeviceNo:{0},Result:{1},UDBTicket{2},timeStamp:{3},digest:{4},newDigest:{5}\r\n", DesSsDeviceNo, Result, UDBTicket, timeStamp, digest, newDigest);
            if (!digest.Equals(newDigest))
            {
                //digest不吻合,失败
                strMsg.AppendFormat(",ErrMsg:{0}", "digest有误不匹配");
                Redirect("ErrMsg", "digest有误不匹配");
            }
            if (Result != 0)
            {
                //失败,则返回
                strMsg.AppendFormat(",ErrMsg:{0}", "返回Ticket失败");
                Redirect("ErrMsg", "返回Ticket失败");
            }

            #endregion

            #region 根据UDBTkcket到UDB查询用户信息

            strMsg.Append("【开始查询信息】:");

            UDBAccountInfo accountInfo = new UDBAccountInfo();

            //根据UDBTicket到UDB查询用户信息
            //Result = _UDBMBoss.AccountInfoCheck("3500000000408201", "3500000000408201", UDBTicket, UDBKey, out accountInfo, out ErrMsg);
            Result = _UDBMBoss.AccountInfoQuery("3500000000408201", "3500000000408201", UDBTicket, UDBKey, out accountInfo, out ErrMsg);
            accountInfo.SourceSPID = UDBConstDefinition.DefaultInstance.UDBSPID;
            strMsg.AppendFormat(",Result:{0},UserID:{1},UserIDType:{2},UserType:{3},PUserID:{4},Alias:{5},UserIDStatus:{6},UserIDSsStatus:{7},Description:{8},ProvinceID:{9},NumFlag:{10}\r\n",
                Result, accountInfo.UserID, accountInfo.UserIDType, accountInfo.UserType, accountInfo.PUserID, accountInfo.Alias, accountInfo.UserIDStatus, accountInfo.UserIDSsStatus, accountInfo.Description, accountInfo.ProvinceID, accountInfo.NumFlag);
            if (Result == 0)
            {
                String CustID, OuterID, Status, CustType, CustLevel, RealName, UserName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                //检测对应用户是否在号百系统,不在,则注册进来
                strMsg.Append("【开始注册到号百】:");
                Result = UserRegistry.getUserRegistryUDB(accountInfo, out CustID, out ErrMsg);
                strMsg.AppendFormat("Result:{0},CustID:{1}\r\n", Result, CustID);

                //注册成功
                if (Result == 0)
                {
                    Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
                        out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
                        out AreaID, out RegistrationSource);
                    if (Result != 0)
                    {
                        strMsg.Append(",ErrMsg:客户不存在" + CustID);
                        //客户不存在
                        Redirect("ErrMsg", "客户不存在");
                    }

                    //登录tab写入cookie
                    PageUtility.SetCookie("LoginTabCookie", "UDBTab",8760);

                    //生成Ticket
                    ticket = CommonBizRules.CreateTicket();

                    Result = CIPTicketManager.insertCIPTicket(ticket, SPID, CustID, RealName, UserName, NickName, OuterID, "UDBTicket", accountInfo.UserID, UDBBusiness.ConvertAuthenType(accountInfo.NumFlag), out ErrMsg);
                    strMsg.AppendFormat("【生成ticket】:Result:{0},Ticket:{1},ReturnUrl:{2}", Result, ticket, ReturnUrl);
                    if (Result != 0)
                    {
                        strMsg.Append(",ErrMsg:Ticket生成失败" + ticket);
                        Redirect("ErrMsg", "Ticket生成失败");
                    }
                    strMsg.Append(",Message:生成ticket成功,返回业务系统");
                    //后续就重定向到 QuickLogin1 ? QuickLogin1 是将登陆状态写入cookie的地方
                    //Response.Redirect("QuickLogin1.aspx?LoginTicket=" + ticket + "&ReturnUrl=" + ReturnUrl);  这里放到页面通过js跳转了,因为要区分 window.top.location.href 和 window.location.href ,js写起来比较方便
                }
                else
                {
                    strMsg.Append(",ErrMsg:用户注册到号百失败");
                    Redirect("ErrMsg", "用户注册到号百失败" + ErrMsg);
                }
            }
            else if (Result == 5)
            {
                strMsg.Append(",ErrMsg:用户已删除");
                Redirect("ErrMsg", "用户已删除");
            }
            else
            {
                strMsg.Append(",ErrMsg:查询用户信息失败");
                Redirect("ErrMsg", "查询用户信息失败");
            }

            #endregion
        }
        catch (Exception ex)
        {
            strMsg.AppendFormat(",ErrMsg:{0}", ex.Message);
        }
        finally
        {
            WriteLog(strMsg.ToString());
        }
    }
예제 #6
0
        /// <summary>
        /// UDB�û�ע����µ��Ű�
        /// </summary>
        public static Int32 getUserRegistryUDB(UDBAccountInfo accountInfo, out String CustID, out String ErrMsg)
        {
            Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            CustID = String.Empty;

            try
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "up_Customer_V3_Interface_UserRegistryV2UDB";

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

                    SqlParameter parAreaID = new SqlParameter("@AreaID", SqlDbType.VarChar);
                    parAreaID.Value = String.Empty;
                    cmd.Parameters.Add(parAreaID);

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

                    SqlParameter parAuthenType = new SqlParameter("@AuthenType", SqlDbType.VarChar);
                    parAuthenType.Value = UDBBusiness.ConvertAuthenType(accountInfo.NumFlag);
                    cmd.Parameters.Add(parAuthenType);

                    SqlParameter parCustType = new SqlParameter("@CustType", SqlDbType.VarChar);
                    parCustType.Value = "42";
                    cmd.Parameters.Add(parCustType);

                    SqlParameter parRealName = new SqlParameter("@RealName", SqlDbType.VarChar);
                    parRealName.Value = String.IsNullOrEmpty(accountInfo.Alias) ? accountInfo.UserID : accountInfo.Alias;
                    //parRealName.Value = String.Empty;
                    cmd.Parameters.Add(parRealName);

                    SqlParameter parUserName = new SqlParameter("@UserName", SqlDbType.VarChar);
                    //parUserName.Value = String.IsNullOrEmpty(accountInfo.Alias) ? accountInfo.UserID : accountInfo.Alias;
                    parUserName.Value = String.Empty;
                    cmd.Parameters.Add(parUserName);

                    SqlParameter parNickName = new SqlParameter("@NickName", SqlDbType.VarChar);
                    parNickName.Value = String.IsNullOrEmpty(accountInfo.Alias) ? accountInfo.UserID : accountInfo.Alias;
                    cmd.Parameters.Add(parNickName);

                    Random random = new Random();
                    String randomPwd = random.Next(100000, 999999).ToString();
                    SqlParameter parPassword = new SqlParameter("@Password", SqlDbType.VarChar);
                    parPassword.Value = CryptographyUtil.Encrypt(randomPwd);
                    cmd.Parameters.Add(parPassword);

                    SqlParameter parOuterID = new SqlParameter("@OuterID", SqlDbType.VarChar);
                    parOuterID.Value = accountInfo.PUserID;
                    cmd.Parameters.Add(parOuterID);

                    SqlParameter parSourceSPID = new SqlParameter("@SourceSPID", SqlDbType.VarChar);
                    parSourceSPID.Value = accountInfo.SourceSPID;
                    cmd.Parameters.Add(parSourceSPID);

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

                    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);

                    DBUtility.Execute(cmd, DBUtility.BestToneCenterConStr);

                    Result = Convert.ToInt32(parResult.Value);
                    ErrMsg = parErrMsg.Value.ToString();
                    CustID = parOutCustID.Value.ToString();

                }
            }
            catch (Exception ex)
            {
                ErrMsg += ex.Message;
            }

            return Result;
        }
예제 #7
0
        /// <summary>
        /// ������UDB��ѯ�û���Ϣ���ص�xml
        /// </summary>
        public static Int32 ParseAccountInfoQueryXml(String xmlStr, out UDBAccountInfo accountInfo, out String ErrMsg)
        {
            Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            accountInfo = new UDBAccountInfo();
            try
            {

                //����xml
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlStr);
                XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
                manager.AddNamespace("UDB", "http://udb.chinatelecom.com");

                //����xml����
                Result = Convert.ToInt32(xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:ResultCode", manager).InnerText);
                accountInfo.UserType = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserType", manager).InnerText;

                XmlNode node = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:ReturnUserGroupList", manager);

                accountInfo.UserID = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserID", manager).InnerText;
                accountInfo.UserIDType = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserIDType", manager).InnerText;
                accountInfo.PUserID = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:PUserID", manager).InnerText;
                accountInfo.Alias = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Alias", manager).InnerText;
                accountInfo.BindingAccessNo = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:BindingAccessNo", manager).InnerText;
                accountInfo.ThirdSsUserID = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:ThirdSsUserID", manager).InnerText;
                accountInfo.UserIDStatus = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserIDStatus", manager).InnerText;
                accountInfo.UserIDSsStatus = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserIDSsStatus", manager).InnerText;
                accountInfo.UserPayType = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:UserPayType", manager).InnerText;
                accountInfo.PrePaySystemNo = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:PrePaySystemNo", manager).InnerText;
                String temp_Description = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Description", manager).InnerText;
                accountInfo.Description = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Description", manager).InnerText;
                if (Result == 0 || Result == 5)
                {
                    //<Ex><PID>07</PID><NF>2</NF></Ex>
                    Int32 startIndex = temp_Description.IndexOf("<PID>");
                    Int32 endIndex = temp_Description.IndexOf("</PID>");
                    accountInfo.ProvinceID = temp_Description.Substring(startIndex + 5, endIndex - startIndex - 5);
                    startIndex = temp_Description.IndexOf("<NF>");
                    endIndex = temp_Description.IndexOf("</NF>");
                    accountInfo.NumFlag = temp_Description.Substring(startIndex + 4, endIndex - startIndex - 4);
                }
                else
                {
                    ErrMsg = xmlDoc.SelectSingleNode("/UDB:AccountInfoCheckResult/UDB:Description", manager).InnerText;
                }
            }
            catch (Exception ex)
            {
                ErrMsg += ex.Message;
            }

            return Result;
        }