captcha in the clouds

69 views
Skip to first unread message

7uc0

unread,
Mar 2, 2010, 10:03:49 AM3/2/10
to play-framework
Salut les filles, et bravo pour ce projet !

I'm posting to report a incompatibility regarding the captcha helper
and gae runtime restricted environement.
The use of awt.Color (maybe the whole awt package) is prohibido.

I haven't checked the source code yet for investigation, but I noticed
the play-imaging and play-simpleCaptcha framework libs pkg, but the
exception is thrown with core play.libs.Captcha class Could one of you
messieurs confirm me the use of those libs regarding the core Captcha
utility class ?

Thx

Stack dump, fyi

play.exceptions.JavaExecutionException: java.awt.Color is a restricted
class. Please see the Google App Engine developer's guide for more
details.
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at play.server.ServletWrapper
$ServletInvocation.execute(ServletWrapper.java:405)
at play.Invoker$Invocation.run(Invoker.java:176)
at play.server.ServletWrapper
$ServletInvocation.run(ServletWrapper.java:396)
at play.Invoker.invokeInThread(Invoker.java:59)
at play.server.ServletWrapper.service(ServletWrapper.java:87)
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.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:
97)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1084)
at
com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:
35)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1084)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
43)
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.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:
238)
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.headerComplete(HttpConnection.java:830)
at
com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:
76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
at
com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:
135)
at
com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:
235)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime
$6.handleBlockingRequest(RuntimePb.java:5485)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime
$6.handleBlockingRequest(RuntimePb.java:5483)
at
com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:
24)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:
363)
at com.google.net.rpc.impl.Server$2.run(Server.java:837)
at
com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:
56)
at
com.google.tracing.LocalTraceSpanBuilder.internalContinueSpan(LocalTraceSpanBuilder.java:
536)
at com.google.net.rpc.impl.Server.startRpc(Server.java:792)
at com.google.net.rpc.impl.Server.processRequest(Server.java:367)
at
com.google.net.rpc.impl.ServerConnection.messageReceived(ServerConnection.java:
448)
at
com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:
319)
at
com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:
290)
at com.google.net.async.Connection.handleReadEvent(Connection.java:
474)
at
com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:
774)
at
com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:
205)
at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:
101)
at
com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:
251)
at com.google.apphosting.runtime.JavaRuntime
$RpcRunnable.run(JavaRuntime.java:394)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: java.awt.Color is a
restricted class. Please see the Google App Engine developer's guide
for more details.
at java.awt.Color.<clinit>(Color.java)
at play.libs.Images$Captcha.<init>(Images.java:167)
at play.libs.Images.captcha(Images.java:149)
at play.libs.Images.captcha(Images.java:156)
at controllers.Application.captcha(Application.java:83)
at play.utils.Java.invokeStatic(Java.java:129)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:138

Guillaume Bort

unread,
Mar 2, 2010, 10:23:20 AM3/2/10
to play-fr...@googlegroups.com
Yes the play.libs.Images.captcha function is a wrapper around simpleCaptcha.

It will not work on GAE since the java.awt API is restricted. Perhaps
you should look at something like http://recaptcha.net/, or trying to
generate the captcha image using the Google Image Manipulation APIs
availables on app engine.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

7uc0

unread,
Mar 2, 2010, 2:09:19 PM3/2/10
to play-framework
it could then be integrated within gae module, I'll check this out.
Thanks Guillaume, et au plaisir

-E.

On 2 mar, 16:23, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> Yes the play.libs.Images.captcha function is a wrapper around simpleCaptcha.
>
> It will not work on GAE since the java.awt API is restricted. Perhaps

> you should look at something likehttp://recaptcha.net/, or trying to


> generate the captcha image using the Google Image Manipulation APIs

Bendanpa

unread,
Apr 28, 2010, 8:28:00 PM4/28/10
to play-framework
any updates on this?

I am also looking for a sulotion.

Thanks,
Bendanpa

