@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String[] enablers = context.getBeanFactory()
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
ConditionMessage.Builder message = ConditionMessage
.forCondition("@EnableOAuth2Sso Condition");
for (String name : enablers) {
if (context.getBeanFactory().isTypeMatch(name,
WebSecurityConfigurerAdapter.class)) {
return ConditionOutcome.match(message
.found("@EnableOAuth2Sso annotation on WebSecurityConfigurerAdapter")
.items(name));
}
}
return ConditionOutcome.noMatch(message.didNotFind(
"@EnableOAuth2Sso annotation " + "on any WebSecurityConfigurerAdapter")
.atAll());
}
java类org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter的实例源码
EnableOAuth2SsoCondition.java 文件源码
项目:spring-security-oauth2-boot
阅读 36
收藏 0
点赞 0
评论 0
SecurityConfig.java 文件源码
项目:spring-microservice-sample
阅读 58
收藏 0
点赞 0
评论 0
@Bean
public WebSecurityConfigurerAdapter securityConfigBean(){
return new WebSecurityConfigurerAdapter() {
@Override
protected void configure(HttpSecurity http) throws Exception {
// We need this to prevent the browser from popping up a dialog on a 401
http
.httpBasic()
.and()
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/posts/**").permitAll()
.antMatchers(HttpMethod.DELETE, "/posts/**").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.csrf().disable();
}
};
}
BootApplication.java 文件源码
项目:boot-works
阅读 30
收藏 0
点赞 0
评论 0
@Bean
WebSecurityConfigurerAdapter webSecurityConfigurerAdapter() {
return new WebSecurityConfigurerAdapter() {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable() // enables HTTP GET for /logout, not recommended in prod
.authorizeRequests()
.antMatchers("/b/**").hasAnyAuthority("USER")
// hasRole(ADMIN) == hasAuthority(ROLE_ADMIN)
.antMatchers("/books/**").hasRole("ADMIN")
.anyRequest().authenticated()
.and().formLogin()
.and().logout().permitAll();
}
};
}
Application.java 文件源码
项目:mars-calendar
阅读 32
收藏 0
点赞 0
评论 0
@Bean
public WebSecurityConfigurerAdapter applicationSecurity() {
return new WebSecurityConfigurerAdapter() {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll().and().csrf().disable(); //oops?
}
//
// @Override
// protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// auth.inMemoryAuthentication().withUser("admin").password("admin")
// .roles("ADMIN", "USER").and().withUser("user").password("user")
// .roles("USER");
// }
};
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 33
收藏 0
点赞 0
评论 0
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
if (this.configType.isAssignableFrom(bean.getClass())
&& bean instanceof WebSecurityConfigurerAdapter) {
ProxyFactory factory = new ProxyFactory();
factory.setTarget(bean);
factory.addAdvice(new SsoSecurityAdapter(this.applicationContext));
bean = factory.getProxy();
}
return bean;
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 52
收藏 0
点赞 0
评论 0
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (invocation.getMethod().getName().equals("init")) {
Method method = ReflectionUtils
.findMethod(WebSecurityConfigurerAdapter.class, "getHttp");
ReflectionUtils.makeAccessible(method);
HttpSecurity http = (HttpSecurity) ReflectionUtils.invokeMethod(method,
invocation.getThis());
this.configurer.configure(http);
}
return invocation.proceed();
}
JwtSecurityAutoconfigureApplicationTests.java 文件源码
项目:jwt-security-spring-boot-starter
阅读 38
收藏 0
点赞 0
评论 0
/**
* Checks whether beans are registered after auto configuration class has been registered
*/
@Test
public void registerJwtAutoConfiguration() {
this.context.register(SecurityProperties.class);
this.context.register(JwtAutoConfiguration.class);
this.context.refresh();
//assert
this.context.getBean(TokenProvider.class);
this.context.getBean(PasswordEncoder.class);
this.context.getBean(UserDetailsService.class);
this.context.getBean(SecurityEvaluationContextExtension.class);
this.context.getBean(WebSecurityConfigurerAdapter.class);
}
JwtSecurityAutoconfigureApplicationTests.java 文件源码
项目:jwt-security-spring-boot-starter
阅读 36
收藏 0
点赞 0
评论 0
/**
* Expects not to have {@link WebSecurityConfigurerAdapter} in context if property is set to false
*/
@Test(expected = NoSuchBeanDefinitionException.class)
public void propertyAutoSecurityDisabled() {
this.context.register(SecurityProperties.class);
this.context.register(JwtAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "com.github.cobrijani.jwt.enabled:false");
this.context.refresh();
//assert
this.context.getBean(WebSecurityConfigurerAdapter.class);
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 34
收藏 0
点赞 0
评论 0
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
if (this.configType.isAssignableFrom(bean.getClass())
&& bean instanceof WebSecurityConfigurerAdapter) {
ProxyFactory factory = new ProxyFactory();
factory.setTarget(bean);
factory.addAdvice(new SsoSecurityAdapter(this.applicationContext));
bean = factory.getProxy();
}
return bean;
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 30
收藏 0
点赞 0
评论 0
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (invocation.getMethod().getName().equals("init")) {
Method method = ReflectionUtils
.findMethod(WebSecurityConfigurerAdapter.class, "getHttp");
ReflectionUtils.makeAccessible(method);
HttpSecurity http = (HttpSecurity) ReflectionUtils.invokeMethod(method,
invocation.getThis());
this.configurer.configure(http);
}
return invocation.proceed();
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 32
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String[] enablers = context.getBeanFactory()
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
for (String name : enablers) {
if (context.getBeanFactory().isTypeMatch(name,
WebSecurityConfigurerAdapter.class)) {
return ConditionOutcome.match(
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
}
return ConditionOutcome.noMatch(
"found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
OAuth2SsoDefaultConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 38
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String[] enablers = context.getBeanFactory()
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
for (String name : enablers) {
if (context.getBeanFactory().isTypeMatch(name,
WebSecurityConfigurerAdapter.class)) {
return ConditionOutcome.noMatch(
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
}
return ConditionOutcome
.match("found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
PSpringSecurityInitializer.java 文件源码
项目:singular-server
阅读 30
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
@Override
protected <T extends WebSecurityConfigurerAdapter> Class<T> getSpringSecurityConfigClass(IServerContext context) {
if (context.equals(PServerContext.WORKLIST)) {
return (Class<T>) SecurityConfigs.CASAnalise.class;
} else if (context.equals(PServerContext.REQUIREMENT)) {
return (Class<T>) SecurityConfigs.CASPeticionamento.class;
} else if (context.equals(PServerContext.ADMINISTRATION)) {
return (Class<T>) SecurityConfigs.AdministrationSecurity.class;
}
return null;
}
SpringSecurityInitializer.java 文件源码
项目:singular-server
阅读 32
收藏 0
点赞 0
评论 0
public void init(ServletContext ctx, AnnotationConfigWebApplicationContext applicationContext, String springMVCServletMapping, IServerContext[] serverContexts) {
addRestSecurity(applicationContext);
addSpringSecurityFilter(ctx, applicationContext, springMVCServletMapping);
for (IServerContext context : serverContexts) {
logger.info(SINGULAR_SECURITY, "Securing (Spring Security) context:", context.getContextPath());
Class<WebSecurityConfigurerAdapter> config = getSpringSecurityConfigClass(context);
if (config != null) {
applicationContext.register(config);
addLogoutFilter(ctx, applicationContext, springMVCServletMapping, context);
}
}
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
if (this.configType.isAssignableFrom(bean.getClass())
&& bean instanceof WebSecurityConfigurerAdapter) {
ProxyFactory factory = new ProxyFactory();
factory.setTarget(bean);
factory.addAdvice(new SsoSecurityAdapter(this.applicationContext));
bean = factory.getProxy();
}
return bean;
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 30
收藏 0
点赞 0
评论 0
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (invocation.getMethod().getName().equals("init")) {
Method method = ReflectionUtils
.findMethod(WebSecurityConfigurerAdapter.class, "getHttp");
ReflectionUtils.makeAccessible(method);
HttpSecurity http = (HttpSecurity) ReflectionUtils.invokeMethod(method,
invocation.getThis());
this.configurer.configure(http);
}
return invocation.proceed();
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String[] enablers = context.getBeanFactory()
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
for (String name : enablers) {
if (context.getBeanFactory().isTypeMatch(name,
WebSecurityConfigurerAdapter.class)) {
return ConditionOutcome.match(
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
}
return ConditionOutcome.noMatch(
"found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
OAuth2SsoDefaultConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 34
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String[] enablers = context.getBeanFactory()
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
for (String name : enablers) {
if (context.getBeanFactory().isTypeMatch(name,
WebSecurityConfigurerAdapter.class)) {
return ConditionOutcome.noMatch(
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
}
return ConditionOutcome
.match("found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
SecurityConfig.java 文件源码
项目:angularjs-springmvc-sample-boot
阅读 35
收藏 0
点赞 0
评论 0
@Bean
public WebSecurityConfigurerAdapter webSecurityConfigure(){
return new WebSecurityConfigurerAdapter() {
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests()
.antMatchers("/api/signup", "/api/users/username-check")
.permitAll()
.and()
.authorizeRequests()
.regexMatchers(HttpMethod.GET, "^/api/users/[\\d]*(\\/)?$").authenticated()
.regexMatchers(HttpMethod.GET, "^/api/users(\\/)?(\\?.+)?$").hasRole("ADMIN")
.regexMatchers(HttpMethod.DELETE, "^/api/users/[\\d]*(\\/)?$").hasRole("ADMIN")
.regexMatchers(HttpMethod.POST, "^/api/users(\\/)?$").hasRole("ADMIN")
.and()
.authorizeRequests()
.antMatchers("/api/**").authenticated()
.and()
.authorizeRequests()
.anyRequest().permitAll()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.httpBasic()
.and()
.csrf()
.disable();
// @formatter:on
}
};
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:contestparser
阅读 33
收藏 0
点赞 0
评论 0
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
if (this.configType.isAssignableFrom(bean.getClass())
&& bean instanceof WebSecurityConfigurerAdapter) {
ProxyFactory factory = new ProxyFactory();
factory.setTarget(bean);
factory.addAdvice(new SsoSecurityAdapter(this.beanFactory));
bean = factory.getProxy();
}
return bean;
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:contestparser
阅读 43
收藏 0
点赞 0
评论 0
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (invocation.getMethod().getName().equals("init")) {
Method method = ReflectionUtils
.findMethod(WebSecurityConfigurerAdapter.class, "getHttp");
ReflectionUtils.makeAccessible(method);
HttpSecurity http = (HttpSecurity) ReflectionUtils.invokeMethod(method,
invocation.getThis());
this.configurer.configure(http);
}
return invocation.proceed();
}
OAuth2SsoCustomConfiguration.java 文件源码
项目:contestparser
阅读 31
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String[] enablers = context.getBeanFactory()
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
for (String name : enablers) {
if (context.getBeanFactory().isTypeMatch(name,
WebSecurityConfigurerAdapter.class)) {
return ConditionOutcome.match(
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
}
return ConditionOutcome.noMatch(
"found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
OAuth2SsoDefaultConfiguration.java 文件源码
项目:contestparser
阅读 39
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String[] enablers = context.getBeanFactory()
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
for (String name : enablers) {
if (context.getBeanFactory().isTypeMatch(name,
WebSecurityConfigurerAdapter.class)) {
return ConditionOutcome.noMatch(
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
}
return ConditionOutcome
.match("found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
}
RestConfig.java 文件源码
项目:mirrorgate
阅读 33
收藏 0
点赞 0
评论 0
@Bean
public WebSecurityConfigurerAdapter secureConfigurer() {
return new WebSecurityConfigurerAdapterImpl();
}
H2ConsoleAutoConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 30
收藏 0
点赞 0
评论 0
@Bean
public WebSecurityConfigurerAdapter h2ConsoleSecurityConfigurer() {
return new H2ConsoleSecurityConfigurer();
}
StudioSpringSecurityInitializer.java 文件源码
项目:singular-server
阅读 33
收藏 0
点赞 0
评论 0
@Override
protected <T extends WebSecurityConfigurerAdapter> Class<T> getSpringSecurityConfigClass(IServerContext context) {
return (Class<T>) StudioSecurity.class;
}
H2ConsoleAutoConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 32
收藏 0
点赞 0
评论 0
@Bean
public WebSecurityConfigurerAdapter h2ConsoleSecurityConfigurer() {
return new H2ConsoleSecurityConfigurer();
}
H2ConsoleAutoConfiguration.java 文件源码
项目:contestparser
阅读 33
收藏 0
点赞 0
评论 0
@Bean
public WebSecurityConfigurerAdapter h2ConsoleSecurityConfigurer() {
return new H2ConsoleSecurityConfigurer();
}
ServletContainerConfiguration.java 文件源码
项目:haven-platform
阅读 27
收藏 0
点赞 0
评论 0
/**
* Disable csrf
* Allows anonymous request
*
* @return
*/
@Bean
@Autowired
WebSecurityConfigurerAdapter webSecurityConfigurerAdapter() {
return new WebSecurityConfigurerAdapterImpl();
}
SpringSecurityInitializer.java 文件源码
项目:singular-server
阅读 38
收藏 0
点赞 0
评论 0
protected abstract <T extends WebSecurityConfigurerAdapter> Class<T> getSpringSecurityConfigClass(IServerContext context);