Example usage for org.apache.http.params HttpParams setParameter

List of usage examples for org.apache.http.params HttpParams setParameter

Introduction

In this page you can find the example usage for org.apache.http.params HttpParams setParameter.

Prototype

HttpParams setParameter(String str, Object obj);

Source Link

Usage

From source file:be.milieuinfo.core.proxy.controller.ProxyServlet.java

private void readConfigParam(HttpParams hcParams, String hcParamName, Class<?> type) {
    String val_str = getServletConfig().getInitParameter(hcParamName);
    if (val_str == null)
        return;//  ww w . ja  va2s.  c  o  m
    Object val_obj;
    if (type == String.class) {
        val_obj = val_str;
    } else {
        try {
            val_obj = type.getMethod("valueOf", String.class).invoke(type, val_str);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    hcParams.setParameter(hcParamName, val_obj);
}

From source file:uk.ac.ebi.phenotype.web.proxy.ExternalUrlConfiguratbleProxyServlet.java

private void readConfigParam(HttpParams hcParams, String hcParamName, Class type) {
    String val_str = getServletConfig().getInitParameter(hcParamName);
    if (val_str == null)
        return;//from  w w  w  . j  a  va  2  s. c o  m
    Object val_obj;
    if (type == String.class) {
        val_obj = val_str;
    } else {
        try {
            val_obj = type.getMethod("valueOf", String.class).invoke(type, val_str);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    hcParams.setParameter(hcParamName, val_obj);
}

From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java

public boolean webServiceImageUrl(String msgSubject) {
    try {/*www.j  a  v a  2s.c  o  m*/
        Log.d("webServiceImageUrl", "called");
        HttpParams p = new BasicHttpParams();
        p.setParameter("user", "1");
        HttpClient httpclient = new DefaultHttpClient(p);
        String url = "http://ip.roaming4world.com/esstel/file-transfer/file_download.php?msg=" + msgSubject;

        Log.d("url", url + " #");
        HttpGet httpget = new HttpGet(url);
        ResponseHandler<String> responseHandler;
        String responseBody;
        responseHandler = new BasicResponseHandler();
        responseBody = httpclient.execute(httpget, responseHandler);
        JSONObject json = new JSONObject(responseBody);
        imageUrl = json.getString("response");
        if (imageUrl.equals("Error")) {
            return false;
        } else {
            return true;
        }
    } catch (Throwable t) {

        t.printStackTrace();

        return false;
    }
}

From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java

public boolean webServiceAcknowledge(String msgSubject) {
    try {// www  .  j av a 2 s .  com
        Log.d("webServiceImageUrl", "called");
        HttpParams p = new BasicHttpParams();
        p.setParameter("user", "1");
        HttpClient httpclient = new DefaultHttpClient(p);
        String url = "http://ip.roaming4world.com/esstel/file-transfer/file_download_ack.php?msg=" + msgSubject;

        Log.d("url", url + " #");
        HttpGet httpget = new HttpGet(url);
        ResponseHandler<String> responseHandler;
        String responseBody;
        responseHandler = new BasicResponseHandler();
        responseBody = httpclient.execute(httpget, responseHandler);
        JSONObject json = new JSONObject(responseBody);
        imageUrl = json.getString("response");
        if (imageUrl.equals("Error")) {
            return false;
        } else {
            return true;
        }
    } catch (Throwable t) {

        t.printStackTrace();

        return false;
    }
}

From source file:snoopware.api.ProxyServlet.java

protected void readConfigParam(HttpParams hcParams, String hcParamName, Class type) {
    String val_str = getServletConfig().getInitParameter(hcParamName);
    if (val_str == null) {
        return;//from  ww w .j  a va2  s.com
    }
    Object val_obj;
    if (type == String.class) {
        val_obj = val_str;
    } else {
        try {
            //noinspection unchecked
            val_obj = type.getMethod("valueOf", String.class).invoke(type, val_str);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    hcParams.setParameter(hcParamName, val_obj);
}

From source file:org.ocpsoft.rewrite.servlet.config.proxy.ProxyServlet.java

protected void readConfigParam(HttpParams hcParams, String hcParamName, Class type) {
    String val_str = getServletConfig().getInitParameter(hcParamName);
    if (val_str == null)
        return;//from www. jav  a  2s  . co  m
    Object val_obj;
    if (type == String.class) {
        val_obj = val_str;
    } else {
        try {
            /*
             * noinspection unchecked
             */
            val_obj = type.getMethod("valueOf", String.class).invoke(type, val_str);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    hcParams.setParameter(hcParamName, val_obj);
}

From source file:kornell.server.ProxyServlet.java

protected void readConfigParam(HttpParams hcParams, String hcParamName, Class type) {
    String val_str = getServletConfig().getInitParameter(hcParamName);
    if (val_str == null)
        return;/*from  ww  w. j  ava  2  s .c  om*/
    Object val_obj;
    if (type == String.class) {
        val_obj = val_str;
    } else {
        try {
            //noinspection unchecked
            val_obj = type.getMethod("valueOf", String.class).invoke(type, val_str);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    hcParams.setParameter(hcParamName, val_obj);
}

From source file:org.jasig.portal.security.provider.saml.SAMLDelegatedAuthenticationService.java

/**
 * This method takes the SOAP AuthnRequest, sends it to the IdP, and retrieves
 * the result.  This method does not process the result.
 * /*from  w w  w  . ja v  a2s  . co  m*/
 * @param samlSession SAML session
 * @param authnState 
 * @return true, if successful
 */
private boolean getSOAPResponse(SAMLSession samlSession, DelegatedSAMLAuthenticationState authnState) {
    this.logger.debug("Step 4 of 5: Get SOAP response from IDP");

    String result = null;
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, "UTF-8");
    params.setParameter("SOAPAction", "urn:liberty:ssos:2006-08:AuthnRequest");
    HttpClient client = new DefaultHttpClient(params);

    try {
        logger.debug("Getting SOAP response from {} with POST body:\n{}", authnState.getIdpEndpoint(),
                authnState.getModifiedSOAPRequest());
        setupIdPClientConnection(client, samlSession, authnState);
        HttpPost method = new HttpPost(authnState.getIdpEndpoint());
        method.setHeader("Content-Type", "text/xml");
        StringEntity postData = new StringEntity(authnState.getModifiedSOAPRequest(), HTTP.UTF_8);
        method.setEntity(postData);
        HttpResponse httpResponse = client.execute(method);
        int resultCode = httpResponse.getStatusLine().getStatusCode();

        if (resultCode >= HttpStatus.SC_OK && resultCode < 300) {
            HttpEntity httpEntity = httpResponse.getEntity();
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            httpEntity.writeTo(output);
            result = output.toString();
            logger.debug("Got SOAP response:\n{}", result);
            authnState.setSoapResponse(result);
            return true;
        }

        logger.error("Unsupported HTTP result code when retrieving the resource: " + resultCode + ".");
        throw new DelegatedAuthenticationRuntimeException(
                "Unsupported HTTP result code when retrieving the resource: " + resultCode + ".");
    } catch (Exception ex) {
        logger.error("Exception caught when trying to retrieve the resource.", ex);
        throw new DelegatedAuthenticationRuntimeException(
                "Exception caught when trying to retrieve the resource.", ex);
    } finally {
        client.getConnectionManager().shutdown();
    }
}

From source file:org.dasein.cloud.gogrid.GoGridMethod.java

private @Nonnull HttpClient getClient(@Nonnull ProviderContext ctx, boolean ssl) {
    HttpParams params = new BasicHttpParams();

    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    //noinspection deprecation
    HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
    HttpProtocolParams.setUserAgent(params, "Dasein Cloud");

    Properties p = ctx.getCustomProperties();

    if (p != null) {
        String proxyHost = p.getProperty("proxyHost");
        String proxyPort = p.getProperty("proxyPort");

        if (proxyHost != null) {
            int port = 0;

            if (proxyPort != null && proxyPort.length() > 0) {
                port = Integer.parseInt(proxyPort);
            }// ww w  .  j a v  a  2 s. com
            params.setParameter(ConnRoutePNames.DEFAULT_PROXY,
                    new HttpHost(proxyHost, port, ssl ? "https" : "http"));
        }
    }
    return new DefaultHttpClient(params);
}