I am using the java bcrypt class library to encrypt passwords on one of my
sites and it is working fine. However, I am extending the app with a
webservice and using the same bcrypt library to authenticate logins. This
works fine for a period of time and then stops working.

The error that I receive is "An exception occurred when executing method
checkpw.". The error detail is "The cause of this exception was that:
java.lang.NullPointerException.". Even when I start to receive this error,
I am still able to make the exact same call from within a CF template
without a problem. But being called from the webservice, I get the error. I
have tried reinitializing the app to no avail. The only way that I have
been able to fix the issue is by rebooting CF. I am using ACF 10 and here
is the code that I am using to call bcrypt.

component  displayname="Consumer API" output="false" wsversion="2"
namespace="http://mydomain/";
{
    variables.bcrypt = CreateObject("java", "BCrypt");

    remote struct function authenticate() returnformat="JSON" {
        var results = {};
        var memberEmail = "";
        var password = "";
        var token = "";

        results.status = 0;
        results.message = "Invalid email or password";

        if (isSOAPRequest()){
            try
            {
                memberEmail = getSOAPRequestHeader("http://mydomain/";,
"memberEmail");
                password = getSOAPRequestHeader("http://mydomain/";,
"password");

                if (isValid("email",memberEmail)){
                    Member = entityLoad("Member",{email=memberEmail},true);

                    if (NOT isNull(Member)){
                        if
(bcrypt.checkpw(lcase(password),Member.getMemberPassword())){
                            results.message = "Successfully Authenticated";
                            token =
variables.utility.formStringEncrypt(Member.getMemberID());
                            addSOAPResponseHeader("http://mydomain/";,
"token", token, false);
                            results.status = 1;
                            results.message = "Member authenticated";
                        } else {
                            addSOAPResponseHeader("http://mydomain/";,
"token", token, false);
                        }
                    } else {
                        addSOAPResponseHeader("http://mydomain/";, "token",
token, false);
                    }
                } else {
                        addSOAPResponseHeader("http://mydomain/";, "token",
token, false);
                }
            }
            catch(Any e)
            {
                results.message = "Error processing request.";
                sendError(e);
            }
        } else {
            results.message = "Not invoked as a web service";
        }

        return results;
    }
}

Any help would be greatly appreciated.

-- 

  [image: profile picture]  *Dean Lawrence*
*President*
Internet Data Technology
*Phone:* 888-438-4381 x701
*Web:* www.idatatech.com
*Email:* [email protected]
  Programming | Database | Consulting | Training


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359854
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to