Examples of AuthManager


Examples of org.apache.jmeter.protocol.http.control.AuthManager

    }

    private int getHeaderSize(String method, URL url) {
        HeaderManager headers = getHeaderManager();
        CookieManager cookies = getCookieManager();
        AuthManager auth = getAuthManager();
        int hsz = 1; // Host always
        if(method.equals(HTTPConstants.POST)) {
            HTTPFileArg[] hfa = getHTTPFiles();
            if(hfa.length > 0) {
                hsz += 3;
            } else {
                hsz += 2;
            }
        }
        if(headers != null) {
            hsz += headers.size();
        }
        if(cookies != null) {
            hsz += cookies.getCookieCount();
        }
        if(auth != null) {
                String authHeader = auth.getAuthHeaderForURL(url);
            if(authHeader != null) {
            ++hsz;
            }
        }
        return hsz;
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager


    private String setConnectionHeaders(URL url, String host, String method)
    throws IOException {
        HeaderManager headers = getHeaderManager();
        AuthManager auth = getAuthManager();
        StringBuilder hbuf = new StringBuilder();
        // Allow Headers to override Host setting
        hbuf.append("Host").append(COLON_SPACE).append(host).append(NEWLINE);//$NON-NLS-1$
        setInt(0xA00b); //Host
        setString(host);
        if(headers != null) {
            CollectionProperty coll = headers.getHeaders();
            PropertyIterator i = coll.iterator();
            while(i.hasNext()) {
                Header header = (Header)i.next().getObjectValue();
                String n = header.getName();
                String v = header.getValue();
                hbuf.append(n).append(COLON_SPACE).append(v).append(NEWLINE);
                int hc = translateHeader(n);
                if(hc > 0) {
                    setInt(hc+AJP_HEADER_BASE);
                } else {
                    setString(n);
                }
                setString(v);
            }
        }
        if(method.equals(HTTPConstants.POST)) {
            int cl = -1;
            HTTPFileArg[] hfa = getHTTPFiles();
            if(hfa.length > 0) {
                HTTPFileArg fa = hfa[0];
                String fn = fa.getPath();
                File input = new File(fn);
                cl = (int)input.length();
                if(body != null) {
                    JOrphanUtils.closeQuietly(body);
                    body = null;
                }
                body = new BufferedInputStream(new FileInputStream(input));
                setString(HTTPConstants.HEADER_CONTENT_DISPOSITION);
                setString("form-data; name=\""+encode(fa.getParamName())+
                      "\"; filename=\"" + encode(fn) +"\""); //$NON-NLS-1$ //$NON-NLS-2$
                String mt = fa.getMimeType();
                hbuf.append(HTTPConstants.HEADER_CONTENT_TYPE).append(COLON_SPACE).append(mt).append(NEWLINE);
                setInt(0xA007); // content-type
                setString(mt);
            } else {
                hbuf.append(HTTPConstants.HEADER_CONTENT_TYPE).append(COLON_SPACE).append(HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED).append(NEWLINE);
                setInt(0xA007); // content-type
                setString(HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
                StringBuilder sb = new StringBuilder();
                boolean first = true;
                PropertyIterator args = getArguments().iterator();
                while(args.hasNext()) {
                    JMeterProperty arg = args.next();
                    if(first) {
                        first = false;
                    } else {
                        sb.append('&');
                    }
                    sb.append(arg.getStringValue());
                }
                stringBody = sb.toString();
                byte [] sbody = stringBody.getBytes(); // TODO - charset?
                cl = sbody.length;
                body = new ByteArrayInputStream(sbody);
            }
            hbuf.append(HTTPConstants.HEADER_CONTENT_LENGTH).append(COLON_SPACE).append(String.valueOf(cl)).append(NEWLINE);
            setInt(0xA008); // Content-length
            setString(String.valueOf(cl));
        }
        if(auth != null) {
            String authHeader = auth.getAuthHeaderForURL(url);
            if(authHeader != null) {
                setInt(0xA005); // Authorization
                setString(authHeader);
                hbuf.append(HTTPConstants.HEADER_AUTHORIZATION).append(COLON_SPACE).append(authHeader).append(NEWLINE);
            }
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager

      // We get the AuthManager and pass it to the WSDLHelper
      // once the sampler is updated to Axis, all of this stuff
      // should not be necessary. Now I just need to find the
      // time and motivation to do it.
      WebServiceSampler sampler = (WebServiceSampler) this.createTestElement();
      AuthManager manager = sampler.getAuthManager();
      HELPER = new WSDLHelper(url, manager);
      HELPER.parse();
      return HELPER.getWebMethods();
    } catch (Exception exception) {
      JOptionPane.showConfirmDialog(this,
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager

    tableModel = new InnerTableModel();
    init();
  }

  public TestElement createTestElement() {
    AuthManager authMan = tableModel.manager;
    configureTestElement(authMan);
    return (TestElement) authMan.clone();
  }
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager

    public InnerTableModel(AuthManager man) {
      manager = man;
    }

    public InnerTableModel() {
      manager = new AuthManager();
    }
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager

  public Arguments getArguments() {
    return (Arguments) getProperty(ARGUMENTS).getObjectValue();
  }

  public void setAuthManager(AuthManager value) {
    AuthManager mgr = getAuthManager();
    if (mgr != null) {
      log.warn("Existing AuthManager " + mgr.getName() + " superseded by " + value.getName());
    }
    setProperty(new TestElementProperty(AUTH_MANAGER, value));
  }
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager

           
      // set the auth. thanks to KiYun Roe for contributing the patch
      // I cleaned up the patch slightly. 5-26-05
      if (getAuthManager() != null) {
        if (getAuthManager().getAuthForURL(getUrl()) != null) {
          AuthManager authmanager = getAuthManager();
          Authorization auth = authmanager.getAuthForURL(getUrl());
          spconn.setUserName(auth.getUser());
          spconn.setPassword(auth.getPass());
        } else {
          log.warn("the URL for the auth was null." + " Username and password not set");
        }
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager

    }

    private int getHeaderSize(String method, URL url) {
        HeaderManager headers = getHeaderManager();
        CookieManager cookies = getCookieManager();
        AuthManager auth = getAuthManager();
        int hsz = 1; // Host always
        if(method.equals(POST)) {
            String fn = getFilename();
            if(fn != null && fn.trim().length() > 0) {
                hsz += 3;
            } else {
                hsz += 2;
            }
        }
        if(headers != null) {
            hsz += headers.size();
        }
        if(cookies != null) {
            hsz += cookies.getCookieCount();
        }
        if(auth != null) {
                String authHeader = auth.getAuthHeaderForURL(url);
            if(authHeader != null) {
            ++hsz;
            }
        }
        return hsz;
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager


    private String setConnectionHeaders(URL url, String host, String method)
    throws IOException {
        HeaderManager headers = getHeaderManager();
        AuthManager auth = getAuthManager();
        StringBuffer hbuf = new StringBuffer();
        // Allow Headers to override Host setting
        hbuf.append("Host").append(COLON_SPACE).append(host).append(NEWLINE);//$NON-NLS-1$
        setInt(0xA00b); //Host
        setString(host);
        if(headers != null) {
            CollectionProperty coll = headers.getHeaders();
            PropertyIterator i = coll.iterator();
            while(i.hasNext()) {
                Header header = (Header)i.next().getObjectValue();
                String n = header.getName();
                String v = header.getValue();
                hbuf.append(n).append(COLON_SPACE).append(v).append(NEWLINE);
                int hc = translateHeader(n);
                if(hc > 0) {
                    setInt(hc+AJP_HEADER_BASE);
                } else {
                    setString(n);
                }
                setString(v);
            }
        }
        if(method.equals(POST)) {
            int cl = -1;
            String fn = getFilename();
            if(fn != null && fn.trim().length() > 0) {
                File input = new File(fn);
                cl = (int)input.length();
                body = new FileInputStream(input);
                setString(HEADER_CONTENT_DISPOSITION);
                setString("form-data; name=\""+encode(getFileField())+
                      "\"; filename=\"" + encode(fn) +"\""); //$NON-NLS-1$ //$NON-NLS-2$
                String mt = getMimetype();
                hbuf.append(HEADER_CONTENT_TYPE).append(COLON_SPACE).append(mt).append(NEWLINE);
                setInt(0xA007); // content-type
                setString(mt);
            } else {
                hbuf.append(HEADER_CONTENT_TYPE).append(COLON_SPACE).append(APPLICATION_X_WWW_FORM_URLENCODED).append(NEWLINE);
                setInt(0xA007); // content-type
                setString(APPLICATION_X_WWW_FORM_URLENCODED);
                StringBuffer sb = new StringBuffer();
                boolean first = true;
                PropertyIterator args = getArguments().iterator();
                while(args.hasNext()) {
                    JMeterProperty arg = args.next();
                    if(first) {
                        first = false;
                    } else {
                        sb.append('&');
                    }
                    sb.append(arg.getName()).append('=').append(arg.getStringValue());
                }
                byte [] sbody = sb.toString().getBytes(); //FIXME - encoding
                cl = sbody.length;
                body = new ByteArrayInputStream(sbody);
            }
            hbuf.append(HEADER_CONTENT_LENGTH).append(COLON_SPACE).append(String.valueOf(cl)).append(NEWLINE);
            setInt(0xA008); // Content-length
            setString(String.valueOf(cl));
        }
        if(auth != null) {
            String authHeader = auth.getAuthHeaderForURL(url);
            if(authHeader != null) {
                setInt(0xA005); // Authorization
                setString(authHeader);
                hbuf.append(HEADER_AUTHORIZATION).append(COLON_SPACE).append(authHeader).append(NEWLINE);
            }
View Full Code Here

Examples of org.apache.jmeter.protocol.http.control.AuthManager

     * @throws ClientProtocolException
     */
    private HttpResponse executeRequest(final HttpClient httpClient,
            final HttpRequestBase httpRequest, final HttpContext localContext, final URL url)
            throws IOException, ClientProtocolException {
        AuthManager authManager = getAuthManager();
        if (authManager != null) {
            Subject subject = authManager.getSubjectForUrl(url);
            if(subject != null) {
                try {
                    return Subject.doAs(subject,
                            new PrivilegedExceptionAction<HttpResponse>() {
   
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.