Examples of HttpState


Examples of org.apache.commons.httpclient.HttpState

      // Start by accessing the secured index.html of war1
      HttpClient httpConn = new HttpClient();
     
      checkAccessDenied(httpConn, warA1 + "index.html");

      HttpState state = httpConn.getState();
     
      log.debug("Saw JSESSIONID="+getSessionIdValueFromState(state));

      // Submit the login form
      executeFormLogin(httpConn, warA1);
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

      // Start by accessing the secured index.html of war1
      HttpClient httpConn = new HttpClient();

      checkAccessDenied(httpConn, warA1 + "index.html");

      HttpState state = httpConn.getState();

      log.debug("Saw JSESSIONID="+getSessionIdValueFromState(state));

      // Submit the login form
      executeFormLogin(httpConn, warA1);
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

  HttpClient http() {
    if (client==null) {
      client= new HttpClient();
      if (state==null)
        state= new HttpState();
      client.setState(state);
    }
    return client;
  }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

   * JSON-RPC tests need this setup to operate propely.
   * This call invokes registerObject("test", ...) from the  JSP
   */
  void setupServerTestEnvironment(String url) throws HttpException, IOException {
    HttpClient client= new HttpClient();
    state= new HttpState();
    client.setState(state);
    GetMethod method= new GetMethod(url);
    int status= client.executeMethod(method);
    if (status!=HttpStatus.SC_OK)
      throw new RuntimeException("Setup did not succeed. Make sure the JSON-RPC-Java test application is running on "
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

     * @param authManager
     *            the <code>AuthManager</code> containing all the authorisations for
     *            this <code>UrlConfig</code>
     */
    private void setConnectionAuthorization(HttpClient client, URL u, AuthManager authManager) {
        HttpState state = client.getState();
        if (authManager != null) {
            HttpClientParams params = client.getParams();
            Authorization auth = authManager.getAuthForURL(u);
            if (auth != null) {
                    String username = auth.getUser();
                    String realm = auth.getRealm();
                    String domain = auth.getDomain();
                    if (log.isDebugEnabled()){
                        log.debug(username + " >  D="+ username + " D="+domain+" R="+realm);
                    }
                    state.setCredentials(
                            new AuthScope(u.getHost(),u.getPort(),
                                    realm.length()==0 ? null : realm //"" is not the same as no realm
                                    ,AuthScope.ANY_SCHEME),
                            // NT Includes other types of Credentials
                            new NTCredentials(
                                    username,
                                    auth.getPass(),
                                    localHost,
                                    domain
                            ));
                    // We have credentials - should we set pre-emptive authentication?
                    if (canSetPreEmptive){
                        log.debug("Setting Pre-emptive authentication");
                        params.setAuthenticationPreemptive(true);
                    }
            } else {
                state.clearCredentials();
                if (canSetPreEmptive){
                    params.setAuthenticationPreemptive(false);
                }
            }
        } else {
            state.clearCredentials();
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

            "name1=value1;Version=1;Path=/commons,name1=value2;Version=1;" +
            "Path=/commons/httpclient;Version=1");

        CookieSpec cookiespec = new CookieSpecBase();
        Cookie[] parsed = cookieParse(cookiespec, ".apache.org", 80, "/commons/httpclient", true, header);
        HttpState state = new HttpState();
        state.addCookies(parsed);
        Cookie[] cookies = state.getCookies();
        assertEquals("Wrong number of cookies.",2,cookies.length);
        assertEquals("Name","name1",cookies[0].getName());
        assertEquals("Value","value1",cookies[0].getValue());
        assertEquals("Name","name1",cookies[1].getName());
        assertEquals("Value","value2",cookies[1].getValue());
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

        Header header = new Header("Set-Cookie",
            "name1=value1;Version=1;Path=/commons,name1=value2;Version=1;Path=/commons");

        CookieSpec cookiespec = new CookieSpecBase();
        Cookie[] parsed = cookieParse(cookiespec, ".apache.org", 80, "/commons/httpclient", true, header);
        HttpState state = new HttpState();
        state.addCookies(parsed);
        Cookie[] cookies = state.getCookies();
        assertEquals("Found 1 cookies.",1,cookies.length);
        assertEquals("Name","name1",cookies[0].getName());
        assertEquals("Value","value2",cookies[0].getValue());
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

    return hostConfig;
    }

    private void addHttpAuth(Settings settings, Object[] authSettings) {
        if (StringUtils.hasText(settings.getNetworkHttpAuthUser())) {
            HttpState state = (authSettings[1] != null ? (HttpState) authSettings[1] : new HttpState());
            authSettings[1] = state;
            state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkHttpAuthUser(), settings.getNetworkHttpAuthPass()));
            if (log.isDebugEnabled()) {
                log.info("Using detected HTTP Auth credentials...");
            }
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

            if (StringUtils.hasText(settings.getNetworkProxyHttpUser())) {
                if (!StringUtils.hasText(settings.getNetworkProxyHttpPass())) {
                    log.warn(String.format("HTTP proxy user specified but no/empty password defined - double check the [%s] property", ConfigurationOptions.ES_NET_PROXY_HTTP_PASS));

                }
                HttpState state = new HttpState();
                state.setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkProxyHttpUser(), settings.getNetworkProxyHttpPass()));
                // client is not yet initialized so simply save the object for later
                results[1] = state;
            }

            if (log.isDebugEnabled()) {
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

            "name1=value1;Version=1;Path=/commons,name1=value2;Version=1;" +
            "Path=/commons/httpclient;Version=1");

        CookieSpec cookiespec = new CookieSpecBase();
        Cookie[] parsed = cookieParse(cookiespec, ".apache.org", 80, "/commons/httpclient", true, header);
        HttpState state = new HttpState();
        state.addCookies(parsed);
        Cookie[] cookies = state.getCookies();
        assertEquals("Wrong number of cookies.",2,cookies.length);
        assertEquals("Name","name1",cookies[0].getName());
        assertEquals("Value","value1",cookies[0].getValue());
        assertEquals("Name","name1",cookies[1].getName());
        assertEquals("Value","value2",cookies[1].getValue());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.