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; } }
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 { } } }