2016-03-30 14 views
0

Ich wollte Verschlüsselung verwenden, um Benutzerdaten in Grails 2.5.4 Anwendung zu verschlüsseln. Ich folgte den Anweisungen zum Herunterladen der Konfiguration der Version 1.3.1 des Plugins.Jasypt verschlüsselt nicht in Grails 2.5.4

Meine Java-Sicherheits-JCE-Dateien in JDK 1.8 wurden aktualisiert (sowohl in JDK-JRE- als auch in Standalone-JRE-Verzeichnissen).

Ich habe hier einige Beiträge gefunden, die ähnlich waren und die Fixes wie die Kleinschreibung in ConfigFIlePath angewendet haben.

def configFilePath = System.getenv('ENCRYPTION_CONFIG_LOCATION') ?: "file:${userHome}" 
configFilePath += "/.jasypt.groovy" 
grails.config.locations = [configFilePath] 

ich auch mit der Konfiguration innerhalb des Objekts

jasypt { 
    algorithm = "PBEWITHSHA256AND256BITAES-CBC-BC" 
    providerName = "BC" 
    password = "test" 
    keyObtentionIterations = 1000 
} 

Config.groovy versucht

Meine Domain ist wie folgt definiert:

Egal
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 
    } 
} 

was ich die Daten in meiner Domain Objekt versuchen wird nicht verschlüsselt, soweit ich das beurteilen kann, indem ich es über die Grails-dbconsole-Anwendung anschaue.

Ich habe die Debugprotokollierung aktiviert, sehe aber keine Protokolle von jasept.

Antwort

1

Ich vermute, das Hauptproblem ist die Verwendung von type innerhalb Ihrer constraints und nicht innerhalb mapping wie die documentation erklärt.

Ich würde empfehlen, Sie constraints ändern wie folgt aussehen:

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 
} 

Und fügen mappings kurz nach den Zwängen wie folgt aus:

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 
}