Hibernate - encrypted reference by relations on usernames

强颜欢笑 提交于 2020-01-15 04:59:06

问题


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 table 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.


回答1:


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)


来源:https://stackoverflow.com/questions/3282245/hibernate-encrypted-reference-by-relations-on-usernames

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!