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

问题描述

我在想,如果我的想法是可能的休眠。

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.

所以,我需要这样的:

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

推荐答案

您应该使用自定义的用户类型和实际上提供了一组基本的Hibernate 用户类型可满足您的需求。

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.



  • Security: Transparent encryption of persisted data (with Jasypt UserTypes)

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

10-31 01:23