Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HttpProxyServlet and user authentication

    I see the params for proxyHost and proxyPort but I don't see anything for username and password - I'm assuming these don't exist?

    Some of our clients have proxies that require user authentication for external addresses.

    #2
    That's lower-level, it's JVM-wide settings - see this article.

    Comment


      #3
      Thanks again! As usual, most of the perceived shortcomings of SmartGwt usually end up being our lack of general webapp knowledge. You guys rock. Thanks.

      Comment


        #4
        Hi

        I am trying out the showcase example in my organization and the internet proxy causes the WSDL Databinding sample to fail
        I have tried to set the username and password by specifying VM options and also tried specifying the properties in the server.properties file but it still fails.

        server.properties
        Code:
        http.proxySet=true
        http.proxyHost=proxyHostNameValue
        http.proxyPort=proxyPortValue
        http.proxyUser=myusername
        http.proxyPassword=mypassword

        My logs
        Code:
        === 2013-03-13 09:41:38,586 [l0-2] INFO  RequestContext - URL: '/showcase/sc/HttpProxy', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1': Moz (Gecko) with Accept-Encoding header
        === 2013-03-13 09:41:38,602 [l0-2] INFO  HttpProxyServlet - HttpProxy - No rules defined - proxying all incoming URLs.
        === 2013-03-13 09:41:38,605 [l0-2] DEBUG XML - Parsed XML from (in memory stream): 1ms
        === 2013-03-13 09:41:38,607 [l0-2] DEBUG HttpProxyServlet - HttpProxy - ProxyData is: {
            xsi:"http://www.w3.org/2000/10/XMLSchema-instance",
            url:"http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL",
            httpMethod:"GET"
        }
        === 2013-03-13 09:41:41,500 [l0-2] WARN  HttpProxyServlet - HttpProxy - Tried to proxy to unknown host, returning error
        java.net.UnknownHostException: wsf.cdyne.com
        	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
        	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        	at java.net.Socket.connect(Socket.java:529)
        	at java.net.Socket.connect(Socket.java:478)
        	at java.net.Socket.<init>(Socket.java:375)
        	at java.net.Socket.<init>(Socket.java:249)
        	at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
        	at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
        	at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
        	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
        	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
        	at com.isomorphic.servlet.HttpProxyServlet.doPost(HttpProxyServlet.java:591)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
        	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
        	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
        	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
        	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
        	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
        	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
        	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
        	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        	at org.mortbay.jetty.Server.handle(Server.java:324)
        	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
        	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
        	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
        	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
        	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
        	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
        	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

        If I add the following properties to my HttpProxyServlet configuration in web.xml it still fails with an Authentication Required error.

        web.xml
        Code:
            <servlet>
                <servlet-name>HttpProxy</servlet-name>
                <servlet-class>com.isomorphic.servlet.HttpProxyServlet</servlet-class>
                <init-param>
                    <param-name>proxyHost</param-name>
                    <param-value>proxyHostnameValue</param-value>
                </init-param>
                <init-param>
                    <param-name>proxyPort</param-name>
                    <param-value>proxyPortValue</param-value>
                </init-param>
            </servlet>
        My Logs
        Code:
        === 2013-03-13 09:37:23,798 [l0-3] INFO  RequestContext - URL: '/showcase/sc/HttpProxy', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1': Moz (Gecko) with Accept-Encoding header
        === 2013-03-13 09:37:23,818 [l0-3] INFO  HttpProxyServlet - HttpProxy - No rules defined - proxying all incoming URLs.
        === 2013-03-13 09:37:23,822 [l0-3] DEBUG XML - Parsed XML from (in memory stream): 2ms
        === 2013-03-13 09:37:23,824 [l0-3] DEBUG HttpProxyServlet - HttpProxy - ProxyData is: {
            xsi:"http://www.w3.org/2000/10/XMLSchema-instance",
            url:"http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL",
            httpMethod:"GET"
        }
        === 2013-03-13 09:37:24,226 [l0-3] WARN  HttpProxyServlet - HttpProxy - Method failed: HTTP/1.1 407 authenticationrequired
        === 2013-03-13 09:37:24,228 [l0-3] INFO  HttpProxyServlet - HttpProxy - Response:
        <!--Head-->
        <head>
          <meta http-equiv="X-UA-Compatible" content="IE=7" />
          <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
          <title>McAfee Web Gateway - Notification</title>
          </head>
        <!--/Head-->
        <!--Contents-->
        <!-- FileName: authenticationrequired.html
             Language: [en]
        -->
        <!--Title-->
        <table class='titleTable' background='/mwg-internal/de5fs23hu73ds/files/default/img/bg_navbar.jpg'>
          <tr>
            <td class='titleData'>
              Authentication Required.
            </td>
          </tr>
        </table>
        <!--/Title-->
        
        <!--Content-->
        <table class="contentTable">
          <tr>
            <td class="contentData">
              You must be authenticated to access this URL.
            </td>
          </tr>
        </table>
        <!--/Content-->
        
        <!--Info-->
        <table class="infoTable">
          <tr>
            <td class="infoData">
              <b>URL: </b>http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL<br />
              <b>User name: </b><br />
              <b>Client IP: </b>ipaddress<br />
            </td>
          </tr>
        </table>
        <!--/Info-->
        <!--/Contents-->
            
        
        [WARN] 407 - POST /showcase/sc/HttpProxy (127.0.0.1) 979 bytes
           Request headers
              Host: 127.0.0.1:8888
              User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1
              Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
              Accept-Language: en-us,en;q=0.7,de-de;q=0.3
              Accept-Encoding: gzip, deflate
              Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
              Connection: keep-alive
              Cookie: isc_cState=ready; JSESSIONID=6e7u20ric1b1; GLog=%7B%0D%20%20%20%20left%3A-8%2C%20%0D%20%20%20%20top%3A-8%2C%20%0D%20%20%20%20width%3A1366%2C%20%0D%20%20%20%20height%3A669%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Anull%0D%7D
              Referer: http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997
              Content-Type: application/x-www-form-urlencoded; charset=UTF-8
              Content-Length: 260
              Pragma: no-cache
              Cache-Control: no-cache
           Response headers
              X-Included-Test2: true
              X-Included-Test: true
              Content-Type: text/html
              Content-Length: 979
              Proxy-Connection: keep-alive
        If I run a simple Java application without SmartGWT, it takes the proxy setting including the username and password when I specify it as command line arguments.

        So where exactly should I specify the username and password to get the WSDL Databinding example to work? I have tried passing it as VM arguments, putting it in the server.properties file but it just doesnt get picked up..

        Comment


          #5
          Take a look at the article linked above - these are Java system properties, outside of the domain of SmartGWT entirely. You would set them via one of the techniques mentioned in that article. server.properties is for SmartGWT properties, so not relevant here.

          Our HttpProxyServlet does have some limited support for configuring proxies that do not require authentication, but the recommended approach is to again to set this at the Java system level, both because of your requirement for authentication and because it means that general Java usage (such as the URL class) will use your proxy settings.

          Comment

          Working...
          X