REST Api (was Re: Custom UI? )

Heiko W.Rupp hrupp at redhat.com
Mon Jun 20 14:41:48 UTC 2011


Hi,

Am 06.06.2011 um 12:21 schrieb Heiko W.Rupp:

> I sat down over the weekend (and some time this morning) to implement a first REST provider.
> This code is in git in branch heiko-rest ( http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=shortlog;h=refs/heads/heiko-rest ).

Did more weekend work (actually most on the weekend before)

Code can now return schedules and metric data.
I did play with the HibernareDetach util, but this did not work well. RESTeasy seems to do too much magic here.
Also opening a hibernate session in a filter and leaving it for RE seems not right - especially as it is not clear
to RE to what level dependent objects should be transferred over the wire - a rest client may sit at the other
end of a thin pipe.
So I ended up in creating some POJOs in org.rhq.core.domain.rest [1]. This also solves the issue about number
of callbacks, as they are more coarse grained than some of the usual domain objects ("welcome back DTO" :-)

I've also added an authentication filter to the rest servlets, so that REST calls need to be authenticated.
Unfortunately this does not yet provide authorization, as it is unclear yet on how to pass the obtained subject
into the backend.

Backend methods should have the usual foo(Subject subject, OtherParams[] ...) kind of signature and thus RESTeasy
would consider subject part of the passed data, which is not right.

One solution here could be to put the Subject on a ThreadLocal and then have an Interceptor 'inject' that into a variable
callerSubject that can then used inside the rest provider methods. As they are exposed via Local interface only, this should
be ok from the security side.
Another option could be to explicitly require a login call at the start to obtain a token and then always pass this token into
each call, but again this does not feel right.

  Heiko

[1] http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=tree;f=modules/core/domain/src/main/java/org/rhq/core/domain/rest
-- 
Reg. Adresse: Red Hat GmbH, Technopark II, Haus C, 
Werner-von-Siemens-Ring 14, D-85630 Grasbrunn
Handelsregister: Amtsgericht München HRB 153243
Geschaeftsführer: Brendan Lane, Charlie Peters, Michael Cunningham, Charles Cachera



More information about the rhq-devel mailing list