Hello Patrizio,
I notice that the guarder router add another level in the hierarchy of
the URIs, because it attaches the authenticator to the segment "/".
Router guardedRouter = new Router(getContext());
guardedRouter.attach("/", authenticator);
The consequence is that you need to intercalate a "/" in your URI
hierarchy : http://example.com//myresource.
So either the guarder router attaches the authenticator using the
"attachDefault" method, either you simply return the authenticator.
best regards,
Thierry Boileau
> Hi Jerome,
>
> thanks for the snippet.
> My error was returning the guarded router instead of the
> authenticator. That way worked in M4 outside GAE/J.
>
> Anyway I just verified that everything works fine.
>
> Do you know when M5 will be released??
>
> Thanks again.
>
> Jerome Louvel wrote:
>>
>> Hi Patrizio,
>>
>> Â
>>
>> Thierry just did a test with the latest snapshot and HTTP BASIC
>> authentication does work. Here is attached a quick code snippet that
>> he wrote based on your code sample.
>>
>> Â
>>
>> Best regards,
>> Jerome Louvel
>> --
>> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
>> <http://www.restlet.org/>
>> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>> <http://www.noelios.com/>
>>
>> Â
>>
>> Â
>>
>> Â
>>
>> Â
>>
>> *De :* Patrizio Munzi [mailto:[email protected]]
>> *Envoyé :* mardi 20 octobre 2009 09:27
>> *À :* [email protected]
>> *Objet :* Re: HTTP_BASIC authentication doesn't work in GAE
>>
>> Â
>>
>> Hi Jerome,
>>
>> did you miss my last mail..??
>> I'm having trouble attaching the authenticator with the new snapshot.
>>
>> Regards
>>
>> Patrizio Munzi wrote:
>>
>> Hi Jerome,
>>
>> I'm trying to test latest snapshot but I'm not able anymore to attach
>> an authenticator to my router.
>> Using the same snippet as before:
>> ---------------
>> public Restlet createRoot() {
>>
>> // Create a router Restlet that defines routes.
>> Router router = new Router(getContext());
>>
>> // Defines a route for the resource "list of items"
>> router.attach("/addcall", CallResource.class);
>> router.attach("/addsms", SMSResource.class);
>>
>> ChallengeAuthenticator authenticator = new
>> ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC,
>> "com.eris4.warp4.callfriends.server.restlet");
>> MapVerifier verifier = new MapVerifier();
>> verifier.getLocalSecrets().put("callFriends",
>> "callFriends".toCharArray());
>> authenticator.setVerifier(verifier);
>> authenticator.setNext(router);
>>
>> Router guardedRouter = new Router(getContext());
>> guardedRouter.attach("/", authenticator);
>>
>> return guardedRouter;
>> }
>> -------------
>>
>> I get a Resource not found from the client.
>> Has something changed on guarding mechanism..??
>>
>> Please let me know so that I can go further.
>>
>> BR
>>
>> Jerome Louvel wrote:
>>
>> Hi Patrizio,
>> Â
>> We recently moved all JAAS dependencies from Restlet Core to a JAAS
>> extension. This should solve your issue. Could you test with a recent
>> 2.0 snapshot and let us know?
>> Â
>> Best regards,
>> Jerome Louvel
>> --
>> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
>> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>> Â
>> Â
>> Patrizio Munzi a écrit :
>> Â
>>
>> Ok, thank you.
>>
>> Â
>>
>> Thierry Boileau wrote:
>>
>> Â Â Â
>>
>> Hello Patrizio,
>>
>> Â
>>
>> I've entered a new issue for this problem :
>>
>> http://restlet.tigris.org/issues/show_bug.cgi?id=893.
>>
>> Thanks for your report.
>>
>> Â
>>
>> Best regards,
>>
>> Thierry Boileau
>>
>> Â
>>
>> Â
>>
>> Â Â Â Â Â Â
>>
>> Hi everybody,
>>
>> Â
>>
>> I think I've found a problem of Restlet Authentication mechanism
>> with GAE.
>>
>> Â
>>
>> I have got this simple guard:
>>
>> --------------------------
>>
>> Â Â Â public Restlet createRoot() {
>>
>> Â Â Â Â Â Â Â Â // Create a router Restlet that defines routes.
>>
>> Â Â Â Â Â Â Â Â Router router = new Router(getContext());
>>
>> Â
>>
>> Â Â Â Â Â Â Â // Defines a route for the resource "list of
>> items"
>>
>> Â Â Â Â Â Â Â Â router.attach("/addcall", CallResource.class);
>>
>> Â Â Â Â Â Â Â Â router.attach("/addsms", SMSResource.class);
>>
>> Â
>>
>> Â Â Â Â Â Â Â ChallengeAuthenticator authenticator = new
>>
>> ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC,
>>
>> "com.eris4.warp4.callfriends.server.restlet");
>>
>> Â Â Â Â Â Â Â MapVerifier verifier = new MapVerifier();
>>
>> Â Â Â Â Â Â Â verifier.getSecrets().put("callFriends",
>>
>> "callFriends".toCharArray());
>>
>> Â Â Â Â Â Â Â authenticator.setVerifier(verifier);
>>
>> Â Â Â Â Â Â Â authenticator.setNext(router);
>>
>> Â Â Â Â Â Â
>>
>> Â Â Â Â Â Â Â Â Router guardedRouter = new Router(getContext());
>>
>> Â Â Â Â Â Â Â guardedRouter.attach("/", authenticator);
>>
>> Â Â Â Â Â Â
>>
>> Â Â Â Â Â Â Â Â return guardedRouter;
>>
>> Â Â Â }
>>
>> --------------------------
>>
>> Â
>>
>> and this simple client:
>>
>> --------------------------
>>
>> Â Â Â public static void main(String[] args) throws
>> ResourceException {
>>
>> Â Â Â Â Â Â Â //Â Â Â Â Â Â Â Client client = new Client(new
>> Context(),
>>
>> Protocol.HTTP);
>>
>> Â Â Â Â Â Â Â Â //Â Â Â Â Â Â Â
>> client.getContext().getParameters().add("converter",Â
>>
>> "com.noelios.restlet.http.HttpClientConverter");
>>
>> Â
>>
>> Â Â Â Â Â Â Â
>> Engine.getInstance().getRegisteredClients().add(new
>>
>> HttpClientHelper(null));
>>
>> Â Â Â Â Â Â Â Client client = new Client(Protocol.HTTP);
>>
>> Â Â Â Â Â Â Â Status resultStatus = null;
>>
>> Â Â Â Â Â Â Â try {
>>
>> Â Â Â Â Â Â Â Â Â Â Â Form form = new Form();
>>
>> Â Â Â Â Â Â Â Â Â Â Â Â form.add("param1", "1");
>>
>> Â Â Â Â Â Â Â Â Â Â Â Representation callRepresentation =
>> form.getWebRepresentation();
>>
>> Â
>>
>> Â Â Â Â Â Â Â Â Â Â Â Request request = new
>> Request(Method.POST, url);
>>
>> Â Â Â Â Â Â Â Â Â Â Â ChallengeResponse authentication = new
>>
>> ChallengeResponse(ChallengeScheme.HTTP_BASIC, "login", "psw");
>>
>> Â Â Â Â Â Â Â Â Â Â Â
>> request.setChallengeResponse(authentication);
>>
>> Â
>>
>> Â Â Â Â Â Â Â Â Â Â Â request.setEntity(callRepresentation);
>>
>> Â Â Â Â Â Â Â Â Â Â Â Response response =
>> client.handle(request);
>>
>> Â Â Â Â Â Â Â Â Â Â Â resultStatus = response.getStatus();
>>
>> Â Â Â Â Â Â Â } catch (Throwable t) {
>>
>> Â Â Â Â Â Â Â Â Â Â Â System.err.println("Exception: " + t);
>>
>> Â Â Â Â Â Â Â }Â Â Â Â Â Â
>>
>> Â Â Â }
>>
>> --------------------------
>>
>> Â
>>
>> and GAE side I get the following exception:
>>
>> --------------------------
>>
>> SEVERE: Unhandled exception or error intercepted
>>
>> java.security.AccessControlException: access denied
>>
>> (javax.security.auth.AuthPermission modifyPrincipals)
>>
>> Â Â Â at
>> java.security.AccessControlContext.checkPermission(Unknown Source)
>>
>> Â Â Â at java.security.AccessController.checkPermission(Unknown
>> Source)
>>
>> Â Â Â at java.lang.SecurityManager.checkPermission(Unknown
>> Source)
>>
>> Â Â Â at
>>
>>
>> com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:139)
>>
>> Â Â Â at javax.security.auth.Subject$SecureSet.add(Unknown
>> Source)
>>
>> Â Â Â at
>> java.util.Collections$SynchronizedCollection.add(Unknown Source)
>>
>> Â Â Â at
>> org.restlet.security.SecretVerifier.verify(SecretVerifier.java:114)
>>
>> Â Â Â at
>>
>>
>> org.restlet.security.ChallengeAuthenticator.authenticate(ChallengeAuthenticator.java:134)
>>
>> Â Â Â at
>>
>>
>> org.restlet.security.Authenticator.beforeHandle(Authenticator.java:107)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:199)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at org.restlet.routing.Router.doHandle(Router.java:321)
>>
>> Â Â Â at org.restlet.routing.Router.handle(Router.java:520)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at
>>
>>
>> org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:152)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at
>> org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
>>
>> Â Â Â at
>>
>>
>> org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72)
>>
>> Â Â Â at org.restlet.Application.handle(Application.java:344)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at org.restlet.routing.Router.doHandle(Router.java:321)
>>
>> Â Â Â at org.restlet.routing.Router.handle(Router.java:520)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at org.restlet.routing.Router.doHandle(Router.java:321)
>>
>> Â Â Â at org.restlet.routing.Router.handle(Router.java:520)
>>
>> Â Â Â at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>
>> Â Â Â at org.restlet.routing.Filter.handle(Filter.java:201)
>>
>> Â Â Â at
>> org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
>>
>> Â Â Â at org.restlet.Component.handle(Component.java:403)
>>
>> Â Â Â at org.restlet.Server.handle(Server.java:350)
>>
>> Â Â Â at
>> org.restlet.engine.ServerHelper.handle(ServerHelper.java:71)
>>
>> Â Â Â at
>>
>>
>> org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:149)
>>
>> Â Â Â at
>> org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:967)
>>
>> Â Â Â at
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
>>
>> Â Â Â at
>>
>>
>> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>>
>> Â Â Â at
>>
>>
>> com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:121)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>>
>> Â Â Â at
>> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
>>
>> Â Â Â at
>>
>>
>> com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>
>> Â Â Â at
>>
>>
>> com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:313)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>
>> Â Â Â at org.mortbay.jetty.Server.handle(Server.java:313)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
>>
>> Â Â Â at
>> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
>>
>> Â Â Â at
>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
>>
>> Â Â Â at
>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
>>
>> Â Â Â at
>>
>>
>> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
>>
>> -----------------------
>>
>> Â
>>
>> has anybody any idea on how I can work around this???
>>
>> Is it a bug??
>>
>> Â
>>
>> Thanks
>>
>> Â
>>
>> ------------------------------------------------------
>>
>>
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2392516
>>
>> <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2392516>
>>
>> Â
>>
>> Â
>>
>> Â Â Â
>>
>> Â Â Â Â Â Â Â Â
>>
>> ------------------------------------------------------
>>
>>
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2393621
>>
>> <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2393621>
>>
>> Â
>>
>> Â
>>
>> Â Â Â Â Â Â
>>
>> --
>>
>> Â
>>
>> *Patrizio Munzi*
>>
>> Product Specialist
>>
>> Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
>>
>> tel: +39 06 4543 3540
>>
>> fax: +39 06 4543 3587
>>
>> mobile: +39 393 7195 164
>>
>> mail: [email protected] <mailto:[email protected]>
>> <mailto:[email protected]>
>>
>> web: http://www.eris4.com <http://www.eris4.com/>
>>
>> skype: eris4_munzi <skype:eris4_munzi?add>
>>
>> Â
>>
>> Â Â Â
>>
>> Â
>> ------------------------------------------------------
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2407600
>>
>> <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2407600>
>> Â
>> Â
>>
>> Â
>>
>> --
>>
>> *Patrizio Munzi*
>> Product Specialist
>> Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
>> tel: +39 06 4543 3540
>> fax: +39 06 4543 3587
>> mobile: +39 393 7195 164
>> mail: [email protected] <mailto:[email protected]>
>> web: http://www.eris4.com <http://www.eris4.com/>
>> skype: eris4_munzi <skype:eris4_munzi?add>
>>
>> Â
>>
>> --
>>
>> *Patrizio Munzi*
>> Product Specialist
>> Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
>> tel: +39 06 4543 3540
>> fax: +39 06 4543 3587
>> mobile: +39 393 7195 164
>> mail: [email protected] <mailto:[email protected]>
>> web: http://www.eris4.com <http://www.eris4.com/>
>> skype: eris4_munzi <skype:eris4_munzi?add>
>>
>
> --
>
> *Patrizio Munzi*
> Product Specialist
> Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
> tel: +39 06 4543 3540
> fax: +39 06 4543 3587
> mobile: +39 393 7195 164
> mail: [email protected] <mailto:[email protected]>
> web: http://www.eris4.com <http://www.eris4.com/>
> skype: eris4_munzi <skype:eris4_munzi?add>
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2410099