Hello! On Mer, 13 Gennaio 2010 4:55, Dave wrote: > I do not think your theme modifications could interfere with the > comment authenticator. > > The problem seems to be that mathAnswer is not being store in the > session or is somehow being erased. I don't have any idea why this > would be happening. > > - Dave
I have solved so: 1) Putting and hide input field in comment form: sb.append("<input type=hidden name=\"mathAnswer\" value=\""); sb.append(mathAnswer); sb.append("\" />"); 2) I have modified the authenticate method considering the request parameter "mathAnswer" and no more the attribute session "mathAnswer". So the condition to authenticate the user submitted answer is: if (mathAnswerString != null && answer == Integer.parseInt(mathAnswerString)) { authentic = true; session.removeAttribute("mathAnswer"); session.removeAttribute("mathValue1"); session.removeAttribute("mathValue2"); } Indeed I think that there is no needing to reset sessions attribute, as (it seems to me that the real problem is that authenticate method won't get information about the HTTP session.. - Could someone can figure out why this happen? ). One more question. Im not a real java programmer.. So I can figure out why I get: ERROR 2010-01-13 12:13:45,400 RollerContext:getAuthenticator - ERROR creating authenticator, using default java.lang.ClassCastException: org.rocsca.MathCommentAuthenticator cannot be cast to org.apache.roller.ui.core.Authenticator at org.apache.roller.ui.core.RollerContext.getAuthenticator(RollerContext.java:417) at org.apache.roller.ui.core.RollerRequest.init(RollerRequest.java:139) at org.apache.roller.ui.core.RollerRequest.<init>(RollerRequest.java:109) at org.apache.roller.ui.core.RollerRequest.getRollerRequest(RollerRequest.java:397) . . . Once I act on a submitted comment from roller backend. Thanks in advance, rocsca > On Wed, Jan 6, 2010 at 5:27 PM, Rocco Scappatura > <rocco.scappat...@infracom.it> wrote: >> Hello Dave, >> >> First of all, sorry for the delay. >> >> On Gio, 24 Dicembre 2009 16:30, Dave wrote: >>> 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. >> >> I have refined the verbosity of 'patched' version of the authenticator. >> >> I saw that indeed is the HTML parameter that comes 'null' during the >> 'authenticate' stage: >> >> 1) The method 'getHtml' is invoked when the comment page is loaded: >> >> DEBUG 2010-01-06 22:58:25,150 MathCommentAuthenticator:getHtml - The >> HTML >> attribute 'mathAnswer' is null >> DEBUG 2010-01-06 22:58:25,150 MathCommentAuthenticator:getHtml - The >> HTML >> attribute 'mathAnswer' is set to:2+42 >> DEBUG 2010-01-06 22:58:25,150 MathCommentAuthenticator:getHtml - That is >> to:44 >> >> 2) The 'Post' button is clicked, after inserting the valule '44' in the >> text box answer: >> DEBUG 2010-01-06 23:00:07,947 CommentServlet:doPost - Doing comment >> posting for entry = /blog/entry/preambolo_a_questa_categoria >> >> 3) the 'authenticate' method is invoked and the value of 'answer' HTML >> attribute is correctly reported, while the 'mathAnswer' HTML attribute >> not >> (it is null because, it is not posted after sumission othe filled form): >> DEBUG 2010-01-06 23:00:07,947 MathCommentAuthenticator:authenticate - >> The >> value of HTML attribute 'answer' is :44 >> DEBUG 2010-01-06 23:00:07,947 MathCommentAuthenticator:authenticate - >> The >> value of HTML attribute 'mathAnswer' is null >> DEBUG 2010-01-06 23:00:07,947 CommentServlet:doPost - Comment failed >> authentication >> >> 4) The method 'getHtml' is invoked again to generate nue random values: >> DEBUG 2010-01-06 23:00:09,369 MathCommentAuthenticator:getHtml - The >> HTML >> attribute 'mathAnswer' is null >> DEBUG 2010-01-06 23:00:09,369 MathCommentAuthenticator:getHtml - The >> HTML >> attribute 'mathAnswer' is set to:5+27 >> DEBUG 2010-01-06 23:00:09,369 MathCommentAuthenticator:getHtml - That is >> to:32 >> >> If my analys is correct, why 'mathAnswer' is not forwarded? HAve you any >> idea? The only think that I have do is customizing the theme. How could >> I >> investigate to find if I stripped something of worth from the originale >> theme? Where is the the corrupted files located (I mothified the theme >> from web UI)? >> >> Thanks, >> >> rocsca >>> >>> - 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 >>>> >>>> >>> >> >> >> >