Shiro、Hibernate 和 Envers
我已经实现了 shiro 并且运行得很好。我们现在正在尝试实现 envers 来对休眠中的实体进行审计日志记录,这也很有效。一个问题是我们试图让主题在正常模式和 runAs 模式下从 shiro 进行更改。
Shiro 从当前线程获取主题,似乎当 envers 的 AuditEventListener 被调用时,它已经在一个单独的线程中。在 hibernate 中哪里有一个很好的钩子来将 shiro 的主题绑定到当前线程。 Shiro 已经有方法可以做到这一点,但我需要重写 hibernates 事件调用程序,以某种方式将主题绑定到新线程,或者向事件添加额外的数据,以便我稍后获取它。
I've got shiro implemented and it's working quite well. We're now trying to implement envers to do audit logging of our entities in hibernate and that works as well. One problem is we're trying to get the subject making the change from shiro both in normal mode and in runAs mode.
Shiro gets the subject from the current thread and it seems that by the time envers' AuditEventListener is called it's already in a separate thread. Where would be a good hook in hibernate to bind shiro's subject to the current thread. Shiro already has methods to do this but I'd need to override hibernates event caller to bind the subject to the new thread somehow or add additional data to the event that would let me grab it later.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明问题与配置有关。它在 bootstrap 中快要死了,当时安全性还没有发挥作用,因为它是 web.xml 中的一个过滤器,可以打开安全管理器。
Turns out the problem was related to configuration. It was dying in bootstrap which at the time security was not in play since it's a filter in web.xml that turns on the security manager.