public static WeiBoUser login(String u, String p) {

		WeiBoUser user = null;

		DefaultHttpClient client = new DefaultHttpClient();

		try {
			// 获得rsaPubkey,rsakv,servertime等参数值
			HashMap<String, String> params = preLogin(encodeAccount(u), client);

			// Mobile
			// HttpPost post = new HttpPost(
			// "https://passport.sina.cn/signin/signin?entry=wapsso.js(v1.4.5)");

			HttpPost post = new HttpPost(
					"http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.2)");

			post.setHeader("Accept",
					"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
			post.setHeader("User-Agent",
					"Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");

			post.setHeader("Accept-Language", "zh-cn,zh;q=0.8");
			post.setHeader("Accept-Charset", "GB2312,utf-8;q=0.7,*;q=0.7");
			post.setHeader("Referer",
					"http://weibo.com/?c=spr_web_sq_firefox_weibo_t001");
			post.setHeader("Content-Type", "application/x-www-form-urlencoded");

			String nonce = makeNonce(6);

			List<NameValuePair> nvps = new ArrayList<NameValuePair>();
			nvps.add(new BasicNameValuePair("encoding", "UTF-8"));
			nvps.add(new BasicNameValuePair("entry", "weibo"));
			nvps.add(new BasicNameValuePair("from", ""));
			nvps.add(new BasicNameValuePair("gateway", "1"));
			nvps.add(new BasicNameValuePair("nonce", nonce));
			nvps.add(new BasicNameValuePair("pagerefer",
					"http://i.firefoxchina.cn/old/"));
			nvps.add(new BasicNameValuePair("prelt", "111"));
			nvps.add(new BasicNameValuePair("pwencode", "rsa2"));
			nvps.add(new BasicNameValuePair("returntype", "META"));
			nvps.add(new BasicNameValuePair("rsakv", params.get("rsakv")));
			nvps.add(new BasicNameValuePair("savestate", "0"));
			nvps.add(new BasicNameValuePair("servertime", params
					.get("servertime")));

			nvps.add(new BasicNameValuePair("service", "miniblog"));
			// nvps.add(new BasicNameValuePair("sp", new
			// SinaSSOEncoder().encode(p, data, nonce)));

			/******************** *加密密码 ***************************/
			ScriptEngineManager sem = new ScriptEngineManager();
			ScriptEngine se = sem.getEngineByName("javascript");
			// FileReader f = new FileReader("d://sso.js");
			se.eval(SinaSSOEncoder.getJs());
			String pass = "";

			if (se instanceof Invocable) {
				Invocable invoke = (Invocable) se;
				// 调用preprocess方法，并传入两个参数密码和验证码

				pass = invoke.invokeFunction("getpass", p,
						params.get("servertime"), nonce, params.get("pubkey"))
						.toString();

				System.out.println("c = " + pass);
			}

			nvps.add(new BasicNameValuePair("sp", pass));
			nvps.add(new BasicNameValuePair("su", encodeAccount(u)));
			nvps.add(new BasicNameValuePair(
					"url",
					"http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack"));

			nvps.add(new BasicNameValuePair("useticket", "1"));
			// nvps.add(new BasicNameValuePair("ssosimplelogin", "1"));
			nvps.add(new BasicNameValuePair("vsnf", "1"));

			post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

			HttpResponse response = client.execute(post);

			String entity = EntityUtils.toString(response.getEntity());

			// System.out.println(entity.toString());

			if (entity.replace("\"", "").indexOf("retcode=0") > -1) {

				// fix code
				String url = entity.substring(entity
						.indexOf("http://passport.weibo.com/wbsso/login?"),
						entity.indexOf("code=0") + 6);

				String strScr = ""; // 首页用户script形式数据
				String nick = "暂无"; // 昵称

				// 获取到实际url进行连接
				HttpGet getMethod = new HttpGet(url);
				response = client.execute(getMethod);
				entity = EntityUtils.toString(response.getEntity());

				// System.out.println(entity);

				nick = entity.substring(entity.indexOf("displayname") + 14,
						entity.lastIndexOf("userdomain") - 3).trim();

				url = entity.substring(entity.indexOf("userdomain") + 13,
						entity.lastIndexOf("\""));
				getMethod = new HttpGet("http://weibo.com/" + url);
				response = client.execute(getMethod);
				entity = EntityUtils.toString(response.getEntity());

				// System.out.println(entity.toString());

				Document doc = Jsoup.parse(entity);
				Elements els = doc.select("script");

				if (els != null && els.size() > 0) {
					for (int i = 0, leg = els.size(); i < leg; i++) {

						if (els.get(i).html().indexOf("$CONFIG") > -1) {
							strScr = els.get(i).html();
							break;
						}
					}
				}

				if (!strScr.equals("")) {
					ScriptEngineManager manager = new ScriptEngineManager();
					ScriptEngine engine = manager.getEngineByName("javascript");

					engine.eval("function getMsg(){" + strScr
							+ "return $CONFIG['onick'];}");
					if (engine instanceof Invocable) {
						Invocable invoke = (Invocable) engine;
						// 调用preprocess方法，并传入两个参数密码和验证码

						nick = invoke.invokeFunction("getMsg", null).toString();

					}
				}

				user = new WeiBoUser();
				user.setUserName(u);
				user.setUserPass(p);
				user.setDisplayName(nick);

			}

		} catch (Exception e) {
			e.printStackTrace();
			System.out.println(e.getMessage());
			// logger.info(e.getMessage());
			user = null;
		}

		return user;
	}