Examples of HTTPRequestInfo


Examples of org.exolab.jms.net.http.HTTPRequestInfo

        final int proxyPort = 1030;
        final String proxyUser = "bar";
        final String proxyPassword = "fly";
        final SSLProperties ssl = new SSLProperties();

        HTTPRequestInfo info = populate(uri, proxyHost, proxyPort, proxyUser,
                                        proxyPassword, ssl);

        assertEquals(uri, info.getURI().toString());
        assertEquals(proxyHost, info.getProxyHost());
        assertEquals(proxyPort, info.getProxyPort());
        assertEquals(proxyUser, info.getProxyUser());
        assertEquals(proxyPassword, info.getProxyPassword());
        assertEquals(ssl, info.getSSLProperties());
    }
View Full Code Here

Examples of org.exolab.jms.net.http.HTTPRequestInfo

        final int proxyPort = 9090;
        final String proxyUser = "hoo";
        final String proxyPassword = "shoo";
        final SSLProperties ssl = new SSLProperties();

        HTTPRequestInfo info1 = populate(uri, proxyHost, proxyPort, proxyUser,
                                         proxyPassword, null);
        HTTPRequestInfo info2 = populate(uri, proxyHost, proxyPort, proxyUser,
                                         proxyPassword, null);

        assertEquals(info1, info2);

        info2.setSSLProperties(ssl);
        assertFalse(info1.equals(info2));
    }
View Full Code Here

Examples of org.exolab.jms.net.http.HTTPRequestInfo

        ssl.setTrustStore("trustStore");
        ssl.setTrustStorePassword("trustStorePassword");
        ssl.setTrustStoreType("PCKS12");

        Properties properties = new Properties(prefix);
        HTTPRequestInfo info1 = populate(uri, proxyHost, proxyPort, proxyUser,
                                         proxyPassword, ssl);
        info1.export(properties);
        HTTPRequestInfo info2 = new HTTPRequestInfo(new URI(uri), properties);
        assertEquals(info1, info2);

        assertEquals(uri, info2.getURI().toString());
        assertEquals(proxyHost, info2.getProxyHost());
        assertEquals(proxyPort, info2.getProxyPort());
        assertEquals(proxyUser, info2.getProxyUser());
        assertEquals(proxyPassword, info2.getProxyPassword());
        assertEquals(ssl, info2.getSSLProperties());
    }
View Full Code Here

Examples of org.exolab.jms.net.http.HTTPRequestInfo

     */
    private HTTPRequestInfo populate(String uri, String host, int port,
                                     String user, String password,
                                     SSLProperties ssl)
            throws Exception {
        HTTPRequestInfo info = new HTTPRequestInfo(new URI(uri));
        info.setProxyHost(host);
        info.setProxyPort(port);
        info.setProxyUser(user);
        info.setProxyPassword(password);
        info.setSSLProperties(ssl);
        return info;
    }
View Full Code Here

