List of usage examples for org.springframework.security.config.annotation.web.builders HttpSecurity getSharedObject
<C> C getSharedObject(Class<C> sharedType);
From source file:shiver.me.timbers.spring.security.JwtSpringSecurityAdaptor.java
private void autowireThis(HttpSecurity http) { final ApplicationContext parent = http.getSharedObject(ApplicationContext.class); checkForJwtAnnotation(parent);//from w w w . j a v a 2s. c o m final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.setParent(parent); context.register(PropertySourcesPlaceholderConfigurer.class); context.register(getClass()); context.refresh(); context.getAutowireCapableBeanFactory().autowireBean(this); }
From source file:org.juiser.spring.boot.config.JuiserAuthenticationFilterRegistrar.java
@Override public void init(HttpSecurity http) throws Exception { // autowire this bean ApplicationContext context = http.getSharedObject(ApplicationContext.class); context.getAutowireCapableBeanFactory().autowireBean(this); boolean springSecurityEnabled = forwardedHeaderConfig.getJwt() instanceof SpringSecurityJwtConfig; if (springSecurityEnabled) { String headerName = forwardedHeaderConfig.getName(); HeaderAuthenticationFilter filter = new HeaderAuthenticationFilter(headerName, authenticationManager); http.addFilterBefore(filter, UsernamePasswordAuthenticationFilter.class); } //else juiser.security.enabled is false or spring security is disabled via a property }
From source file:sample.MyConfigurer.java
@SuppressWarnings("unchecked") @Override/*w ww .j a v a2s. co m*/ public void init(HttpSecurity http) throws Exception { // autowire this bean ApplicationContext context = http.getSharedObject(ApplicationContext.class); context.getAutowireCapableBeanFactory().autowireBean(this); // Our DSL allows to grant access to URLs defined by permitAllPattern in a property // and then requires authentication for any other request http.authorizeRequests().antMatchers(permitAllPattern).permitAll().anyRequest().authenticated(); if (http.getConfigurer(FormLoginConfigurer.class) == null) { // only apply if formLogin() was not invoked by the user // this is a way of providing a default, but allow users to override http.formLogin().loginPage(loginPage); } }
From source file:cn.timeoff.config.hackspring.WebSecurityConfigurerAdapter.java
public void init(final WebSecurity web) throws Exception { final HttpSecurity http = getHttp(); web.addSecurityFilterChainBuilder(http).postBuildAction(new Runnable() { public void run() { FilterSecurityInterceptor securityInterceptor = http .getSharedObject(FilterSecurityInterceptor.class); web.securityInterceptor(securityInterceptor); }//from w w w .j a va2 s .co m }); }