GuardedExample without using deprecated API
Hy everybody I was using CXF and change to Restlet because security looks to be easier to implement. I am using JAX-RS and I hopefully found an example with security in the source code: org.restlet.example.ext.jaxrs.GuardedExample I had some difficulties to make it work : We need to call ChallengeAuthenticator after creating the Verifier. // set valid users and their passwords. MemoryRealm realm = new MemoryRealm(); application.getContext().setDefaultEnroler(realm.getEnroler()); application.getContext().setDefaultVerifier(realm.getVerifier()); realm.getUsers().add(new User(admin, adminPW.toCharArray())); realm.getUsers().add(new User(alice, alicesSecret.toCharArray())); realm.getUsers().add(new User(bob, bobsSecret.toCharArray())); // create a Guard final ChallengeAuthenticator guard = new ChallengeAuthenticator( application.getContext(), ChallengeScheme.HTTP_BASIC, JAX-RS example); Because the ChallengeAuthenticator constructor use the vertifier in the context : public ChallengeAuthenticator(Context context, boolean optional, ChallengeScheme challengeScheme, String realm) { this(context, optional, challengeScheme, realm, (context != null) ? context.getDefaultVerifier() : null); } Now it is working but I am wondering about the RoleChecker. My RoleChecker is like this : /** * Class needed for BASIC AUTH. */ @SuppressWarnings(deprecation) private static final class RestletRoleChecker implements RoleChecker { public boolean isInRole(Principal principal, String role) { throw new RuntimeException([isInRole] was called. We don't know why this class is needed.); } } And it is working with HTTP Basic Auth very well. Because security is important, I am wondering why I need to call : application.setAuthentication(guard, roleChecker); //with an unused RestletRoleChecker and why : application.setGuard(guard); //not deprecated doesn't work instead. Because application.setAuthentication is deprecated, how can I use ClientInfo.getRoles() instead ? The only way I found to access ClientInfo is in Resource, and I would like to set the BasicAuth for every Resources. Thank you Romain -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=246
How to signup a ChallengeAuthenticator when using SpringBeanRouter
I have a working app with restlet 2.0 and Server resources configured through SpringBeanRouter ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:util=http://www.springframework.org/schema/util; xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd; bean name=component id=component class=org.restlet.ext.spring.SpringComponent property name=clientsList list valueHTTP/value valueHTTPS/value /list /property property name=hosts list ref bean=virtualHost / /list /property /bean bean id=virtualHost class=org.restlet.ext.spring.SpringHost constructor-arg ref=component / property name=attachments map entry key=/ws value-ref=router / /map /property /bean bean name=router class=org.restlet.ext.spring.SpringBeanRouter/ /beans Sample Restlet Server Resource: @Component( /data/Contact/{userId} ) @Scope( value = prototype ) public class ContactData extends BaseServerResource { } I'd like to add a default ChallengeAuthenticator (ChallengeScheme.HTTP_BASIC) and I understand how to do this programmatically if I were using straight Restlet (without spring) but not sure how to setup a filter to a SpringBeanRouter Two references I've seen so far doesn't discuss these details: http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/46-restlet/112-restlet.html http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/70-restlet/196-restlet.html Any help, appreciated -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/How-to-signup-a-ChallengeAuthenticator-when-using-SpringBeanRouter-tp5588475p5588475.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=256
RE: Runtime issue with Restlet 2.0-SNAPSHOT
Hi there, You are probably mixing JARs from different versions in your classpath. You need to make sure that the org.restlet.jar and all extension JARs you are using are coming from the same distribution/version. Best regards, Jerome -- Restlet ~ Founder and Technical Lead ~ http://www.restlet.org Noelios Technologies ~ http://www.noelios.com -Message d'origine- De : webp...@tigris.org [mailto:webp...@tigris.org] Envoyé : mercredi 29 septembre 2010 12:33 À : discuss@restlet.tigris.org Objet : Runtime issue with Restlet 2.0-SNAPSHOT Hi, I am using Restlet 2.0-SNAPSHOT version with jaxrs extension. But at runtime, I am getting error: java.lang.NoClassDefFoundError: org.restlet.util.Helper I see that this class is in restlet 1.1.10 verion. Am I missing anything in my dependency list? I also tried to search same class in all the jars I got when downloading 2.0 version, but didn't find this class in any of those jars. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2666085 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=285
Exception in Applet running in Eclipse
Hello, I am getting the following exception when I try to run my applet with a Restlet client. Sep 30, 2010 2:53:41 PM org.restlet.engine.http.connector.HttpClientHelper start INFO: Starting the default HTTP client Sep 30, 2010 2:53:42 PM org.restlet.resource.ClientResource handle INFO: A recoverable error was detected (1001), attempting again in 2000 ms. Sep 30, 2010 2:53:45 PM org.restlet.resource.ClientResource handle INFO: A recoverable error was detected (1001), attempting again in 2000 ms. Communication Error (1001) - Connection refused: connect at org.restlet.resource.ClientResource.handle(ClientResource.java:854) at org.restlet.resource.ClientResource.handle(ClientResource.java:759) at org.restlet.resource.ClientResource.get(ClientResource.java:492) at com.enabletv.applet.VideoProcessingApplet.init(VideoProcessingApplet.java:427) at sun.applet.AppletPanel.run(AppletPanel.java:424) at java.lang.Thread.run(Thread.java:619) 1. I don't get this when I access my server Application outside of an applet hosted in Eclipse. I altered the org.restlet.example.tutorial.Part02a.java from the tutorials section and it successfully connects to my server. 2. I have seen http://wiki.restlet.org/docs_2.0/13-restlet/333-restlet/338-restlet.html and have followed the guidance there to no avail. 3. I can build my applet outside of Eclipse and run it in a browser with or without the solution in 2. 4. config notes: - Restlet 2.01 - only jar file referenced is org.restlet.jar What else I should try? I'm not sure how much additional information is needed, but I don't think I'm doing anything crazy and someone else must have this issue. Thanks, Darin -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2666702