List of usage examples for org.apache.http.protocol HTTP ISO_8859_1
String ISO_8859_1
To view the source code for org.apache.http.protocol HTTP ISO_8859_1.
Click Source Link
From source file:com.androidinahurry.tunisiabanking.bank.atb.AtbService.java
private static HttpResponse doPost(AtbContext context, String url, List<NameValuePair> formParams) throws KeyManagementException, UnrecoverableKeyException, ClientProtocolException, NoSuchAlgorithmException, KeyStoreException, IOException { String URL = BASE_URL + url; // Create the entity for the Http Post UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, HTTP.ISO_8859_1); HttpPost httpPost = new HttpPost(URL); httpPost.setEntity(entity);/* www.j av a2s .c o m*/ // Execute the HTTP request return context.getHttpClient().execute(httpPost, context.getHttpContext()); }
From source file:com.liato.bankdroid.banking.banks.DanskeBank.java
@Override protected LoginPackage preLogin() throws BankException, ClientProtocolException, IOException { urlopen = new Urllib(context, CertificateReader.getCertificates(context, R.raw.cert_danskebank)); urlopen.setContentCharset(HTTP.ISO_8859_1); urlopen.addHeader("Referer", "https://mobil.danskebank.se/"); List<NameValuePair> postData = new ArrayList<NameValuePair>(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm - dd.MM.yyyy"); postData.add(new BasicNameValuePair("gsSprog", "SE")); postData.add(new BasicNameValuePair("gsBrand", "OEB")); postData.add(new BasicNameValuePair("gsSession", "")); postData.add(new BasicNameValuePair("gsProdukt", "XAS")); postData.add(new BasicNameValuePair("gsNextObj", "Forside")); postData.add(new BasicNameValuePair("gsNextAkt", "MBForside")); postData.add(new BasicNameValuePair("gsNextUObj", "SC")); postData.add(new BasicNameValuePair("gsCurItem", "")); postData.add(new BasicNameValuePair("gsCurItem2", "")); postData.add(new BasicNameValuePair("gsCurItem3", "")); postData.add(new BasicNameValuePair("gsCurItem4", "")); postData.add(new BasicNameValuePair("gsCurItem5", "")); postData.add(new BasicNameValuePair("gsCurObj", "Logon")); postData.add(new BasicNameValuePair("gsCurAkt", "MBSELogon")); postData.add(new BasicNameValuePair("gsCurUObj", "SC")); postData.add(new BasicNameValuePair("hidStatusType", "A00")); postData.add(new BasicNameValuePair("hidStatusTekst", "")); postData.add(new BasicNameValuePair("hidStatusTid", sdf.format(new Date()))); postData.add(new BasicNameValuePair("gsSikSystem", "KO")); postData.add(new BasicNameValuePair("gsLand", "SE")); postData.add(new BasicNameValuePair("gsAftlnr", username)); postData.add(new BasicNameValuePair("gsLogon", password)); return new LoginPackage(urlopen, postData, response, "https://mobil.danskebank.se/XI"); }
From source file:com.liato.bankdroid.banking.banks.CSN.java
@Override protected LoginPackage preLogin() throws BankException, ClientProtocolException, IOException { urlopen = new Urllib(context, CertificateReader.getCertificates(context, R.raw.cert_csn)); urlopen.setAllowCircularRedirects(true); urlopen.setContentCharset(HTTP.ISO_8859_1); urlopen.addHeader("Referer", "https://www.csn.se/bas/"); response = urlopen.open("https://www.csn.se/bas/inloggning/pinkod.do"); List<NameValuePair> postData = new ArrayList<NameValuePair>(); postData.add(new BasicNameValuePair("javascript", "on")); try {/*from w w w. ja v a 2 s . com*/ response = urlopen.open("https://www.csn.se/bas/javascript", postData); } catch (ClientProtocolException e) { throw new BankException("pl:CPE:" + e.getMessage()); } catch (IOException e) { throw new BankException("pl:IOE:" + e.getMessage()); } postData.clear(); postData.add(new BasicNameValuePair("metod", "validerapinkod")); postData.add(new BasicNameValuePair("pnr", username)); postData.add(new BasicNameValuePair("pinkod", password)); return new LoginPackage(urlopen, postData, response, "https://www.csn.se/bas/inloggning/Pinkod.do"); }
From source file:org.apache.axis2.transport.http.HTTPWorker.java
public void service(final AxisHttpRequest request, final AxisHttpResponse response, final MessageContext msgContext) throws HttpException, IOException { ConfigurationContext configurationContext = msgContext.getConfigurationContext(); final String servicePath = configurationContext.getServiceContextPath(); final String contextPath = (servicePath.startsWith("/") ? servicePath : "/" + servicePath) + "/"; String uri = request.getRequestURI(); String method = request.getMethod(); String soapAction = HttpUtils.getSoapAction(request); InvocationResponse pi;//from w w w. j av a 2 s . co m if (method.equals(HTTPConstants.HEADER_GET)) { if (uri.equals("/favicon.ico")) { response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY); response.addHeader(new BasicHeader("Location", "http://ws.apache.org/favicon.ico")); return; } if (!uri.startsWith(contextPath)) { response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY); response.addHeader(new BasicHeader("Location", contextPath)); return; } if (uri.endsWith("axis2/services/")) { String s = HTTPTransportReceiver.getServicesHTML(configurationContext); response.setStatus(HttpStatus.SC_OK); response.setContentType("text/html"); OutputStream out = response.getOutputStream(); out.write(EncodingUtils.getBytes(s, HTTP.ISO_8859_1)); return; } if (uri.indexOf("?") < 0) { if (!uri.endsWith(contextPath)) { if (uri.endsWith(".xsd") || uri.endsWith(".wsdl")) { HashMap services = configurationContext.getAxisConfiguration().getServices(); String file = uri.substring(uri.lastIndexOf("/") + 1, uri.length()); if ((services != null) && !services.isEmpty()) { Iterator i = services.values().iterator(); while (i.hasNext()) { AxisService service = (AxisService) i.next(); InputStream stream = service.getClassLoader() .getResourceAsStream("META-INF/" + file); if (stream != null) { OutputStream out = response.getOutputStream(); response.setContentType("text/xml"); ListingAgent.copy(stream, out); out.flush(); out.close(); return; } } } } } } if (uri.endsWith("?wsdl2")) { String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 6); HashMap services = configurationContext.getAxisConfiguration().getServices(); AxisService service = (AxisService) services.get(serviceName); if (service != null) { boolean canExposeServiceMetadata = canExposeServiceMetadata(service); if (canExposeServiceMetadata) { response.setStatus(HttpStatus.SC_OK); response.setContentType("text/xml"); service.printWSDL2(response.getOutputStream(), getHost(request)); } else { response.setStatus(HttpStatus.SC_FORBIDDEN); } return; } } if (uri.endsWith("?wsdl")) { /** * service name can be hierarchical (axis2/services/foo/1.0.0/Version?wsdl) or * normal (axis2/services/Version?wsdl). */ String[] temp = uri.split(configurationContext.getServiceContextPath() + "/"); String serviceName = temp[1].substring(0, temp[1].length() - 5); HashMap services = configurationContext.getAxisConfiguration().getServices(); AxisService service = (AxisService) services.get(serviceName); if (service != null) { boolean canExposeServiceMetadata = canExposeServiceMetadata(service); if (canExposeServiceMetadata) { response.setStatus(HttpStatus.SC_OK); response.setContentType("text/xml"); service.printWSDL(response.getOutputStream(), getHost(request)); } else { response.setStatus(HttpStatus.SC_FORBIDDEN); } return; } } if (uri.endsWith("?xsd")) { String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 4); HashMap services = configurationContext.getAxisConfiguration().getServices(); AxisService service = (AxisService) services.get(serviceName); if (service != null) { boolean canExposeServiceMetadata = canExposeServiceMetadata(service); if (canExposeServiceMetadata) { response.setStatus(HttpStatus.SC_OK); response.setContentType("text/xml"); service.printSchema(response.getOutputStream()); } else { response.setStatus(HttpStatus.SC_FORBIDDEN); } return; } } //cater for named xsds - check for the xsd name if (uri.indexOf("?xsd=") > 0) { // fix for imported schemas String[] uriParts = uri.split("[?]xsd="); String serviceName = uri.substring(uriParts[0].lastIndexOf("/") + 1, uriParts[0].length()); String schemaName = uri.substring(uri.lastIndexOf("=") + 1); HashMap services = configurationContext.getAxisConfiguration().getServices(); AxisService service = (AxisService) services.get(serviceName); if (service != null) { boolean canExposeServiceMetadata = canExposeServiceMetadata(service); if (!canExposeServiceMetadata) { response.setStatus(HttpStatus.SC_FORBIDDEN); return; } //run the population logic just to be sure service.populateSchemaMappings(); //write out the correct schema Map schemaTable = service.getSchemaMappingTable(); XmlSchema schema = (XmlSchema) schemaTable.get(schemaName); if (schema == null) { int dotIndex = schemaName.indexOf('.'); if (dotIndex > 0) { String schemaKey = schemaName.substring(0, dotIndex); schema = (XmlSchema) schemaTable.get(schemaKey); } } //schema found - write it to the stream if (schema != null) { response.setStatus(HttpStatus.SC_OK); response.setContentType("text/xml"); schema.write(response.getOutputStream()); return; } else { InputStream instream = service.getClassLoader() .getResourceAsStream(DeploymentConstants.META_INF + "/" + schemaName); if (instream != null) { response.setStatus(HttpStatus.SC_OK); response.setContentType("text/xml"); OutputStream outstream = response.getOutputStream(); boolean checkLength = true; int length = Integer.MAX_VALUE; int nextValue = instream.read(); if (checkLength) length--; while (-1 != nextValue && length >= 0) { outstream.write(nextValue); nextValue = instream.read(); if (checkLength) length--; } outstream.flush(); return; } else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int ret = service.printXSD(baos, schemaName); if (ret > 0) { baos.flush(); instream = new ByteArrayInputStream(baos.toByteArray()); response.setStatus(HttpStatus.SC_OK); response.setContentType("text/xml"); OutputStream outstream = response.getOutputStream(); boolean checkLength = true; int length = Integer.MAX_VALUE; int nextValue = instream.read(); if (checkLength) length--; while (-1 != nextValue && length >= 0) { outstream.write(nextValue); nextValue = instream.read(); if (checkLength) length--; } outstream.flush(); return; } // no schema available by that name - send 404 response.sendError(HttpStatus.SC_NOT_FOUND, "Schema Not Found!"); return; } } } } if (uri.indexOf("?wsdl2=") > 0) { String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?wsdl2=")); if (processInternalWSDL(uri, configurationContext, serviceName, response, getHost(request))) return; } if (uri.indexOf("?wsdl=") > 0) { String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?wsdl=")); if (processInternalWSDL(uri, configurationContext, serviceName, response, getHost(request))) return; } String contentType = null; Header[] headers = request.getHeaders(HTTPConstants.HEADER_CONTENT_TYPE); if (headers != null && headers.length > 0) { contentType = headers[0].getValue(); int index = contentType.indexOf(';'); if (index > 0) { contentType = contentType.substring(0, index); } } // deal with GET request pi = RESTUtil.processURLRequest(msgContext, response.getOutputStream(), contentType); } else if (method.equals(HTTPConstants.HEADER_POST)) { // deal with POST request String contentType = request.getContentType(); if (HTTPTransportUtils.isRESTRequest(contentType)) { pi = RESTUtil.processXMLRequest(msgContext, request.getInputStream(), response.getOutputStream(), contentType); } else { String ip = (String) msgContext.getProperty(MessageContext.TRANSPORT_ADDR); if (ip != null) { uri = ip + uri; } pi = HTTPTransportUtils.processHTTPPostRequest(msgContext, request.getInputStream(), response.getOutputStream(), contentType, soapAction, uri); } } else if (method.equals(HTTPConstants.HEADER_PUT)) { String contentType = request.getContentType(); msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType); pi = RESTUtil.processXMLRequest(msgContext, request.getInputStream(), response.getOutputStream(), contentType); } else if (method.equals(HTTPConstants.HEADER_DELETE)) { pi = RESTUtil.processURLRequest(msgContext, response.getOutputStream(), null); } else { throw new MethodNotSupportedException(method + " method not supported"); } Boolean holdResponse = (Boolean) msgContext.getProperty(RequestResponseTransport.HOLD_RESPONSE); if (pi.equals(InvocationResponse.SUSPEND) || (holdResponse != null && Boolean.TRUE.equals(holdResponse))) { try { ((RequestResponseTransport) msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL)) .awaitResponse(); } catch (InterruptedException e) { throw new IOException("We were interrupted, so this may not function correctly:" + e.getMessage()); } } // Finalize response RequestResponseTransport requestResponseTransportControl = (RequestResponseTransport) msgContext .getProperty(RequestResponseTransport.TRANSPORT_CONTROL); if (TransportUtils.isResponseWritten(msgContext) || ((requestResponseTransportControl != null) && requestResponseTransportControl.getStatus() .equals(RequestResponseTransport.RequestResponseTransportStatus.SIGNALLED))) { // The response is written or signalled. The current status is used (probably SC_OK). } else { // The response may be ack'd, mark the status as accepted. response.setStatus(HttpStatus.SC_ACCEPTED); } }
From source file:com.liato.bankdroid.banking.banks.seb.SEB.java
@Override protected LoginPackage preLogin() throws BankException, ClientProtocolException, IOException { urlopen = new Urllib(context, CertificateReader.getCertificates(context, R.raw.cert_seb_web)); urlopen.setContentCharset(HTTP.ISO_8859_1); urlopen.addHeader("Referer", "https://m.seb.se/"); urlopen.setKeepAliveTimeout(5);//from www. j av a 2 s.c o m //response = urlopen.open("https://m.seb.se/cgi-bin/pts3/mpo/9000/mpo9001.aspx?P1=logon.htm"); List<NameValuePair> postData = new ArrayList<NameValuePair>(); postData.add(new BasicNameValuePair("A1", username)); postData.add(new BasicNameValuePair("A2", password)); postData.add(new BasicNameValuePair("A3", "4")); return new LoginPackage(urlopen, postData, response, "https://m.seb.se/cgi-bin/pts3/mps/1000/mps1001bm.aspx"); }
From source file:com.mockey.ClientExecuteProxy.java
/** * /*from w ww. ja va2s . c om*/ * @param twistInfo * @param proxyServer * @param realServiceUrl * @param httpMethod * @param request * @return * @throws ClientExecuteProxyException */ public ResponseFromService execute(TwistInfo twistInfo, ProxyServerModel proxyServer, Url realServiceUrl, boolean allowRedirectFollow, RequestFromClient request) throws ClientExecuteProxyException { log.info("Request: " + String.valueOf(realServiceUrl)); // general setup SchemeRegistry supportedSchemes = new SchemeRegistry(); // Register the "http" and "https" protocol schemes, they are // required by the default operator to look up socket factories. supportedSchemes.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); supportedSchemes.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); // prepare parameters HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.ISO_8859_1); HttpProtocolParams.setUseExpectContinue(params, false); ClientConnectionManager ccm = new ThreadSafeClientConnManager(supportedSchemes); DefaultHttpClient httpclient = new DefaultHttpClient(ccm, params); if (!allowRedirectFollow) { // Do NOT allow for 302 REDIRECT httpclient.setRedirectStrategy(new DefaultRedirectStrategy() { public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) { boolean isRedirect = false; try { isRedirect = super.isRedirected(request, response, context); } catch (ProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (!isRedirect) { int responseCode = response.getStatusLine().getStatusCode(); if (responseCode == 301 || responseCode == 302) { return true; } } return isRedirect; } }); } else { // Yes, allow for 302 REDIRECT // Nothing needed here. } // Prevent CACHE, 304 not modified // httpclient.addRequestInterceptor(new HttpRequestInterceptor() { // public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { // // request.setHeader("If-modified-Since", "Fri, 13 May 2006 23:54:18 GMT"); // // } // }); CookieStore cookieStore = httpclient.getCookieStore(); for (Cookie httpClientCookie : request.getHttpClientCookies()) { // HACK: // httpClientCookie.getValue(); cookieStore.addCookie(httpClientCookie); } // httpclient.setCookieStore(cookieStore); if (ClientExecuteProxy.cookieStore == null) { ClientExecuteProxy.cookieStore = httpclient.getCookieStore(); } else { httpclient.setCookieStore(ClientExecuteProxy.cookieStore); } StringBuffer requestCookieInfo = new StringBuffer(); // Show what cookies are in the store . for (Cookie cookie : ClientExecuteProxy.cookieStore.getCookies()) { log.debug("Cookie in the cookie STORE: " + cookie.toString()); requestCookieInfo.append(cookie.toString() + "\n\n\n"); } if (proxyServer.isProxyEnabled()) { // make sure to use a proxy that supports CONNECT httpclient.getCredentialsProvider().setCredentials(proxyServer.getAuthScope(), proxyServer.getCredentials()); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyServer.getHttpHost()); } // TWISTING Url originalRequestUrlBeforeTwisting = null; if (twistInfo != null) { String fullurl = realServiceUrl.getFullUrl(); String twistedUrl = twistInfo.getTwistedValue(fullurl); if (twistedUrl != null) { originalRequestUrlBeforeTwisting = realServiceUrl; realServiceUrl = new Url(twistedUrl); } } ResponseFromService responseMessage = null; try { HttpHost htttphost = new HttpHost(realServiceUrl.getHost(), realServiceUrl.getPort(), realServiceUrl.getScheme()); HttpResponse response = httpclient.execute(htttphost, request.postToRealServer(realServiceUrl)); if (response.getStatusLine().getStatusCode() == 302) { log.debug("FYI: 302 redirect occuring from " + realServiceUrl.getFullUrl()); } responseMessage = new ResponseFromService(response); responseMessage.setOriginalRequestUrlBeforeTwisting(originalRequestUrlBeforeTwisting); responseMessage.setRequestUrl(realServiceUrl); } catch (Exception e) { log.error(e); throw new ClientExecuteProxyException("Unable to retrieve a response. ", realServiceUrl, e); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } // Parse out the response information we're looking for // StringBuffer responseCookieInfo = new StringBuffer(); // // Show what cookies are in the store . // for (Cookie cookie : ClientExecuteProxy.cookieStore.getCookies()) { // log.info("Cookie in the cookie STORE: " + cookie.toString()); // responseCookieInfo.append(cookie.toString() + "\n\n\n"); // // } // responseMessage.setRequestCookies(requestCookieInfo.toString()); // responseMessage.setResponseCookies(responseCookieInfo.toString()); return responseMessage; }
From source file:com.mockey.model.ResponseFromService.java
public void writeToOutput(HttpServletResponse resp) throws IOException { // copy the headers out if (headers != null) { for (Header header : headers) { // copy the cookies if (ignoreHeader(header.getName())) { log.debug("Ignoring header: " + header.getName()); } else if (header.getName().equalsIgnoreCase("Set-Cookie")) { // Ignore... } else if (header.getName().equals("Content-Type")) { // copy the content type resp.setContentType(header.getValue()); } else resp.setHeader(header.getName(), header.getValue()); }//ww w .ja v a 2s . c o m } // For cookie information we already extracted from initialization. for (Cookie cookie : this.cookieList) { resp.addCookie(cookie); } if (body != null) { byte[] myISO88591asBytes = body.getBytes(HTTP.ISO_8859_1); new PrintStream(resp.getOutputStream()).write(myISO88591asBytes); resp.getOutputStream().flush(); } else { PrintStream out = new PrintStream(resp.getOutputStream()); out.println(body); } }
From source file:ro.nextreports.server.service.DefaultSecurityService.java
/** * A reset token looks like://from w w w . jav a2 s . c o m * USERNAME-sep-DIGEST(USER_PASSWORD_HASH)-sep-currentTimeMillis */ public String generateResetToken(User user) { String encryptedToken = tokenEncryptor.encrypt(user.getUsername() + SEPARATOR + simpleDigester.digest(user.getPassword()) + SEPARATOR + System.currentTimeMillis()); return UrlEncoder.QUERY_INSTANCE.encode(encryptedToken, HTTP.ISO_8859_1); }
From source file:ch.ethz.sms.androidsms.impl.SMS.java
private void createPostBody() { try {/*w w w . ja v a 2 s . c o m*/ UrlEncodedFormEntity urlEFEntity = new UrlEncodedFormEntity(mPostBodyData, HTTP.ISO_8859_1); mHttpPost.setEntity(urlEFEntity); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
From source file:edu.ucsb.eucalyptus.transport.http.Axis2HttpWorker.java
private void handleServicesList(final AxisHttpResponse response, final ConfigurationContext configurationContext) throws IOException { String s = HTTPTransportReceiver.getServicesHTML(configurationContext); response.setStatus(HttpStatus.SC_OK); response.setContentType("text/html"); OutputStream out = response.getOutputStream(); out.write(EncodingUtils.getBytes(s, HTTP.ISO_8859_1)); }