2017-05-26 44 views
0

工作我已经在我的项目运行在春季大气配置 - 春天的安全性。气氛不Wildfly 10个工作日,但大气的相同版本Tomcat8

所有的WebSocket调用我的@ManagedService类工作的罚款。

但是现在我想移动到Wildfly 10,并且在部署同一场战争时,气氛呼叫不会进入我的@ManagedService类。它发送到我的弹簧安全过滤器。

我的气氛版本:

<dependency> 
     <groupId>org.atmosphere</groupId> 
     <artifactId>atmosphere-runtime</artifactId> 
     <version>2.4.12</version> 
    </dependency> 

Spring版本:4.3.6.RELEASE

春季安全:4.2.1.RELEASE

这是我WepAppInitializer

// Create the dispatcher servlet's Spring application context 
AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext(); 
dispatcherServlet.register(SpringMVCConfig.class); 

// AtmosphereServlet atmosphereServlet = new AtmosphereServlet(); 
AtmosphereServlet atmosphereServlet = servletContext.createServlet(AtmosphereServlet.class); 
ServletRegistration.Dynamic websocketServlet = servletContext.addServlet("websocketServlet", atmosphereServlet); 
websocketServlet.setLoadOnStartup(0); 
websocketServlet.setAsyncSupported(true); 

Set<String> mappingConflicts = websocketServlet.addMapping("/subscribe/*"); 

// Register and map the dispatcher servlet 
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", 
    new DispatcherServlet(dispatcherServlet)); 
dispatcher.setAsyncSupported(true); 
dispatcher.setLoadOnStartup(1); 
dispatcher.addMapping("/"); 
mappingConflicts = dispatcher.addMapping("/"); 
if (!mappingConflicts.isEmpty()) { 
    throw new IllegalStateException("'appServlet' cannot be mapped to '/'"); 
} 
AtmosphereFramework framework = atmosphereServlet.framework(); 
broadcasterFactory = framework.getBroadcasterFactory(); 

下面是我的春节,安全片段

@Override 
protected void configure(HttpSecurity http) throws Exception { 

http.csrf().disable().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() 
    .authorizeRequests() 

    ... 
    My ant matchers... 
    ... 

    // All other request need to be authenticated 
    .anyRequest().authenticated() 
    // Custom Token based authentication based on the header 
    // previously given to the client 
    .and().addFilterBefore(authenticationFilter, UsernamePasswordAuthenticationFilter.class).logout() 
    .logoutUrl("/logout").disable().exceptionHandling().accessDeniedPage("/accessDenied"); 

} 

问题: 在wildfly,我所有的WebSocket调用要验证过滤器,而不是@ManagedService

任何具体的,我错过了野蝇必须做的事情?

回答

0

最后我明白了这个问题。 在wildfly中奇怪的是,websocket调用也会通过认证过滤器,而在Tomcat中,websocket调用会直接跳过到@ManagedService类。

所以我刚刚为我的氛围网址添加了一个忽略antMatcher。

@Override 
public void configure(WebSecurity web) throws Exception { 
web.ignoring().antMatchers(REQUEST_MAPPING_AUTHENTICATEUSER).antMatchers("/heartBeat") 
    .antMatchers("/subscribe/**"); 
} 

这解决了我的问题。