I was wondering if my idea is possible with hibernate.
What I want is that there is one table with usernames and every table wich has a reference to this ta开发者_如何学Pythonble has the username encrypted in a column. So the username doesn't stand in normal text but encrypted in every table which have a reference to the user table.
So I need something like:
@ManyToOne
@JoinColumn(name = "userName", insertable=false, updatable=false, encrypted="md5")
public User getUser(){
return this.user;
}
public void setUser(User user ){
this.user = user;
}
I hope that I make myself clear.
You should implement this using a custom UserType
and Jasypt (Java Simplified Encryption) actually provides a basic set of Hibernate UserType
that may suit your needs.
See also
- Security: Transparent encryption of persisted data (with Jasypt UserTypes)
精彩评论