我想在Grails 2.5.4应用程序中使用加密来加密用户数据。我按照下载配置1.3.1版插件的说明进行操作。
在JDK 1.8中更新了我的Java安全JCE文件(在JDK jre和独立的JRE目录中)。
我在这里发现了一些类似的帖子,并应用了类似的修复程序 在configFIlePath中小写i。
def configFilePath = System.getenv('ENCRYPTION_CONFIG_LOCATION') ?: "file:${userHome}"
configFilePath += "/.jasypt.groovy"
grails.config.locations = [configFilePath]
我也在Config.groovy
中尝试了配置jasypt {
algorithm = "PBEWITHSHA256AND256BITAES-CBC-BC"
providerName = "BC"
password = "test"
keyObtentionIterations = 1000
}
我的域对象定义如下:
package com.xyz
import java.util.Date;
import com.bloomhealthco.jasypt.*
class UserProfile {
String firstName
String lastName
Date dateOfBirth
// USATT membership information
long usattID
Date expirationDate
// contact information
String email
String phone
String streetAddress
String city
String state
String zipCode
String country
String gender
String club
// no reference to SecUser
static belongsTo = SecUser
static hasMany = [tournamentEntries: TournamentEntry]
static constraints = {
firstName blank: false, maxSize: 384, type: GormEncryptedStringType
lastName blank: false, maxSize: 384, type: GormEncryptedStringType
dateOfBirth blank: false
gender blank: false, type: GormEncryptedStringType
email blank: false, maxSize: 384, type: GormEncryptedStringType
phone blank: false, maxSize: 384, type: GormEncryptedStringType
streetAddress blank: false, maxSize: 384, type: GormEncryptedStringType
city blank: false, maxSize: 384, type: GormEncryptedStringType
state blank: false, type: GormEncryptedStringType
zipCode blank: false, type: GormEncryptedStringType
country blank: false, maxSize: 384, type: GormEncryptedStringType
expirationDate nullable: true
}
}
无论我尝试什么,我的Domain对象中的数据都没有加密,只要我通过Grails dbconsole应用程序查看它就可以了。
我启用了调试日志记录,但没有看到来自jasypt的任何日志。
答案 0 :(得分:1)
我怀疑主要问题是在type
中使用constraints
而mapping
内constraints
解释不了{/ 1}}。
我建议您将static constraints = {
firstName blank: false, maxSize: 384
lastName blank: false, maxSize: 384
dateOfBirth blank: false
gender blank: false
email blank: false, maxSize: 384
phone blank: false, maxSize: 384
streetAddress blank: false, maxSize: 384
city blank: false, maxSize: 384
state blank: false
zipCode blank: false
country blank: false, maxSize: 384
expirationDate nullable: true
}
更改为:
mappings
在这样的约束之后添加static mapping = {
firstName type: GormEncryptedStringType
lastName type: GormEncryptedStringType
gender blank: false, type: GormEncryptedStringType
email type: GormEncryptedStringType
phone type: GormEncryptedStringType
streetAddress type: GormEncryptedStringType
city type: GormEncryptedStringType
state type: GormEncryptedStringType
zipCode blank: false, type: GormEncryptedStringType
country type: GormEncryptedStringType
}
:
<plugin name="com.kernix.pdfviewer" spec="1.1.0" source="pgb" />