- Timestamp:
- 2012-05-31T13:56:53+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/Authentication.java
r25722 r25725 412 412 newPassword = hashPassword(newPassword); 413 413 414 if (_recaptchaPrivateKey != null )414 if (_recaptchaPrivateKey != null && _recaptchaPrivateKey.length() > 0) 415 415 { 416 416 ReCaptchaImpl reCaptcha = new ReCaptchaImpl(); 417 417 reCaptcha.setPrivateKey(_recaptchaPrivateKey); 418 418 419 String challenge = (String) paramMap.get("recaptcha_challenge_field"); 420 String uResponse = (String) paramMap.get("recaptcha_response_field"); 421 422 if (challenge == null || uResponse == null) 423 { 424 serviceNode.setAttribute("operation", REGISTER); 425 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_CAPTCHA_MISSING)); 426 return result; 427 } 428 429 ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(request.getAttribute("remoteAddress"), challenge, uResponse); 430 431 if (!reCaptchaResponse.isValid()) 432 { 433 serviceNode.setAttribute("operation", REGISTER); 434 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_CAPTCHA_DOES_NOT_MATCH)); 435 return result; 419 try 420 { 421 //If this line throws an exception then we'll assume the user has problems with their firewall 422 reCaptcha.checkAnswer(request.getAttribute("remoteAddress"), "", ""); 423 424 String challenge = (String) paramMap.get("recaptcha_challenge_field"); 425 String uResponse = (String) paramMap.get("recaptcha_response_field"); 426 427 if (challenge == null || uResponse == null) 428 { 429 serviceNode.setAttribute("operation", REGISTER); 430 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_CAPTCHA_MISSING)); 431 return result; 432 } 433 434 ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(request.getAttribute("remoteAddress"), challenge, uResponse); 435 436 if (!reCaptchaResponse.isValid()) 437 { 438 serviceNode.setAttribute("operation", REGISTER); 439 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_CAPTCHA_DOES_NOT_MATCH)); 440 return result; 441 } 442 } 443 catch (Exception ex) 444 { 436 445 } 437 446 } … … 637 646 else if (op.equals(REGISTER)) 638 647 { 639 try 640 { 641 ReCaptchaImpl reCaptcha = new ReCaptchaImpl(); 642 reCaptcha.setPrivateKey(_recaptchaPrivateKey); 643 reCaptcha.checkAnswer(request.getAttribute("remoteAddress"), "", ""); 644 } 645 catch(Exception ex) 646 { 647 return result; 648 if (_recaptchaPrivateKey != null && _recaptchaPrivateKey.length() > 0) 649 { 650 try 651 { 652 ReCaptchaImpl reCaptcha = new ReCaptchaImpl(); 653 reCaptcha.setPrivateKey(_recaptchaPrivateKey); 654 reCaptcha.checkAnswer(request.getAttribute("remoteAddress"), "", ""); 655 } 656 catch (Exception ex) 657 { 658 return result; 659 } 648 660 } 649 661
Note:
See TracChangeset
for help on using the changeset viewer.