List of usage examples for org.apache.http.client ClientProtocolException getMessage
public String getMessage()
From source file:gov.nih.nci.caxchange.messaging.AdverseEventIntegrationTest.java
/** * TestCase for Creating Adverse Event in caAERS when Study does not exist in caAERS. *//* ww w . j a v a 2 s . c om*/ @Test public void createAEStudyNotExist() { try { final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); final StringEntity reqentity = new StringEntity(getCreateAEStudyNotExist()); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); String createdXML = null; if (entity != null) { createdXML = EntityUtils.toString(entity); Assert.assertEquals(true, createdXML.contains(ERRORCODE1101)); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:gov.nih.nci.caxchange.messaging.AdverseEventIntegrationTest.java
/** * TestCase for Creating Adverse Event in caAERS when Participant does not exist in caAERS. *//*from w ww. j a v a 2s . com*/ @Test public void createAEParticipantNotExist() { try { final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); final StringEntity reqentity = new StringEntity(getCreateAEParticipantNotExist()); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); String createdXML = null; if (entity != null) { createdXML = EntityUtils.toString(entity); Assert.assertEquals(true, createdXML.contains(ERRORCODE1053)); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:com.liato.bankdroid.banking.banks.Payson.java
@Override public Urllib login() throws LoginException, BankException { try {//from www . j a va2 s . c om LoginPackage lp = preLogin(); response = urlopen.open(lp.getLoginTarget(), lp.getPostData()); if (response.contains("Felaktig E-postadress") || response.contains("Lsenord saknas") || response.contains("E-postadress saknas")) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } return urlopen; }
From source file:gov.nih.nci.caxchange.messaging.RegisterConsentIntegrationTest.java
/** * Testcase for registerConsents flow/*from w w w . ja v a 2 s.c om*/ */ @Test public void registerConsents() { try { // Create the Specimen for which Consent has to be registered. createSpecimen(); final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); final StringEntity reqentity = new StringEntity(getRegisterConsentXMLStr()); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); String createdXML = null; if (entity != null) { createdXML = EntityUtils.toString(entity); Assert.assertEquals(true, createdXML.contains("<responseStatus>SUCCESS</responseStatus>")); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:gov.nih.nci.caxchange.messaging.RegistrationLoadTest.java
private void sendMessage(int sfx) { try {/*from w w w. ja v a 2s . co m*/ final HttpClient httpclient = new DefaultHttpClient(); final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); final StringEntity reqentity = new StringEntity(getCreateMsg(sfx)); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, "text/xml"); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); if (entity != null) { final String output = EntityUtils.toString(entity); Assert.assertNotNull(output); Assert.assertEquals(true, output.contains("SUCCESS")); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:com.liato.bankdroid.banking.banks.Bioklubben.java
public Urllib login() throws LoginException, BankException { try {/*ww w .j av a 2 s . c om*/ LoginPackage lp = preLogin(); response = urlopen.open(lp.getLoginTarget(), lp.getPostData()); if (response.contains("Felaktigt anv")) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { e.printStackTrace(); throw new BankException(e.getMessage()); } return urlopen; }
From source file:ac.dynam.rundeck.plugin.resources.ovirt.oVirtSDKWrapper.java
public void login(String baseUrl, String userName, String password) { try {/* w ww . j a v a 2s . c om*/ // true for filter, ie enable regular users to login // this.api = new Api(baseUrl, userName, password, true); if (!isLoggedin()) { this.api = new ApiBuilder().url(baseUrl).user(userName).password(password).debug(false) .noHostVerification(true).build(); logger.debug("Processing...."); if (isLoggedin()) { logger.info("Successfully Logged into oVirt: " + baseUrl); } else { logger.warn("Can't Log into oVirt: " + baseUrl); } } } catch (ClientProtocolException e) { this.message = "Protocol Exception: " + e.getMessage(); } catch (ServerException e) { this.message = "Server Exception: " + e.getMessage(); } catch (UnsecuredConnectionAttemptError e) { this.message = "Unsecured Connection Exception: " + e.getMessage(); } catch (IOException e) { this.message = "IOException Exception: " + e.getMessage(); } }
From source file:com.liato.bankdroid.banking.banks.Avanza.java
@Override public Urllib login() throws LoginException, BankException { String response = null;//w w w. ja v a2s. c om try { LoginPackage lp = preLogin(); response = urlopen.open(lp.getLoginTarget(), lp.getPostData()); if (response.contains("Felaktigt") && !response.contains("Logga ut")) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } return urlopen; }
From source file:com.liato.bankdroid.banking.banks.icabanken.ICABanken.java
public Urllib login() throws LoginException, BankException { urlopen = new Urllib(context, CertificateReader.getCertificates(context, R.raw.cert_icabanken)); urlopen.addHeader("ApiVersion", API_VERSION); urlopen.addHeader("Accept", "application/json"); urlopen.addHeader("ApiKey", API_KEY); urlopen.addHeader("ClientHardware", Build.MODEL); urlopen.addHeader("ClientOS", "Android"); urlopen.addHeader("ClientOSVersion", Integer.toString(Build.VERSION.SDK_INT)); urlopen.addHeader("ClientAppVersion", "777"); try {/* w w w. j a v a2 s.co m*/ String response = urlopen.open( String.format("%s/login/passwordlogin?customerId=%s&password=%s", API_URL, username, password)); if (response == null || "".equals(response)) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } ObjectMapper vObjectMapper = new ObjectMapper(); vObjectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", new Locale("sv", "SE"))); LoginResponse loginResponse = vObjectMapper.readValue(response, LoginResponse.class); addAccounts(loginResponse.getAccountList()); } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } return urlopen; }
From source file:com.liato.bankdroid.banking.banks.TrustBuddy.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }//from w w w . ja v a 2 s .c om urlopen = login(); String response = null; Matcher matcher; try { response = urlopen.open("https://trustbuddy.com/se/din_sida/"); matcher = reAccounts.matcher(response); while (matcher.find()) { /* * 1: Land * 2: Saldo * 3: Valuta */ Account temp = new Account(Html.fromHtml(matcher.group(1)).toString().trim(), Helpers.parseBalance(matcher.group(2).trim()), matcher.group(1).toLowerCase()); temp.setCurrency(matcher.group(3)); accounts.add(temp); balance = balance.add(Helpers.parseBalance(matcher.group(2))); } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } }