The problem is that the request parameter 'answer' is coming back null. I'm not sure why this would happen. When the comment page is created, the authenticator should be called to provide the authentication portion of the comment form. It will add an input field like this:
<input name='answer' value=''></input> The user enters the math answer into that field and the form POST operation sends the field to the server. Something must be interfering with that in your Roller install. - Dave On Sun, Dec 20, 2009 at 4:59 PM, Rocco Scappatura <rocco.scappat...@infracom.it> wrote: > Hello, > > On Gio, 17 Dicembre 2009 16:30, Rocco Scappatura wrote: >> On Gio, 17 Dicembre 2009 4:44, Dave wrote: >>> On Tue, Dec 15, 2009 at 5:04 AM, Rocco Scappatura >>> <rocco.scappat...@infracom.it> wrote: >>>> On Sab, 12 Dicembre 2009 4:27, Dave wrote: >>>>> Part of the problem is that the math authenticator does not include >>>>> debug statements: >>>>> >>>>> http://bit.ly/5x31Qv >>>>> >>>>> One option would be for you to create your own new math authenticator >>>>> based on that code, but with a different name/package. You could add >>>>> debug code into your authenticator, compile it (against the Roller >>>>> jars), plug it into Roller via roller-custom.properties and then get >>>>> some useful output. >>>> >>>> I'm not expert java programmer.. :-( Neverthless I never downloaded >>>> source >>>> version of roller 3.1 before today.. So I ask you to please address >>>> me.. >>>> >>>> What I have to put into de code to enable debug for the class >>>> MathCommentAuthenticator? >>> >>> I would recommend copying that MathCommentAuthenticator code that I >>> referenced into a new Java class in a different package, for example >>> "org.rocco" >>> >>> There is a logger in the MathCommentAuthenticator now, so to add debug >>> logging you'll need this: >>> >>> mLogger.debug("I just did thing A"); >>> // ... >>> mLogger.debug("I just did thing B " + x + "times, how about >>> that!?!"); >>> >>> >>>> How I have to compile the java package? I suppose then I have to put >>>> some >>>> resulting .jar and to copy it in <roller>\WEB-INF\lib dir and restart >>>> the >>>> application.. Right? >>> >>> Since the MathCommentAuthenticator uses Commons Logging, Servlet API >>> and Roller web stuff you will need to compile with these jars on your >>> classpath: >>> >>> commons-logging.jar >>> servlet.jar (from your app server perhaps?) >>> roller-web.jar >>> >>> Then put the resulting classes in a jar file, put that jar file in >>> WEB-INF/lib and add the following to your roller-custom.properties >>> file so that Roller will use your new authenticator: >>> >>> authenticator.classname=org.rocco.MathCommentAuthenticator >>> >>> Hope that helps... >> >> Yes it is! I put some debug calls in authenticate method of class >> 'org.rocsca.MathCommentAuthenticator' (jarred into rocsca.jar and put into >> lib dir of roller webapp). >> >> More specifically: >> >> public boolean authenticate(HttpServletRequest request) { >> >> boolean authentic = false; >> >> HttpSession session = request.getSession(false); >> String answerString = request.getParameter("answer"); >> >> mLogger.debug("La risposta data e':" + answerString); >> >> if (answerString != null && session != null) { >> try { >> int answer = Integer.parseInt(answerString); >> >> Integer sum = (Integer) >> session.getAttribute("mathAnswer"); >> mLogger.debug("La risposta e':" + sum); >> >> if (sum != null && answer == sum.intValue()) { >> authentic = true; >> >> After this, answering to a math question on my blog I get the log entry: >> >> DEBUG 2009-12-17 16:19:21,322 CommentServlet:doPost - Doing comment >> posting for entry = /blog/entry/preambolo_a_questa_categoria >> DEBUG 2009-12-17 16:19:21,322 MathCommentAuthenticator:authenticate - La >> risposta data e':24 >> DEBUG 2009-12-17 16:19:21,322 MathCommentAuthenticator:authenticate - La >> risposta e':null >> >> so the problem is that 'mathAnswer' is null. While it have to be the sum >> of the two random values generated some step before and propagated. >> >> It sounds like the session is not preserved. >> >> Indeed I often lost session also when I act from the admin side of roller. >> >> Do you any idea of what the cause could be? > > Any idea on how I could go on? > > Thanks, > > rocsca > >