如何在不使用 FlexContext 的情况下从 Java 服务对象访问主体?
我们正在构建一些 Java 对象,这些对象通过 BlazeDS 公开给我们的 Flex 客户端应用程序。因此,基本上,BlazeDS 消息代理 Servlet 会实例化并调用这些对象上的方法来响应客户端请求。效果很好。
我们使用基于应用程序服务器的身份验证,并在 remoting-config.xml 文件元素中的
元素上设置了安全约束,以防止未经身份验证的客户端能够访问这些远程java 对象。再次,工作正常。
然而,在这些 java 对象的实现中有几个地方我们想要获取当前登录用户的用户名。现在,我们通过 FlexContext.getUserPrincipal() 来执行此操作,它可以访问此内容,但我们有一个挥之不去的担忧,即我们不喜欢这些对象(服务层)的实现对 BlazeDS 类具有硬依赖性。但我们不确定如何才能访问此内容。这同样适用于访问 ServletContext 等。
有什么想法吗?
We're building some Java objects that are exposed via BlazeDS to our flex client application. So basically the BlazeDS messagebroker servlet instantiates and invokes methods on these objects in response to client requests. Works great.
We're using app server-based authentication and have set up a security constraint on the <destination>
elements in the remoting-config.xml file element to prevent unauthenticated clients from being able to access these remote java objects. Again, works fine.
However, there are several places within the implementation of these java objects where we want to get the currently logged on user's username. Right now we are doing this via FlexContext.getUserPrincipal()
, which gives access to this but we have a nagging concern that we don't like the idea that the implementation of these objects (the service layer) has a hard dependency on a BlazeDS class. But we're not sure how else to get access to this. The same applies to accessing the ServletContext and such.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 BlazeDS 的 MessageBrokerServlet 时没有办法解决这个问题。我能想到的唯一选择是编写自己的执行 AMF 的 servlet, 喜欢这个。
There isn't a way around this when using BlazeDS's MessageBrokerServlet. The only option I can think of is to write your own servlet that does AMF, like this one.