On Mar 2, 12:09 pm, 7uc0 <erwan.legoul...@gmail.com> wrote:
> it could then be integrated within gae module, I'll check this out.
> Thanks Guillaume, et au plaisir
>
> -E.
>
> On 2 mar, 16:23, Guillaume Bort <guillaume.b...@gmail.com> wrote:
>
> > Yes the play.libs.Images.captchafunction is a wrapper around simpleCaptcha.
>
> > It will not work on GAE since the java.awt API is restricted. Perhaps
> > you should look at something likehttp://recaptcha.net/, or trying to
> > generate thecaptchaimage using the Google Image Manipulation APIs
> > availables on app engine.On Tue, Mar 2, 2010 at 4:03 PM, 7uc0 <erwan.legoul...@gmail.com> wrote:
> > > Salut les filles, et bravo pour ce projet !
>
> > > I'm posting to report a incompatibility regarding thecaptchahelper
> > > and gae runtime restricted environement.
> > > The use of awt.Color (maybe the whole awt package) is prohibido.
>
> > > I haven't checked the source code yet for investigation, but I noticed
> > > the  play-imaging and play-simpleCaptcha framework libs pkg, but the
> > > exception is thrown with core play.libs.Captchaclass Could one of you

Guillaume Bort

unread,
Apr 29, 2010, 8:17:11 AM4/29/10
to play-fr...@googlegroups.com
Perhaps you can use something like http://recaptcha.net/

Bendanpa

unread,
Apr 29, 2010, 12:23:46 PM4/29/10
to play-framework
Thanks. I'll try reCaptcha out. If I get it work I would love to make
it a play module.

Bendanpa

On Apr 29, 5:17 am, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> Perhaps you can use something likehttp://recaptcha.net/
Message has been deleted

Bendanpa

unread,
Apr 30, 2010, 9:54:40 PM4/30/10
to play-framework
Hi Guillaume,

I made the reCaptcha on GAE. It is pretty easy. I post what I did
here:

1. sign up reCaptcha from http://recaptcha.net/ to get the public and
private keys for your site

2. download the jar file form http://code.google.com/p/recaptcha/downloads/list?q=label:java-Latest
and put it in your-project/lib folder

2a. these are the necessary imports:

import net.tanesha.recaptcha.ReCaptcha;
import net.tanesha.recaptcha.ReCaptchaFactory;

import net.tanesha.recaptcha.ReCaptchaImpl;
import net.tanesha.recaptcha.ReCaptchaResponse;

3. the action register()

// for imports see step 2a

public static void register() {
render(ReCaptchaFactory.newReCaptcha("your_public_key",
"your_private_key", false).createRecaptchaHtml(null, null));
}

4. in the register form template

#{form @save()}
your-other-form-stuff

<p>
&{captcha}
<br />
<input type="submit" value="Register" />
</p>
#{/form}

5. in the action save() insert following code to verify user input
(for imports see step 2a)

// other code
ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
reCaptcha.setPrivateKey("your_private_key");

String challenge = params.get("recaptcha_challenge_field");
String uresponse = params.get("recaptcha_response_field");

ReCaptchaResponse reCaptchaResponse =
reCaptcha.checkAnswer("127.0.0.1", challenge, uresponse);

if (reCaptchaResponse.isValid()) {
System.out.println("Answer was entered correctly!");
} else {
System.out.println("Answer is wrong");
render("Application/register.html");
}

// more other code here

I tested and it works on GAE. The only one question I have is the
first arg for method reCaptcha.checkAnswer(), it is an address (server
site address?) of a "remoteAddr", I don't know what it should be, I
just put the "127.0.0.1" and it just works.

I don't know if Istill need to make it a module (I don't know how to
make a module yet). What do you think?

Regards,
Bendanpa

On Apr 29, 5:17 am, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> Perhaps you can use something likehttp://recaptcha.net/

orefalo

unread,
May 1, 2010, 6:46:23 PM5/1/10
to play-framework
I would vote to make it a module. -> I was actually thinking about it.

Keep flexibility in mind, some projects may want to use the captcha in
a popup using ajax, some others no.

Olivier

On Apr 30, 9:54 pm, Bendanpa <benda...@gmail.com> wrote:
> Hi Guillaume,
>
> I made the reCaptcha on GAE. It is pretty easy.  I post what I did
> here:
>
> 1. sign up reCaptcha fromhttp://recaptcha.net/ to get the public and
> private keys for your site
>
> 2. download the jar file formhttp://code.google.com/p/recaptcha/downloads/list?q=label:java-Latest
Reply all
Reply to author
Forward
0 new messages