Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/Authentication.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/Authentication.java	(revision 25721)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/Authentication.java	(revision 25722)
@@ -1,25 +1,24 @@
 package org.greenstone.gsdl3.service;
 
-import org.greenstone.gsdl3.util.GSXML;
-import org.greenstone.gsdl3.util.DerbyWrapper;
-import org.greenstone.gsdl3.util.UserQueryResult;
-import org.greenstone.gsdl3.util.UserTermInfo;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
+import java.io.File;
+import java.io.Serializable;
 import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.UUID;
 import java.util.Vector;
-import java.security.MessageDigest;
-import java.sql.SQLException;
 import java.util.regex.Pattern;
-import java.io.File;
-import java.io.Serializable;
 
 import net.tanesha.recaptcha.ReCaptchaImpl;
 import net.tanesha.recaptcha.ReCaptchaResponse;
+
+import org.greenstone.gsdl3.util.DerbyWrapper;
+import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.UserQueryResult;
+import org.greenstone.gsdl3.util.UserTermInfo;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 public class Authentication extends ServiceRack
@@ -360,5 +359,5 @@
 			String newComment = (String) paramMap.get("comment");
 			String newEmail = (String) paramMap.get("email");
-			
+
 			//Check the given user name
 			int error;
@@ -395,5 +394,5 @@
 			String newPassword = (String) paramMap.get("password");
 			String newEmail = (String) paramMap.get("email");
-			
+
 			//Check the given user name
 			int error;
@@ -410,15 +409,15 @@
 				return result;
 			}
-			
+
 			newPassword = hashPassword(newPassword);
 
-			if(_recaptchaPrivateKey != null)
+			if (_recaptchaPrivateKey != null)
 			{
 				ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
 				reCaptcha.setPrivateKey(_recaptchaPrivateKey);
-	
+
 				String challenge = (String) paramMap.get("recaptcha_challenge_field");
 				String uResponse = (String) paramMap.get("recaptcha_response_field");
-	
+
 				if (challenge == null || uResponse == null)
 				{
@@ -427,7 +426,7 @@
 					return result;
 				}
-	
+
 				ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(request.getAttribute("remoteAddress"), challenge, uResponse);
-	
+
 				if (!reCaptchaResponse.isValid())
 				{
@@ -475,8 +474,8 @@
 					return result;
 				}
-				
+
 				newPassword = hashPassword(newPassword);
 			}
-			
+
 			error = removeUser(previousUsername);
 			if (error != NO_ERROR)
@@ -537,5 +536,5 @@
 					return result;
 				}
-				
+
 				//Check the given password
 				int error;
@@ -545,5 +544,5 @@
 					return result;
 				}
-				
+
 				newPassword = hashPassword(newPassword);
 			}
@@ -552,5 +551,5 @@
 				newPassword = prevPassword;
 			}
-			
+
 			//Check the given user name
 			int error;
@@ -560,5 +559,5 @@
 				return result;
 			}
-			
+
 			String prevGroups = retrieveDataForUser(previousUsername, "groups");
 			String prevStatus = retrieveDataForUser(previousUsername, "status");
@@ -638,5 +637,16 @@
 		else if (op.equals(REGISTER))
 		{
-			if(_recaptchaPublicKey != null && _recaptchaPrivateKey != null)
+			try
+			{
+				ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
+				reCaptcha.setPrivateKey(_recaptchaPrivateKey);
+				reCaptcha.checkAnswer(request.getAttribute("remoteAddress"), "", "");
+			}
+			catch(Exception ex)
+			{
+				return result;
+			}
+
+			if (_recaptchaPublicKey != null && _recaptchaPrivateKey != null)
 			{
 				Element recaptchaElem = this.doc.createElement("recaptcha");
@@ -660,13 +670,13 @@
 		return result;
 	}
-	
+
 	public int checkUsernameAndPassword(String username, String password)
 	{
 		int uResult = checkUsername(username);
 		int pResult = checkPassword(password);
-		
+
 		return (uResult != NO_ERROR ? uResult : (pResult != NO_ERROR ? pResult : NO_ERROR));
 	}
-	
+
 	public int checkUsername(String username)
 	{
@@ -678,5 +688,5 @@
 		return NO_ERROR;
 	}
-	
+
 	public int checkPassword(String password)
 	{
@@ -706,18 +716,19 @@
 	}
 
-
-    
-    // This method can also be used for printing out the password in hex (in case
-    // the password used the UTF-8 Charset), or the hex values in any unicode string.
-    // From http://stackoverflow.com/questions/923863/converting-a-string-to-hexadecimal-in-java
-    public static String toHex(String arg) {
-	try {
-	    return String.format("%x", new BigInteger(arg.getBytes("US-ASCII"))); // set to same charset as used by hashPassword
-	} catch (Exception e) { // UnsupportedEncodingException
-	    e.printStackTrace();
-	} 
-	return "Unable to print";
-    }
-
+	// This method can also be used for printing out the password in hex (in case
+	// the password used the UTF-8 Charset), or the hex values in any unicode string.
+	// From http://stackoverflow.com/questions/923863/converting-a-string-to-hexadecimal-in-java
+	public static String toHex(String arg)
+	{
+		try
+		{
+			return String.format("%x", new BigInteger(arg.getBytes("US-ASCII"))); // set to same charset as used by hashPassword
+		}
+		catch (Exception e)
+		{ // UnsupportedEncodingException
+			e.printStackTrace();
+		}
+		return "Unable to print";
+	}
 
 	private void checkAdminUserExists()
