Skip to content
Lance edited this page Jan 5, 2014 · 6 revisions

You can add security to your application by contributing one or mode TopicAuthorizers. Each TopicAuthorizer can deny a subscription attempt by returning false from boolean isAuthorized(AtmosphereResource resource, String topic).

eg:

public class ChatTopicAuthorizer implements TopicAuthorizer {
   @Override
   public boolean isAuthorized(AtmosphereResource resource, String topic) {
      HttpSession session = resource.getRequest().getSession(false);
      if (session != null) {
         String chatUser = (String) session.getAttribute(ChatConstants.CHAT_USER_SESSION_KEY);
         return chatUser != null;
      }
      return false;
   }
}
public class AppModule {
   public static void contributeTopicAuthorizer(OrderedConfiguration<TopicAuthorizer> config) {
      config.addInstance("chat", ChatTopicAuthorizer.class);
   }
}
Clone this wiki locally