[英]How to share Spring Security classes between a Grails app and a Java app?
I need to use the Spring Security User, Role/Authority and the UserRole-join classes both in a Grails application and a Java app.我需要在 Grails 应用程序和 Java 应用程序中使用 Spring 安全用户、角色/权限和 UserRole-join 类。
Where and how should I implement/generate these classes?我应该在哪里以及如何实现/生成这些类?
If I use the generated GORM/Groovy classes from Grails, how would I import and use them in the Java app (where I handle the Hibernate session factory myself)? If I use the generated GORM/Groovy classes from Grails, how would I import and use them in the Java app (where I handle the Hibernate session factory myself)?
Or would I implement them in Java as Hibernate Entities and import/use them in the Grails app?或者我会在 Java 中将它们实现为 Hibernate 实体并在 Grails 应用程序中导入/使用它们? (I have done this successfully before with 'normal' (none-Spring Security) classes, but I would not know whether/how to implement the get, create, remove, removeAll methods that the Spring Security Core plugin has generated)
(我之前使用“普通”(非 Spring 安全)类成功完成了此操作,但我不知道是否/如何实现 Spring 安全核心插件生成的 get、create、remove、removeAll 方法)
I've an grails app where your second option is used.我有一个 grails 应用程序,其中使用了您的第二个选项。
There is an separate module for data manipulations, because this project have two different standalone apps (grails website and backend processor with REST api), and also it uses MongoDB (so, all this GORM magic doesn't help there).有一个单独的数据操作模块,因为这个项目有两个不同的独立应用程序(grails 网站和带有 REST api 的后端处理器),并且它还使用 MongoDB(所以,所有这些 GORM 魔法都无济于事)。
And Spring Security used on both sides (web and backend), with different implementations, but everything works fine.和 Spring 双方(Web 和后端)使用的安全性,具有不同的实现,但一切正常。 Actually it requires some little work on implementing required beans (look inside Spring Security Core plugin), but it isn't so complicated.
实际上,实现所需的 bean 需要做一些小工作(查看 Spring 安全核心插件),但它并不复杂。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.