保护捆绑包中的 JAX-RS
我正在 glassfish 中创建一个 REST 服务(它使用 Jersey 作为 JAX-RS 实现)。我想将我的服务部署为运行良好的 OSGI 包,我在清单中添加“Web-ContextPath:”,然后使用带注释的 @javax.ws.rs.ApplicationPath 应用程序对象。这一切都使服务可用,但是我想使用基于容器的安全性。我发现我可以在 web.xml 中使用安全约束,然后在 sun-web.xml 中进行用户到角色的映射。也就是说,OSGI 包两者都没有。
清单中是否有一组注释和/或参数,我可以在其中指定应用程序角色、安全约束和角色-用户映射(我认为后者可以全局配置)?
谢谢!
I am creating a REST service in glassfish (which uses Jersey as the JAX-RS impl.). I want to deploy my service as an OSGI bundle which works fine, I add the "Web-ContextPath:" in the manifest and then use an annotated @javax.ws.rs.ApplicationPath application object. This all makes the service usable but then, I want to use container based security. I found I can use security contrains in a web.xml and then do the user-to-role mappings in sun-web.xml. That said, a OSGI bundle does not have either.
Is there a set of annotations and or parameters to the manifest where I can specify application roles, security constrains and role-user mappings (I think the latter can just be globally configured)?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我的尝试方法:
使用一个库,该库可以自动检测具有特定注释的 OSGi 服务,并将它们转换为 REST 资源。对于泽西岛,您可以尝试以下操作: https://github.com/hstaudacher/osgi-jax -rs-connector
使用 OSGi 嵌入式应用服务器,如 jetty(或 tomcat),它提供 OSGi HTTP 服务实现。
配置 Jetty/Tomcat。现在这应该很容易,因为 Jetty/Tomcat 捆绑包可以从配置区域获取配置。
使用 Karaf 还可以节省大量时间,它可以为您完成所有与打包相关的工作,包括提供具有外部化配置的嵌入式 Jetty 等功能。但这完全取决于您。
Here's how I would try this:
Use a library that would automatically detect OSGi services with specific annotations, and translate them to REST resources. For Jersey, you could try this: https://github.com/hstaudacher/osgi-jax-rs-connector
Use OSGi embedded application server like jetty (or tomcat) which provides the OSGi HTTP Service implementation.
Configure Jetty/Tomcat. This should be easy now as the Jetty/Tomcat bundles can pick up configurations from the configuration area.
It would also save a lot of time to use Karaf which would do all the packaging related work for you, including providing features like embedded Jetty with externalized configurations, etc. But that's totally up to you.