4 Replies Latest reply on May 23, 2014 12:28 AM by Joby kj

    IP address filtering in fuse proxy web service

    Joby kj Newbie

      Hi All,

      We are using redhat fuse for creating a proxy for our actual web service .We need to get remote client IP address in fuse . For this we have add a processor in camel route ,   We are trying to extract HttpServletRequest object from Exchange object , but  getting HttpServletRequest as null . We are using  fuse ide 6.0.0 .

       

      1) Camel route

       

      <bean id="SimpleProcessor" class="com.test.SimpleProcessor"/>

         <camelContext xmlns="http://camel.apache.org/schema/spring">

             <route id="proxy">

       

               <from uri="cxf:https://localhost:9091/testProxy?serviceClass=com.test.MyService"/>

             

               <bean ref="SimpleProcessor" />

              

                <to uri="cxf:http://localhost:8080/services/myService?serviceClass=com.test.MyService"/> 

                

             

               </route>

         </camelContext>

       

      2) SimpleProcessor.java

      public class SimpleProcessor implements Processor {

         

           @Override

              public void process(Exchange exchange) {

          

             

              

                  HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);

                  if (req != null) {

                      String remoteAddr = req.getRemoteAddr();

                      int remotePort = req.getRemotePort();

                      System.out.println("Client called from " + remoteAddr + ":" + remotePort);

                   

                  } else {

                      System.out.println("Could not extract client address!");

                  }

           }

         

      Thank You