roller-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rocco Scappatura" <>
Subject Re: authenticator
Date Thu, 17 Dec 2009 15:30:37 GMT
On Gio, 17 Dicembre 2009 4:44, Dave wrote:
> On Tue, Dec 15, 2009 at 5:04 AM, Rocco Scappatura
> <> wrote:
>> On Sab, 12 Dicembre 2009 4:27, Dave wrote:
>>> Part of the problem is that the math authenticator does not include
>>> debug statements:
>>> 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 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
> 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?



View raw message