Captcha - fails validation EVERY time

UI Components for JSF
Post Reply
User avatar
mndot_lance
Posts: 137
Joined: 15 Oct 2009, 21:53

19 Feb 2011, 07:22

Alright, I just spent several hours searching this forum, recaptcha developer guide, and the REST of the internet before posting this question and taking your time. Please, if you've got any answer, you'll make my day:

Problem:
I use p:captcha as indicated in showcase, and it fails validation EVERY time and says:
Captcha: Validation Error: Value is not valid.Captcha: 'sensing edivis' does not match the displayed text.
where 'sensing edivis' was my attempt of course. I attempted probably 50 words. Its clearly broken.

Version:
2.2.RC2 and tried 2.2.1 also


I know my public and private keys are good, because I made a quick sample PHP page using them and it works JUST fine.

My xhtml:

Code: Select all

       <ui:define name="body">
            <h:form>
                <p:messages id="msgs" showDetail="true" showSummary="true" />
                <p:captcha label="Captcha" theme="blackglass" publicKey="6Ld7pMESAAAAAHd1VihJkqPUXAJVwU3Cghc8fzrq"/>
                <p:commandButton value="Test" ajax="false" />
            </h:form>
        </ui:define>

My web.xml:

Code: Select all

 
 <!-- keys gotten from recaptcha -->
    <context-param>
        <param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
        <param-value>6Ld7pMESAAAAAHd1VihJkqPUXAJVwU3Cghc8fzrq</param-value>
    </context-param>
   
    <context-param>
        <param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
        <param-value>6Ld7pMESAAAAAMhr5WSk5bcRrff8Y08NtDi8Buoq</param-value>
    </context-param>
My only thought is that I'm running this on LOCALHOST, so perhaps somehow that's a problem? But my php app is on localhost also and these keys work just fine... I don't know what to think, losing soo much time :evil: :oops: :( :shock:
Last edited by mndot_lance on 20 Feb 2011, 07:20, edited 2 times in total.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 Feb 2011, 12:57

Weird, showcase works online

http://www.primefaces.org/showcase/ui/captcha.jsf

and offline with running on localhost.

Can't see what the problem is except, there is no need to define publickey on component as context-param is used now.

Code: Select all

<p:captcha label="Captcha" theme="blackglass" />
Do you use https by any chance?

User avatar
mndot_lance
Posts: 137
Joined: 15 Oct 2009, 21:53

20 Feb 2011, 07:18

I did try both SSL and non-SSL. I tried with public key on component and in web.xml. Urg.

Thanks for your time, I'll continue trying to figure this out. I have a feeling it has something to do with my local environment, not PrimeFaces. If I find out otherwise, I'll post up.

Most likely I'm giving up and writing some simple math-captcha from scratch. 3 plus 2 is? 5. You're in.

jjayaraman
Posts: 17
Joined: 09 Jul 2013, 10:49

13 Aug 2013, 14:47

I too get the PUBLIC_CAPTCHA_KEY error when I use <p:captcha in Primefaces version 3.5

<p:captcha label="Captcha" />


javax.faces.FacesException: Cannot find public key for catpcha, use primefaces.PUBLIC_CAPTCHA_KEY context-param to defin
e one
at org.primefaces.component.captcha.CaptchaRenderer.encodeEnd(CaptchaRenderer.java:64)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:63)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:47)
at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:202)
Truncated. see log file for complete stacktrace

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

13 Aug 2013, 15:10

@Jayaraman

Next time don't raise the old threads and better to post them as separate topics(If you like to refer old topics then just post those links in your post).Exception log itself reveals you didn't configure the public keys.Do you configure them in web.xml file?
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

jjayaraman
Posts: 17
Joined: 09 Jul 2013, 10:49

13 Aug 2013, 15:15

sudheer wrote:@Jayaraman

Next time don't raise the old threads and better to post them as separate topics(If you like to refer old topics then just post those links in your post).Exception log itself reveals you didn't configure the public keys.Do you configure them in web.xml file?
Hi Sudheer

Thanks for the reply. Sure would do....

From google I found the below code and after I add this to web.xml it works.
But are these values all right ?
Or should I generate similarly for my use ?
How do I generate it.

web.xml

<context-param>
<param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
<param-value>6Ld7pMESAAAAAHd1VihJkqPUXAJVwU3Cghc8fzrq</param-value>
</context-param>

<context-param>
<param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
<param-value>6Ld7pMESAAAAAMhr5WSk5bcRrff8Y08NtDi8Buoq</param-value>
</context-param>


Many thanks
Jay

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

14 Aug 2013, 08:24

You should sign up for reCaptcha to get private and public keys.These keys are specific to your domain.I'am not sure whether you can use existing keys.User guide page 54 mentioned about this.Then configure your generated keys in web.xml accordingly.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 56 guests