Hibernate - 通过用户名关系加密引用 [英] Hibernate - encrypted reference by relations on usernames
问题描述
我想知道我的想法是否可以通过 hibernate 实现.
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;
}
我希望我说清楚.
推荐答案
你应该使用自定义的 UserType
和 Jasypt (Java Simplified Encryption) 实际上提供了一组基本的 Hibernate UserType
可以满足您的需求.
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.
这篇关于Hibernate - 通过用户名关系加密引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!