如何在Grails中应用Jasypt插件2.3.7

时间:2015-09-01 15:07:36

标签: grails gorm jasypt

我正在尝试在我的应用程序中应用Jasypt插件来加密我的表的字段。 这是我的代码。

DOMAIN CLASS

import com.bloomhealthco.jasypt.GormEncryptedStringType;

class TestForm {

    String name
    String age
    String gender
    static mapping = {
        name type: GormEncryptedStringType
        age type: GormEncryptedStringType
        gender type: GormEncryptedStringType
    }
    static constraints = {
    }
}

BUILDCONFIG

plugins {
    // plugins for the build system only
    build ":tomcat:7.0.52.1"

    // plugins for the compile step
    compile ":scaffolding:2.0.2"
    compile ':cache:1.1.1'
    compile ":jasypt-encryption:1.2.1"
    // plugins needed at runtime but not for compilation
    runtime ":hibernate:3.6.10.9"  //or ":hibernate4:4.3.4"

}

CONFIG

//Database encryption configuration
Jasypt {
    algorithm = "PBEWITHSHA256AND256BITAES-CBC-BC"
    providerName = "BC"
    password = "c3kr37"
    keyObtentionIterations = 1000
}

我在我的应用程序中完成的所有操作,这也成功下载了jasypt插件。但是当我尝试保存记录时,它会显示以下错误

Error 500: Internal Server Error

URI:

/grailsTest/testForm/save

Class:

org.jasypt.exceptions.EncryptionInitializationException

Message:

No string encryptor registered for hibernate with name "gormEncryptor"

希望有正确的方向使用此插件,提前谢谢。

0 个答案:

没有答案