|
|
package login;
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
...
|
...
|
@@ -10,66 +9,68 @@ import com.alibaba.fastjson.JSONObject; |
|
|
import tools.HttpTools;
|
|
|
|
|
|
public class FLogin {
|
|
|
public static LoginData login(UserEntity user){
|
|
|
public static LoginData login(UserEntity user) {
|
|
|
LoginData logindata = new LoginData();
|
|
|
|
|
|
InfoData info = new InfoData();
|
|
|
String param = "ssid=5672813&data=";
|
|
|
InterfaceData id = new InterfaceData();
|
|
|
id.setKey("owenkasduf");
|
|
|
//id.setUsername("wangshan");
|
|
|
//id.setPwd("123456");
|
|
|
// id.setUsername("wangshan");
|
|
|
// id.setPwd("123456");
|
|
|
id.setUsername(user.getLoginaccount());
|
|
|
id.setPwd(user.getPassword());
|
|
|
id.setType("2");
|
|
|
//System.out.println(Security.getKey());
|
|
|
//构造请求数据包(并且加密data数据)
|
|
|
// System.out.println(Security.getKey());
|
|
|
// 构造请求数据包(并且加密data数据)
|
|
|
String data = Security.encrypt(JSONObject.toJSONString(id), Security.getKey());
|
|
|
param = param + data;
|
|
|
System.out.println(param);
|
|
|
//发送登录消息
|
|
|
//String receive = HttpRequest.sendPost("http://10.50.2.24/index.php?r=api/index", param);
|
|
|
//String receive = HttpRequest.sendPost("http://10.50.2.20/index.php?r=api/index", param);
|
|
|
//String receive = HttpRequest.sendPost("http://www.zzcargo.com/index.php?r=api/index", param);
|
|
|
// System.err.println("param-->"+param);
|
|
|
// 发送登录消息
|
|
|
// String receive =
|
|
|
// HttpRequest.sendPost("http://10.50.2.24/index.php?r=api/index", param);
|
|
|
// String receive =
|
|
|
// HttpRequest.sendPost("http://10.50.2.20/index.php?r=api/index", param);
|
|
|
// String receive =
|
|
|
// HttpRequest.sendPost("http://www.zzcargo.com/index.php?r=api/index", param);
|
|
|
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
map.put("ssid", "5672813");
|
|
|
map.put("data", data);
|
|
|
String receive = HttpTools.sendPost("http://www.zzcargo.com/index.php?r=api/index", map, "UTF-8");
|
|
|
///index.php?r=site/login
|
|
|
System.out.println(receive);
|
|
|
try{
|
|
|
//转换接收到的数据
|
|
|
/// index.php?r=site/login
|
|
|
// System.err.println("receive-->"+receive);
|
|
|
try {
|
|
|
// 转换接收到的数据
|
|
|
FJSON.JsonToObject(logindata, receive);
|
|
|
//验证通过
|
|
|
if(logindata.getCode() == 20000)
|
|
|
{
|
|
|
//对传回的数据解密
|
|
|
// 验证通过
|
|
|
if (logindata.getCode() == 20000) {
|
|
|
// 对传回的数据解密
|
|
|
String raw = Security.decrypt(logindata.getInfo(), Security.getKey());
|
|
|
//show message
|
|
|
//System.out.println(raw);
|
|
|
// show message
|
|
|
// System.err.println("raw-->"+raw);
|
|
|
|
|
|
logindata.setInfo(raw);
|
|
|
//将解密后的数据转回json
|
|
|
// 将解密后的数据转回json
|
|
|
FJSON.JsonToObject(info, logindata.getInfo());
|
|
|
logindata.setInfodata(info);
|
|
|
}
|
|
|
}catch(Exception e){
|
|
|
//数据返回异常
|
|
|
} catch (Exception e) {
|
|
|
// 数据返回异常
|
|
|
logindata.setCode(0);
|
|
|
|
|
|
}
|
|
|
//测试的数据
|
|
|
// InfoData id = new InfoData();
|
|
|
//
|
|
|
// id.setMobile("fadf");
|
|
|
// id.setCompany_info("flasdjf");
|
|
|
// id.setQq("fasdf");
|
|
|
// id.setContact("fffffffff");
|
|
|
// id.setAddress("fafda");
|
|
|
// id.setCompany("fafdadf");
|
|
|
// logindata.setCode(20000);
|
|
|
// logindata.setInfodata(id);
|
|
|
// 测试的数据
|
|
|
// InfoData id = new InfoData();
|
|
|
//
|
|
|
// id.setMobile("fadf");
|
|
|
// id.setCompany_info("flasdjf");
|
|
|
// id.setQq("fasdf");
|
|
|
// id.setContact("fffffffff");
|
|
|
// id.setAddress("fafda");
|
|
|
// id.setCompany("fafdadf");
|
|
|
// logindata.setCode(20000);
|
|
|
// logindata.setInfodata(id);
|
|
|
return logindata;
|
|
|
}
|
|
|
} |
...
|
...
|
|