Skip to content

cheney0214/ddl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

private boolean login(String username, String password) { HttpClient httpClient = new DefaultHttpClient();

	HttpPost request = new HttpPost(AUTH_URL);
	request.addHeader("Content-Type", "application/x-www-form-urlencoded");

	/* body part */
	List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
	BasicNameValuePair pare = new BasicNameValuePair("username", username);
	nameValuePairs.add(pare);
	pare = new BasicNameValuePair("password", password);
	nameValuePairs.add(pare);

	UrlEncodedFormEntity entity;
	try {
		entity = new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8);
		request.setEntity(entity);
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}

	try {
		HttpResponse response = httpClient.execute(request);
		if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
			authToken = Base64.encodeBase64String((username + ":" + password).getBytes("UTF-8"));
			return true;
		}
	} catch (ClientProtocolException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	}

	return false;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages