You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by helander <le...@gmail.com> on 2012/08/06 22:34:54 UTC

HttpServletRequest associated with CXF endpoint

Is it possible to retrieve the HttpServletRequest "associated" with exchanges
on a CXF Endpoint?

I would like to access the client certificate associated with an HTTPS
request using:

        request.getAttribute("javax.servlet.request.X509Certificate")


Now, I do this using the following procedure, but it's somewhat inefficient
and based on exploring the current run-time (i.e. if core implementation
changes, the solution may no longer work) .

      SoapMessage camelcxfmsg = (SoapMessage)
exchange.getIn().getHeaders().get("camelcxfmessage");
      TLSSessionInfo si = null;
      Set<Entry&lt;String,Object>> es = camelcxfmsg.entrySet();
      for (Entry<String,Object> e : es) {
    	  if
(e.getKey().equals("org.apache.cxf.security.transport.TLSSessionInfo")) {
    	    si = (TLSSessionInfo) e.getValue();
    	    break;
    	  }
      }            

      Certificate[]  certs = null;
      if (si != null) certs =  si.getPeerCertificates();
      

Thanks


Lars
 



--
View this message in context: http://camel.465427.n5.nabble.com/HttpServletRequest-associated-with-CXF-endpoint-tp5716897.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HttpServletRequest associated with CXF endpoint

Posted by Willem Jiang <wi...@gmail.com>.
Yeah, you could any CXF message context by looking up the CXF message
from the Camel message header.

On Tue, Aug 7, 2012 at 8:50 AM, helander <le...@gmail.com> wrote:
> Thanks,
>
> I got it to work:
>
>
> Message cxfMessage =
> exchange.getIn().getHeader(CxfConstants.CAMEL_CXF_MESSAGE, Message.class);
> HttpServletRequest request =
> (HttpServletRequest)cxfMessage.get("HTTP.REQUEST");
> X509Certificate[]  certs =  (X509Certificate[])
> request.getAttribute("javax.servlet.request.X509Certificate");
>
>
> /Lars
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HttpServletRequest-associated-with-CXF-endpoint-tp5716897p5716901.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HttpServletRequest associated with CXF endpoint

Posted by helander <le...@gmail.com>.
Thanks,

I got it to work:


Message cxfMessage =
exchange.getIn().getHeader(CxfConstants.CAMEL_CXF_MESSAGE, Message.class);
HttpServletRequest request =
(HttpServletRequest)cxfMessage.get("HTTP.REQUEST");
X509Certificate[]  certs =  (X509Certificate[])
request.getAttribute("javax.servlet.request.X509Certificate");


/Lars



--
View this message in context: http://camel.465427.n5.nabble.com/HttpServletRequest-associated-with-CXF-endpoint-tp5716897p5716901.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HttpServletRequest associated with CXF endpoint

Posted by "michal.warecki" <mi...@gmail.com>.
Maybe try something like this:

org.apache.cxf.message.Message cxfMessage =
camelMessage.getHeader(CxfConstant.CAMEL_CXF_MESSAGE,
org.apache.cxf.message.Message.class);
ServletRequest request = (ServletRequest)cxfMessage.get("HTTP.REQUEST"); 



--
View this message in context: http://camel.465427.n5.nabble.com/HttpServletRequest-associated-with-CXF-endpoint-tp5716897p5716898.html
Sent from the Camel - Users mailing list archive at Nabble.com.