Hibernate - 用户名关系加密引用 [英] Hibernate - encrypted reference by relations on usernames

查看:132
本文介绍了Hibernate - 用户名关系加密引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我的想法是否可以使用hibernate。



我想要的是有一个表,用户名和每个表都有这个表的引用在列中加密了用户名。因此,用户名不能以普通文本形式显示,而是在每个具有用户表参考的表中进行加密。



所以我需要这样的东西:

  @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简化加密)实际上提供了一套基本的可以满足您需要的Hibernate UserType 另请参阅


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.

解决方案

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

这篇关于Hibernate - 用户名关系加密引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