Flex Messaging Security

五迷三道 提交于 2020-01-01 19:37:22

问题


I'm trying to create a module for a flex application, and I want to send notifications to clients. I've been looking at the BlazeDS messaging service to push out the notifications to clients, but I want to be able to send certain updates to certain clients. The Flex notification framework doesn't seem to allow this - if we have a field in the message with a value of the user's user id for example, any client could theoretically subscribe to all messages for any given user id, and there's no verification on the server side to make sure that the client that has subscribed is logged in as that user id.

Is there something I've missed here, or is the best way to handle this writing my own polling mechanism on the client side?


回答1:


There is indeed a solution for this in the APIs. The first step is to write a class which extends the FlexClientOutboundQueueProcessor class. You need to override one method:

public void add(List outboundQueue, Message message);

Basically all you need to do is write some logic to determine whether you should make the following call:

outboundQueue.add(message)

Simply put, if you don't add the message to the queue, then the message won't be pushed to the client. The other important method in this class is:

FlexClient getFlexClient()

Which you can use to get the associated FlexSession and ultimately the authentication information that presumably exists in your app.

Once this is done, you just need to register the processor with the appropriate channels. Simply add this element within the "properties" element of the "channel-definition" element:

<flex-client-outbound-queue-processor class="com.foo.YourProcessor"/>

I believe you can also specify a nested "properties" element for the queue processor but I don't believe it's required.




回答2:


You can use subtopics for this as long as you disable wildcard subscriptions.



来源:https://stackoverflow.com/questions/916437/flex-messaging-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!