Package com.maverick.http

Examples of com.maverick.http.GetMethod


        // #ifdef DEBUG
        log.info("Registering with the server"); //$NON-NLS-1$
        log.info("Server is " + (isSecure ? "https://" : "http://") + getAditoHost() //$NON-NLS-1$
            + ":" + getAditoPort()); //$NON-NLS-1$
        // #endif
        GetMethod post = new GetMethod("/agent"); //$NON-NLS-1$

              client.setPreemtiveAuthentication(doPreemptive);
        if (!doPreemptive && ticket != null) {
          post.setParameter("ticket", ticket); //$NON-NLS-1$
        }

        post.setParameter(
            "agentType", getConfiguration().getAgentType()); //$NON-NLS-1$ //$NON-NLS-2$
        post.setParameter("locale", Locale.getDefault().toString()); //$NON-NLS-1$

        response = client.execute(post);

        if (response.getStatus() == 302) {
          // Reset the client
          this.client = null;

          URL url = new URL(response.getHeaderField("Location")); //$NON-NLS-1$
          aditoHostname = url.getHost();
          if (url.getPort() > 0)
            aditoPort = url.getPort();
          continue;
        } else if (response.getStatus() == 200) {
          con.addListener(this);
          httpConnection = response.getConnection(); // Preserve the
          // connection
          con.registerRequestHandler(MESSAGE_REQUEST, this);
          con.registerRequestHandler(SHUTDOWN_REQUEST, this);
          con.registerRequestHandler(OPEN_URL_REQUEST, this);
          con.registerRequestHandler(UPDATE_RESOURCES_REQUEST, this);

          // Start the protocol

          con.startProtocol(
              response.getConnection().getInputStream(), response
                  .getConnection().getOutputStream(), true);

          // Synchronize and read back server information
          Request syncRequest = new Request(SYNCHRONIZED_REQUEST);
          con.sendRequest(syncRequest, true);
          if (syncRequest.getRequestData() == null)
            throw new IOException(
                "Server failed to return version data");

          ByteArrayReader reader = new ByteArrayReader(syncRequest
              .getRequestData());
          serverVersion = reader.readString();

          /**
           * Initialize the managers. Tunnels are no longer recorded
           * here unless they are active. This simplifies the agent by
           * making it respond to start and stop requests from the new
           * persistent connection with Adito.
           */
          tunnelManager = new TunnelManager(this);
          applicationManager = new ApplicationManager(this);
          webForwardManager = new WebForwardManager(this);
          networkPlaceManager = new NetworkPlaceManager(this);
          updateResources(-1);
          return;
        } else if (response.getStatus() == 401) {
          authenticator = HttpAuthenticatorFactory
              .createAuthenticator(
                  response.getConnection(),
                  response
                      .getHeaderFields("WWW-Authenticate"),
                  "WWW-Authenticate", "Authorization",
                  HttpAuthenticatorFactory.BASIC, post
                      .getURI());
          if (authenticator.wantsPrompt()) {
            if ( !( defaultAuthenticationPrompt != null ? defaultAuthenticationPrompt.promptForCredentials(false, authenticator) :
                getGUI().promptForCredentials(false, authenticator) ) ) {
              throw new AuthenticationCancelledException();
View Full Code Here


    private static void authenticate(HttpClient client, HttpTestContainer container, HttpTestEntry entry) throws Exception {
        String username = isEmpty(entry.getUsername()) ? container.getDefaultUsername() : entry.getUsername();
        String password = isEmpty(entry.getPassword()) ? container.getDefaultPassword() : entry.getPassword();

        GetMethod usernameLogon = new GetMethod("/usernameLogon.do");
        usernameLogon.setParameter("username", username);
        usernameLogon.setParameter("password", password);
        HttpResponse usernameLogonResponse = client.execute(usernameLogon);
        assertEquals("Authenticated Failed", 200, usernameLogonResponse.getStatus());

        GetMethod logon = new GetMethod("/logon.do");
        logon.setParameter("username", username);
        logon.setParameter("password", password);
        HttpResponse logonResponse = client.execute(logon);
        assertEquals("Authenticated Failed", 200, logonResponse.getStatus());
    }
View Full Code Here

        HttpResponse logonResponse = client.execute(logon);
        assertEquals("Authenticated Failed", 200, logonResponse.getStatus());
    }

    private static void logOff(HttpClient client) throws Exception {
        GetMethod getMethod = new GetMethod("/logoff.do");
        HttpResponse httpResponse = client.execute(getMethod);
        assertEquals("Log Off Failed", 302, httpResponse.getStatus());
        assertRedirect(httpResponse, "showHome.do");
    }
View Full Code Here

        return value == null || value.length() == 0;
    }

    private static void runStep(HttpClient client, HttpTestEntryStep step) throws Exception {
        String url = "/" + step.getUrl();
        HttpMethod get = step.isPost() ? new PostMethod(url) : new GetMethod(url);
        for (Map.Entry<String, String> entry : step.getParameters().entrySet()) {
            get.setParameter(entry.getKey(), entry.getValue());
        }

        HttpResponse response = client.execute(get);
View Full Code Here

       
        System.setProperty("com.maverick.ssl.allowUntrustedCertificates", "true");
        System.setProperty("com.maverick.ssl.allowInvalidCertificates", "true");
       
        HttpClient client = new HttpClient("127.0.0.1", 443, true);
        GetMethod get = new GetMethod("AGENT", "/");
        client.setCredentials(new PasswordCredentials("lee", "xxxxxxxxxx"));
        client.setPreemtiveAuthentication(true);
       
        HttpResponse response = client.execute(get);
       
View Full Code Here

TOP

Related Classes of com.maverick.http.GetMethod

Copyright © 2018 www.massapicom. 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.