use of org.apache.http.message.BasicNameValuePair in project aws-iam-ldap-bridge by denismo.
the class IAMAccountPasswordValidator method verifyIAMPassword.
@Override
public boolean verifyIAMPassword(Entry user, String pw) throws LdapInvalidAttributeValueException, LdapAuthenticationException {
try {
LOG.debug("Verifying {} {} with accessKey <hidden> and secretKey <hidden>", "user", user.get("uid").getString());
HttpClient client = new SystemDefaultHttpClient();
HttpPost post = new HttpPost("https://signin.aws.amazon.com/oauth");
post.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36");
post.setHeader("Referer", "https://signin.aws.amazon.com/oauth");
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("client_id", "arn:aws:iam::015428540659:user/homepage"));
urlParameters.add(new BasicNameValuePair("isIAMUser", "1"));
urlParameters.add(new BasicNameValuePair("account", user.get("accountNumber").getString()));
urlParameters.add(new BasicNameValuePair("username", user.get("uid").getString()));
urlParameters.add(new BasicNameValuePair("password", pw));
urlParameters.add(new BasicNameValuePair("Action", "login"));
urlParameters.add(new BasicNameValuePair("redirect_uri", "https://console.aws.amazon.com/console/home?state=hashArgs%23&isauthcode=true"));
urlParameters.add(new BasicNameValuePair("forceMobileApp", ""));
urlParameters.add(new BasicNameValuePair("forceMobileLayout", ""));
urlParameters.add(new BasicNameValuePair("mfaLoginFailure", ""));
urlParameters.add(new BasicNameValuePair("RemainingExpiryPeriod", ""));
urlParameters.add(new BasicNameValuePair("mfacode", ""));
urlParameters.add(new BasicNameValuePair("next_mfacode", ""));
post.setEntity(new UrlEncodedFormEntity(urlParameters, Charset.forName("UTF-8")));
HttpResponse response = client.execute(post);
return containsHeaders(response, "aws-account-alias", "aws-creds");
} catch (IOException e) {
LOG.error("Exception validating password for " + user.get("uid").getString(), e);
return false;
} catch (RuntimeException t) {
LOG.error("Exception validating password for " + user.get("uid").getString(), t);
throw t;
}
}
use of org.apache.http.message.BasicNameValuePair in project Trello-Android by chrisHoekstra.
the class TrelloService method getNotifications.
public ArrayList<NotificationVO> getNotifications() {
ArrayList<NotificationVO> result = null;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("key", PUBLIC_KEY));
params.add(new BasicNameValuePair("token", mToken));
HttpGet httpGet = new HttpGet(TRELLO_API_URL + "members/" + "me/" + "notifications?" + URLEncodedUtils.format(params, "UTF-8"));
HttpClient httpClient = getHttpClient();
try {
httpGet.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT_STRING);
HttpResponse response = httpClient.execute(httpGet, mContext);
if (response != null) {
result = mObjectMapper.readValue(mJsonFactory.createJsonParser(new InputStreamReader(response.getEntity().getContent(), "UTF-8")), new TypeReference<ArrayList<NotificationVO>>() {
});
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
use of org.apache.http.message.BasicNameValuePair in project Trello-Android by chrisHoekstra.
the class TrelloService method addCard.
public Boolean addCard(String boardListId, String name) {
Boolean result = false;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("key", PUBLIC_KEY));
params.add(new BasicNameValuePair("token", mToken));
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("idList", boardListId));
HttpPost httpPost = new HttpPost(TRELLO_API_URL + "cards?" + URLEncodedUtils.format(params, "UTF-8"));
HttpClient httpClient = getHttpClient();
try {
httpPost.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT_STRING);
HttpResponse response = httpClient.execute(httpPost, mContext);
if (response != null) {
result = true;
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
use of org.apache.http.message.BasicNameValuePair in project moco by dreamhead.
the class MocoWebTest method should_match_form_value.
@Test
public void should_match_form_value() throws Exception {
server.post(eq(form("name"), "dreamhead")).response("foobar");
running(server, new Runnable() {
@Override
public void run() throws Exception {
String content = Post(root()).bodyForm(new BasicNameValuePair("name", "dreamhead")).execute().returnContent().asString();
assertThat(content, is("foobar"));
}
});
}
use of org.apache.http.message.BasicNameValuePair in project android-app by eoecn.
the class MainActivity method onClick.
// [end]
// [start]继承方法
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()) {
case R.id.Linear_above_toHome:
showMenu();
break;
case R.id.login_login:
SharedPreferences share = this.getSharedPreferences(UserLoginUidActivity.SharedName, Context.MODE_PRIVATE);
// [start] 修复上一个bug
String Key = share.getString(UserLoginUidActivity.KEY, "");
if (Key != "" && !Key.contains(":")) {
Editor edit = share.edit();
edit.putString(UserLoginUidActivity.KEY, "");
edit.commit();
}
// [end] 下一版本删除掉
if (share.contains(UserLoginUidActivity.KEY) && !share.getString(UserLoginUidActivity.KEY, "").equals("")) {
IntentUtil.start_activity(this, UserCenterActivity.class);
} else {
IntentUtil.start_activity(this, UserLoginActivity.class);
}
break;
case R.id.imageview_above_more:
if (isShowPopupWindows) {
new PopupWindowUtil(mViewPager).showActionWindow(v, this, mBasePageAdapter.tabs);
}
break;
case R.id.imageview_above_query:
if (NetWorkHelper.isNetworkAvailable(MainActivity.this)) {
IntentUtil.start_activity(this, SearchActivity.class, new BasicNameValuePair("tag", current_page));
} else {
Toast.makeText(getApplicationContext(), "网络连接失败,请检查网络", Toast.LENGTH_LONG).show();
}
break;
case R.id.cbFeedback:
FeedbackAgent agent = new FeedbackAgent(this);
agent.startFeedbackActivity();
break;
case R.id.cbAbove:
IntentUtil.start_activity(this, AboutActivity.class);
break;
case R.id.bn_refresh:
switch(mTag) {
case 0:
imgQuery.setVisibility(View.GONE);
new MyTask().execute(topDao);
break;
case 1:
new MyTask().execute(newsDao);
break;
case 2:
new MyTask().execute(wikiDao);
break;
case 3:
new MyTask().execute(blogsDao);
break;
default:
break;
}
break;
}
}
Aggregations