Examples of org.switchyard.component.http.composer.HttpRequestInfo

     * @param request ServletRequest
     * @return Request information parsed by servlet container from a servlet request
     */
    @SuppressWarnings("unchecked")
    public HttpRequestInfo getRequestInfo(HttpServletRequest request) {
        HttpRequestInfo requestInfo = new HttpRequestInfo();

        requestInfo.setAuthType(request.getAuthType());
        requestInfo.setCharacterEncoding(request.getCharacterEncoding());
        requestInfo.setContentType(request.getContentType());
        requestInfo.setContextPath(request.getContextPath());
        requestInfo.setLocalAddr(request.getLocalAddr());
        requestInfo.setLocalName(getLocalName(request));
        requestInfo.setMethod(request.getMethod());
        requestInfo.setProtocol(request.getProtocol());
        requestInfo.setQueryString(request.getQueryString());
        requestInfo.setRemoteAddr(request.getRemoteAddr());
        requestInfo.setRemoteHost(request.getRemoteHost());
        requestInfo.setRemoteUser(request.getRemoteUser());
        requestInfo.setContentLength(request.getContentLength());
        requestInfo.setRequestSessionId(request.getRequestedSessionId());
        requestInfo.setRequestURI(request.getRequestURI());
        requestInfo.setScheme(request.getScheme());
        requestInfo.setServerName(request.getServerName());
        requestInfo.setRequestPath(request.getServletPath());

        String pathInfo = request.getPathInfo();
        requestInfo.setPathInfo(pathInfo);

        if (pathInfo != null) {
            List<String> pathInfoTokens = requestInfo.getPathInfoTokens();

            pathInfoTokens.addAll(Arrays.asList(request.getPathInfo().split("/")));

            // remove empty tokens...
            Iterator<String> tokensIterator = pathInfoTokens.iterator();
            while (tokensIterator.hasNext()) {
                if (tokensIterator.next().trim().length() == 0) {
                    tokensIterator.remove();
                }
            }
        }

        // Http Query params...
        Map paramMap = request.getParameterMap();
        if (paramMap != null) {
            requestInfo.getQueryParams().putAll(paramMap);
        }

        // Credentials...
        requestInfo.getCredentials().addAll(SecurityServices.getServletRequestCredentialExtractor().extract(request));

        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace(requestInfo);
        }
        return requestInfo;
View Full Code Here

Examples of org.switchyard.component.http.composer.HttpRequestInfo

     * @param type ContentType
     * @return Request information from a http exchange
     * @throws IOException when the request information could not be read
     */
    public static HttpRequestInfo getRequestInfo(HttpExchange request, ContentType type) throws IOException {
        HttpRequestInfo requestInfo = new HttpRequestInfo();

        if (request.getHttpContext().getAuthenticator() instanceof BasicAuthenticator) {
            requestInfo.setAuthType(HttpServletRequest.BASIC_AUTH);
        }
        URI u = request.getRequestURI();
        URI requestURI = null;
        try {
            requestURI = new URI(u.getScheme(), u.getUserInfo(), u.getHost(), u.getPort(), u.getPath(), null, null);
        } catch (URISyntaxException e) {
            // Strange that this could happen when copying from another URI.
            LOGGER.debug(e);
        }
        requestInfo.setCharacterEncoding(type.getCharset());
        requestInfo.setContentType(type.toString());
        requestInfo.setContextPath(request.getHttpContext().getPath());
        requestInfo.setLocalAddr(request.getLocalAddress().getAddress().getHostAddress());
        requestInfo.setLocalName(request.getLocalAddress().getAddress().getHostName());
        requestInfo.setMethod(request.getRequestMethod());
        requestInfo.setProtocol(request.getProtocol());
        requestInfo.setQueryString(u.getQuery());
        requestInfo.setRemoteAddr(request.getRemoteAddress().getAddress().getHostAddress());
        requestInfo.setRemoteHost(request.getRemoteAddress().getAddress().getHostName());
        if (request.getHttpContext().getAuthenticator() instanceof BasicAuthenticator) {
            requestInfo.setRemoteUser(request.getPrincipal().getUsername());
        }
        requestInfo.setContentLength(request.getRequestBody().available());
        // requestInfo.setRequestSessionId(request.getRequestedSessionId());
        if (requestURI != null) {
            requestInfo.setRequestURI(requestURI.toString());
        }
        requestInfo.setScheme(u.getScheme());
        requestInfo.setServerName(u.getHost());
        requestInfo.setRequestPath(u.getPath());

        // Http Query params...
        if (requestInfo.getQueryString() != null) {
            Charset charset = null;
            if (type.getCharset() != null) {
                try {
                    charset = Charset.forName(type.getCharset());
                } catch (Exception exception) {
                    LOGGER.debug(exception);
                }
            }
            for (NameValuePair nameValuePair : URLEncodedUtils.parse(requestInfo.getQueryString(), charset)) {
                requestInfo.addQueryParam(nameValuePair.getName(), nameValuePair.getValue());
            }
        }

        // Credentials...
        requestInfo.getCredentials().addAll(new HttpExchangeCredentialExtractor().extract(request));

        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace(requestInfo);
        }

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.