当前位置: 首页>>代码示例>>Java>>正文


Java CorsConfigurationSource类代码示例

本文整理汇总了Java中org.springframework.web.cors.CorsConfigurationSource的典型用法代码示例。如果您正苦于以下问题:Java CorsConfigurationSource类的具体用法?Java CorsConfigurationSource怎么用?Java CorsConfigurationSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CorsConfigurationSource类属于org.springframework.web.cors包,在下文中一共展示了CorsConfigurationSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: corsConfigurationSource

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
@Bean
public CorsConfigurationSource corsConfigurationSource() {
	CorsConfiguration configuration = new CorsConfiguration();
	configuration.setAllowedOrigins(ImmutableList.of("*"));
	configuration.setAllowedMethods(ImmutableList.of("*"));
	configuration.setAllowCredentials(true);

	configuration.setAllowedHeaders(ImmutableList.of("*"));
	UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
	source.registerCorsConfiguration("/**", configuration);

	return source;
}
 
开发者ID:peavers,项目名称:swordfish-service,代码行数:14,代码来源:SecurityConfig.java

示例2: corsConfiguration

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
private CorsConfigurationSource corsConfiguration() {
	return new CorsConfigurationSource() {
		@Override
		public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
			CorsConfiguration corsConfig = new CorsConfiguration();

			if(asList(env.getActiveProfiles()).contains(PROFILE_DEV)) {
				corsConfig.setAllowedOrigins(asList("http://localhost:9090", "http://127.0.0.1:9090", "http://localhost:7070", "http://127.0.0.1:7070"));
			} else if (asList(env.getActiveProfiles()).contains(PROFILE_TEST)) {
				corsConfig.setAllowedOrigins(asList("https://bitcoin2-test.csg.uzh.ch"));
			} else if (asList(env.getActiveProfiles()).contains(PROFILE_PROD)) {
				corsConfig.setAllowedOrigins(asList("https://bitcoin.csg.uzh.ch"));
			}
			corsConfig.setAllowedMethods(asList("GET", "PUT", "POST", "DELETE", "OPTIONS"));
			corsConfig.setAllowedHeaders(asList("*"));
			corsConfig.setMaxAge(1800L);
			return corsConfig;
		}
	};
}
 
开发者ID:coinblesk,项目名称:coinblesk-server,代码行数:21,代码来源:SecurityConfig.java

示例3: corsConfigurationSource

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
protected CorsConfigurationSource corsConfigurationSource() {
    final CorsConfiguration configuration = new CorsConfiguration();
    configuration.setAllowCredentials(true);
    configuration.setAllowedOrigins(Arrays.asList("*"));
    configuration.setAllowedMethods(Arrays.asList("GET", "POST", "DELETE", "PUT"));
    configuration.setAllowedHeaders(Arrays.asList("X-Requested-With", "Authorization"));
    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/**", configuration);
    return source;
}
 
开发者ID:panga,项目名称:unibave-backend,代码行数:11,代码来源:WebSecurityConfig.java

示例4: getCorsConfiguration

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
/**
 * Retrieve the CORS configuration for the given handler.
 * @param handler the handler to check (never {@code null}).
 * @param request the current request.
 * @return the CORS configuration for the handler or {@code null}.
 * @since 4.2
 */
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
	if (handler instanceof HandlerExecutionChain) {
		handler = ((HandlerExecutionChain) handler).getHandler();
	}
	if (handler instanceof CorsConfigurationSource) {
		return ((CorsConfigurationSource) handler).getCorsConfiguration(request);
	}
	return null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:AbstractHandlerMapping.java

示例5: getCorsConfiguration

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
@Override
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
	if (this.sockJsService instanceof CorsConfigurationSource) {
		return ((CorsConfigurationSource) this.sockJsService).getCorsConfiguration(request);
	}
	return null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:SockJsHttpRequestHandler.java

示例6: corsConfigurationSource

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
@Bean
public CorsConfigurationSource corsConfigurationSource() {
    final CorsConfiguration configuration = new CorsConfiguration();
    configuration.setAllowedOrigins(ImmutableList.of("http://localhost:4200"));
    configuration.setAllowedMethods(Arrays.asList(CORS_ALLOWED_METHODS));
    configuration.setAllowCredentials(false);
    configuration.setAllowedHeaders(Arrays.asList(CORS_ALLOW_HEADERS));

    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/**", configuration);
    return source;
}
 
开发者ID:vlsidlyarevich,项目名称:unity,代码行数:13,代码来源:SecurityConfig.java

示例7: corsConfigurationSource

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
/**
 * CorsConfigurationSource bean initializer.
 * @return cors configuration
 */
@Bean
public CorsConfigurationSource corsConfigurationSource() {
  UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
  if (allowedOrigins.length > 0) {
    CorsConfiguration configuration = new CorsConfiguration();
    configuration.setAllowedOrigins(Arrays.asList(allowedOrigins));
    configuration.setAllowedMethods(Arrays.asList(allowedMethods));
    source.registerCorsConfiguration("/**", configuration);
  }
  return source;
}
 
开发者ID:OpenLMIS,项目名称:openlmis-stockmanagement,代码行数:16,代码来源:ResourceServerSecurityConfiguration.java

示例8: CorsFilter

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
public CorsFilter(CorsConfigurationSource configSource) {
    super(configSource);
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:4,代码来源:CorsFilter.java

示例9: corsConfigurationSource

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
@Bean
public CorsConfigurationSource corsConfigurationSource() {
    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/**", new CorsConfiguration().applyPermitDefaultValues());
    return source;
}
 
开发者ID:SarunasDaubaris,项目名称:personal-garage-service,代码行数:7,代码来源:ApplicationSecurityConfigurer.java

示例10: CorsFilter

import org.springframework.web.cors.CorsConfigurationSource; //导入依赖的package包/类
/**
 * Constructor accepting a {@link CorsConfigurationSource} used by the filter to find
 * the {@link CorsConfiguration} to use for each incoming request.
 * @see UrlBasedCorsConfigurationSource
 */
public CorsFilter(CorsConfigurationSource configSource) {
	this.configSource = configSource;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:CorsFilter.java


注:本文中的org.springframework.web.cors.CorsConfigurationSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。