[question]How do I access the http request from within a XMLRPC::WEBrickServlet?

I've been working with xmlrpc4r and webrick recently, and things have gone
swimmingly for the most part. I'm able to to communicate back and forth over
ssl, authenticating with client and server ssl certificates signed by our CA.
But, what I need next is some way for the server to know which client is
attached to it.

I was hoping that I could get down to the cert from within the
XMLRPC::WEBrickServlet handlers, but I'm not having much luck? Any info about
how to dig down the request from within the handler would be great. If anyone
has any suggestions on how better to do this, I'd be all ears. But I do need
the server to be deciding who's connected to it, not the client telling the
server who it is.

Thanks!

-jason

Here's how I get at the request and response objects in xmlrpc4r.

···

On Nov 11, 2005, at 2:32 PM, jro@codegrinder.com wrote:

I've been working with xmlrpc4r and webrick recently, and things have gone
swimmingly for the most part. I'm able to to communicate back and forth over
ssl, authenticating with client and server ssl certificates signed by our CA.
But, what I need next is some way for the server to know which client is
attached to it.

I was hoping that I could get down to the cert from within the
XMLRPC::WEBrickServlet handlers, but I'm not having much luck? Any info about
how to dig down the request from within the handler would be great. If anyone
has any suggestions on how better to do this, I'd be all ears. But I do need
the server to be deciding who's connected to it, not the client telling the
server who it is.

---
class MyServlet < XMLRPC::WEBrickServlet
   def service(request, response)
     # do whatever I want with the request
     super
     # do whatever I want with the response
   end
end
---

The call to #super will invoke whatever handlers you've added to your servlet. Its not quite what you're looking for, but hopefully its a start. Maybe you could put the relevant certificate information in an instance variable from #service and then revisit it in your handler?

HTH,
--
~akk

Thanks for the tip, it has put me one step closer to my goal. I can gather
info about the certificate in the service method, but I haven't figured out
how to pass it into the handler..

class MyServlet < XMLRPC::WEBrickServlet
    def service(request, response)
        @client_cert_subject=request.client_cert.subject
        puts client_cert_subject # this works
        super
    end
end

servlet = MyServlet.new

something = SomeObject.new

servlet.add_handler("something.do_something") do
    puts @client_cert_summary # this prints "nil"
    something.do_something
end

And also if I "puts self.inspect" inside the add_handler block, I get "main".
Which wasn't quite what I expected.

-jason

···

On Sun, Nov 13, 2005 at 06:39:17AM +0900, Adam Keys wrote:

Here's how I get at the request and response objects in xmlrpc4r.

---
class MyServlet < XMLRPC::WEBrickServlet
  def service(request, response)
    # do whatever I want with the request
    super
    # do whatever I want with the response
  end
end
---

The call to #super will invoke whatever handlers you've added to your
servlet. Its not quite what you're looking for, but hopefully its a
start. Maybe you could put the relevant certificate information in
an instance variable from #service and then revisit it in your handler?