roller-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scappatura Rocco <Rocco.Scappat...@infracom.it>
Subject RE: Comment authentication problem
Date Sat, 25 Jun 2011 15:02:56 GMT
> -----Original Message-----
> From: Dave [mailto:snoopdave@gmail.com]
> Sent: Saturday, June 25, 2011 3:20 PM
> To: user@roller.apache.org
> Subject: Re: Comment authentication problem
> 
> I believe your package name should be this:
> 
>    package org.rocsca;

You have right.. I'm sorry for the trivial error.

I have succesfull compiled the class, jarred it into rocsca.jar and put it into %ROLLER%\WEB-INF\lib.

Into my roller-custom.properties I have:

comment.authenticator.classname=org.rocsca.MathCommentAuthenticator

log4j.category.org.apache.roller.weblogger.ui.rendering.plugins.comments=DEBUG

But also after have restarted roller application, I cant see any debug messages into roller.log
file..

It is possible that rocsca.jar archive has not been loaded? Or what else it can be happened?

Thanks,

> - Dave

rocsca

> 
> On Sat, Jun 25, 2011 at 9:07 AM, Scappatura Rocco
> <Rocco.Scappatura@infracom.it> wrote:
> >> -----Original Message-----
> >> From: Dave [mailto:snoopdave@gmail.com]
> >> Sent: Wednesday, June 22, 2011 9:02 PM
> >> To: user@roller.apache.org
> >> Subject: Re: Comment authentication problem
> >>
> >> Looks like my original suggestion should work for you:
> >> Add this to your imports:
> >>
> >>     import
> >>
> org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentAuthenticator
> >
> > Hello,
> >
> > compiling is success full but I get this runtime error:
> >
> > java.lang.NoClassDefFoundError: org/rocsca/MathCommentAuthenticator (wrong
> name: org/rocsca/MathCommentAuthenticator/MathCommentAuthenticator)
> >        java.lang.ClassLoader.defineClass1(Native Method)
> >        java.lang.ClassLoader.defineClass(Unknown Source)
> >        java.security.SecureClassLoader.defineClass(Unknown Source)
> >
>  org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoa
> der.java:1880)
> >
>  org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java
> :889)
> >
>  org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java
> :1353)
> >
>  org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java
> :1232)
> >        java.lang.ClassLoader.loadClassInternal(Unknown Source)
> >        java.lang.Class.forName0(Native Method)
> >        java.lang.Class.forName(Unknown Source)
> >
>  org.apache.roller.weblogger.ui.rendering.servlets.CommentServlet.init(Comment
> Servlet.java:91)
> >
>  org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.handleRequest(We
> blogRequestMapper.java:231)
> >
>  org.apache.roller.weblogger.ui.rendering.filters.RequestMappingFilter.doFilte
> r(RequestMappingFilter.java:128)
> >
>  org.apache.roller.weblogger.ui.core.filters.InitFilter.doFilter(InitFilter.ja
> va:71)
> >
>  org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.doFilter
> (PersistenceSessionFilter.java:60)
> >
>  org.apache.roller.weblogger.ui.core.filters.BootstrapFilter.doFilter(Bootstra
> pFilter.java:67)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:378)
> >
>  org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(F
> ilterSecurityInterceptor.java:109)
> >
>  org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter
> (FilterSecurityInterceptor.java:83)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(
> SessionFixationProtectionFilter.java:52)
> >
>  org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityF
> ilter.java:53)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(Excep
> tionTranslationFilter.java:101)
> >
>  org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityF
> ilter.java:53)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilte
> rHttp(RememberMeProcessingFilter.java:109)
> >
>  org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityF
> ilter.java:53)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.
> doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
> >
>  org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityF
> ilter.java:53)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(Abstrac
> tProcessingFilter.java:278)
> >
>  org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityF
> ilter.java:53)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(Abstrac
> tProcessingFilter.java:278)
> >
>  org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityF
> ilter.java:53)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.context.HttpSessionContextIntegrationFilter.doFi
> lterHttp(HttpSessionContextIntegrationFilter.java:235)
> >
>  org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityF
> ilter.java:53)
> >
>  org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilte
> r(FilterChainProxy.java:390)
> >
>  org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.
> java:175)
> >
>  org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(Delegatin
> gFilterProxy.java:236)
> >
>  org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilte
> rProxy.java:167)
> >
>  org.apache.roller.weblogger.ui.core.filters.SchemeEnforcementFilter.doFilter(
> SchemeEnforcementFilter.java:121)
> >
>  org.apache.roller.weblogger.ui.core.filters.CharEncodingFilter.doFilter(CharE
> ncodingFilter.java:81)
> >
> >> - Dave
> >
> > Rocsca
> >
> >> On Tue, Jun 21, 2011 at 3:30 AM, Scappatura Rocco
> >> <Rocco.Scappatura@infracom.it> wrote:
> >> >> -----Original Message-----
> >> >> From: Dave [mailto:snoopdave@gmail.com]
> >> >> Sent: Monday, June 20, 2011 10:09 PM
> >> >> To: user@roller.apache.org
> >> >> Subject: Re: Comment authentication problem
> >> >>
> >> >> Unfortunately, we don't accept attachments.
> >> >> Please paste into an email message.
> >> >
> >> > package org.rocsca.MathCommentAuthenticator;
> >> >
> >> > import java.util.ResourceBundle;
> >> > import javax.servlet.http.HttpServletRequest;
> >> > import javax.servlet.http.HttpSession;
> >> > import org.apache.commons.logging.Log;
> >> > import org.apache.commons.logging.LogFactory;
> >> >
> >> >
> >> > /**
> >> >  * Asks the commenter to answer a simple math question.
> >> >  */
> >> > public class MathCommentAuthenticator implements CommentAuthenticator {
> >> >
> >> >    private transient ResourceBundle bundle =
> >> >            ResourceBundle.getBundle("ApplicationResources");
> >> >
> >> >    private static Log mLogger =
> >> LogFactory.getLog(MathCommentAuthenticator.class);
> >> >
> >> >
> >> >    public String getHtml(HttpServletRequest request) {
> >> >
> >> >        String answer = "";
> >> >
> >> >        HttpSession session = request.getSession(true);
> >> >        if (session.getAttribute("mathAnswer") == null) {
> >> >            // starting a new test
> >> >            int value1 = (int)(Math.random()*10.0);
> >> >            int value2 = (int)(Math.random()*100.0);
> >> >            int sum = value1 + value2;
> >> >            session.setAttribute("mathValue1", new Integer(value1));
> >> >            session.setAttribute("mathValue2", new Integer(value2));
> >> >            session.setAttribute("mathAnswer", new Integer(sum));
> >> >        } else {
> >> >            // preserve user's answer
> >> >            answer = request.getParameter("answer");
> >> >            answer = (answer == null) ? "" : answer;
> >> >        }
> >> >
> >> >        // pull existing values out of session
> >> >        Integer value1o =
> >> (Integer)request.getSession().getAttribute("mathValue1");
> >> >        Integer value2o =
> >> (Integer)request.getSession().getAttribute("mathValue2");
> >> >
> >> >        StringBuffer sb = new StringBuffer();
> >> >
> >> >        sb.append("<p>");
> >> >        sb.append(bundle.getString("comments.mathAuthenticatorQuestion"));
> >> >        sb.append("</p><p>");
> >> >        sb.append(value1o);
> >> >        sb.append(" + ");
> >> >        sb.append(value2o);
> >> >        sb.append(" = ");
> >> >        sb.append("<input name=\"answer\" value=\"");
> >> >        sb.append(answer);
> >> >        sb.append("\" /></p>");
> >> >        sb.append("<input type=hidden name=\"mathAnswer\" value=\"");
> >> >        sb.append(mathAnswer);
> >> >        sb.append("\" />");
> >> >
> >> >        return sb.toString();
> >> >    }
> >> >
> >> >
> >> >    public boolean authenticate(HttpServletRequest request) {
> >> >
> >> >        boolean authentic = false;
> >> >
> >> >        HttpSession session = request.getSession(false);
> >> >        String answerString = request.getParameter("answer");
> >> >
> >> >        if (answerString != null && session != null) {
> >> >            try {
> >> >                int answer = Integer.parseInt(answerString);
> >> >                Integer sum = (Integer)
> session.getAttribute("mathAnswer");
> >> >
> >> >                if (mathAnswerString != null && answer ==
> >> Integer.parseInt(mathAnswerString)) {
> >> >                    authentic = true;
> >> >                    session.removeAttribute("mathAnswer");
> >> >                    session.removeAttribute("mathValue1");
> >> >                    session.removeAttribute("mathValue2");
> >> >                }
> >> >            } catch (NumberFormatException ignored) {
> >> >                // ignored ... someone is just really bad at math
> >> >            } catch (Exception e) {
> >> >                // unexpected
> >> >                mLogger.error(e);
> >> >            }
> >> >        }
> >> >
> >> >        return authentic;
> >> >    }
> >> >
> >> > }
> >> >
> >> >> - Dave
> >> >
> >> > rocsca
> >> >
> >> >>
> >> >>
> >> >>
> >> >> On Mon, Jun 20, 2011 at 3:57 PM, Scappatura Rocco
> >> >> <Rocco.Scappatura@infracom.it> wrote:
> >> >> >> -----Original Message-----
> >> >> >> From: Dave [mailto:snoopdave@gmail.com]
> >> >> >> Sent: Monday, June 20, 2011 5:20 PM
> >> >> >> To: user@roller.apache.org
> >> >> >> Subject: Re: Comment authentication problem
> >> >> >>
> >> >> >> On Mon, Jun 20, 2011 at 9:28 AM, Scappatura Rocco
> >> >> >> <Rocco.Scappatura@infracom.it> wrote:
> >> >> >> >> > import java.util.ResourceBundle;
> >> >> >> >> > import javax.servlet.http.HttpServletRequest;
> >> >> >> >> > import javax.servlet.http.HttpSession;
> >> >> >> >> > import org.apache.commons.logging.Log;
> >> >> >> >> > import org.apache.commons.logging.LogFactory;
> >> >> >> >>
> >> >> >> >> I don't see any org.apache.roller packages there.
> >> >> >> >>
> >> >> >> >> What is the package name of the class your are defining?
> >> >> >> > package org.rocsca.MathCommentAuthenticator;
> >> >> >>
> >> >> >> The problem is that you code cannot find the "CommentAuthenticator"
> >> >> >>
> >> >> >> You might be able to fix this by adding this to your imports:
> >> >> >>    import
> >> >> >>
> >> >>
> >>
> org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentAuthenticator
> >> >> >>
> >> >> >> But it's hard to tell because I don't have your full source.
> >> >> >
> >> >> > Obviously my code is open source! :-P
> >> >> >
> >> >> > In attachment there is the java code.
> >> >> >
> >> >> >> Thanks,
> >> >> >> Dave
> >> >> >
> >> >> > Thanks to you!
> >> >> > rocsca
> >> >> >
> >> >
> >

Mime
View raw message