I've been trying to get this working for half a day now. I am trying to use password encryption in my grails app using the bcrypt plugin by Seymour Cakes and Burt Beckwith:
I have put the appropriate dependency in my BuildConfig.groovy and in my controller I am trying to run a simple test:
def bcryptService String goodpwd = "good" String badpwd = "bad" String encryptedpwd = goodpwd.encodeAsBcrypt() println " " println "Good Password: " + goodpwd println "Bad Password: " + badpwd println "Bcrypt Hash Of Good Password: " + encryptedpwd println "Matching good password: " + (goodpwd.encodeAsBcrypt().equals(encryptedpwd)) println "Matching bad password: " + (badpwd.encodeAsBcrypt().equals(encryptedpwd)) println "Bcrypt Service's match result: " + bcryptservice.checkPassword(goodpwd, encryptedpwd)
but I get this:
Good Password: good Bad Password: bad Bcrypt Hash Of Good Password: $2a$10$KvQOvmA4QjH4.JEk4.V2/uXYf8UjKJaUccDijQWG3RkBgAA2LOndS Matching good password: false Matching bad password: false Error | 2014-05-21 14:20:05,935 [http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver - MissingPropertyException occurred when processing request: [POST] /FatcaOne_0 No such property: bcryptservice for class: com.twc.fatcaone.AdminController. Stacktrace follows: Message: No such property: bcryptservice for class: com.twc.fatcaone.AdminController Line | Method ->> 71 | doCall in com.twc.fatcaone.AdminController$_closure5$$EOevDLMH - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sometimes it does that other times it complains that bcryptService is a null. I don't understand what I am doing wrong to not get this dependency injected. Any help greatly appreciated.