Hello all
I'll try to explain what I want to acomplish: Basically I would like to
integrate Bruno Harbulot's SPNEGO authentication filter into a simple
JAX-RS server.
I cannot use application.setGuard(...) since authentication is
implemented as a Filter instead of a Guard.
Here is the main class:
public class ExampleServer {
public static void main(String[] args) throws Exception {
// create Component (as ever for Restlet)
Component comp = new Component();
Server server = comp.getServers().add(Protocol.HTTP, 8182);
// create JAX-RS runtime environment
JaxRsApplication application = new
JaxRsApplication(comp.getContext());
// Authentication filter derived from Bruno Harbulot's code
// How can I activate this filter?
SpnegoFilter filter = new SpnegoFilter();
// attach ApplicationConfig
application.add(new ExampleAppConfig());
// Attach the application to the component and start it
comp.getDefaultHost().attach(application);
comp.start();
System.in.read();
comp.stop();
}
}
The ApplicationConfig class:
public class ExampleAppConfig extends ApplicationConfig {
public Set<Class<?>> getResourceClasses() {
Set<Class<?>> rrcs = new HashSet<Class<?>>();
rrcs.add(EasyRootResource.class);
return rrcs;
}
}
The RAX-RS Resource class:
@Path("easy")
public class EasyRootResource {
@Context
SecurityContext sc;
@GET
@Produces("text/html")
public String getHtml() {
return "<html><head></head><body>\n"
+ "This is an easy resource (as html text).\n"
+ "</body></html>";
}
}
The SPNEGO filter:
http://git.kato.mvc.mcc.ac.uk/bruno/spnegofilter.git/?a=blob_plain;f=src/main/java/uk/ac/manchester/rcs/bruno/spnegofilter/SpnegoFilter.java;hb=HEAD
Thanks,
Roman
Jerome Louvel wrote:
Hi Roman,
Could you share with us a code sample that we can look at and help you
complete?
Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
-----Message d'origine-----
De : Roman Geus [mailto:[EMAIL PROTECTED]
Envoyé : lundi 11 août 2008 17:05
À : discuss@restlet.tigris.org
Objet : Setting a Filter for a JAX-RS resource class or application
Hi all
I would like to set a Filter for a JAX-RS resource or application and I
can't seem to find out how to do it properly.
Can anybody help me with this?
Thanks,
Roman
--
Roman Geus
Paul Scherrer Institut
AIT
Scientific Computing
5232 Villigen PSI
Switzerland
Tel: +41 56 310 54 85
Fax: +41 56 310 36 49
e-Mail: [EMAIL PROTECTED]