本文整理匯總了Java中org.springframework.security.config.annotation.web.builders.HttpSecurity.getSharedObject方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpSecurity.getSharedObject方法的具體用法?Java HttpSecurity.getSharedObject怎麽用?Java HttpSecurity.getSharedObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.config.annotation.web.builders.HttpSecurity
的用法示例。
在下文中一共展示了HttpSecurity.getSharedObject方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import org.springframework.security.config.annotation.web.builders.HttpSecurity; //導入方法依賴的package包/類
@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
}
示例2: configure
import org.springframework.security.config.annotation.web.builders.HttpSecurity; //導入方法依賴的package包/類
/**
* {@inheritDoc}
* In addition {@link #configure(HttpSecurity)} will call {@link #init(HttpSecurity)} in order to be used without
* {@link HttpSecurity#apply(SecurityConfigurerAdapter)} usage, related to
* https://github.com/spring-projects/spring-security/issues/4422 issue.
*
* Thus when using
*
* <pre>{@code
* CasHttpSecurityConfigurer.cas().configure(http);
* }</pre>
*
* {@code configure(http)} will also call {@link CasHttpSecurityConfigurerAdapter#init(HttpSecurity)} and no need
* to write following duplicates
*
* <pre>{@code
* CasHttpSecurityConfigurer.cas().init(http);
* CasHttpSecurityConfigurer.cas().configure(http);
* }</pre>
*/
@Override
public void configure(HttpSecurity http) throws Exception {
init(http);
ApplicationContext context = http.getSharedObject(ApplicationContext.class);
getCasHttpSecurityConfigurerAdapter(context).configure(http);
}
示例3: init
import org.springframework.security.config.annotation.web.builders.HttpSecurity; //導入方法依賴的package包/類
/**
* {@inheritDoc}
* @deprecated use {@link #configure(HttpSecurity)} instead.
* Will not be removed but until this issue was not treat
* https://github.com/spring-projects/spring-security/issues/4422 I still prefer using this
* {@link SecurityConfigurerAdapter} directly like following
*
* <pre>{@code
* CasHttpSecurityConfigurer.cas().configure(http);
* }</pre>
*
* instead of
*
* <pre>{@code
* http.apply(CasHttpSecurityConfigurer.cas());
* }</pre>
*/
@Override
@Deprecated
public void init(HttpSecurity http) throws Exception {
if (!isInitialized) {
ApplicationContext context = http.getSharedObject(ApplicationContext.class);
getCasHttpSecurityConfigurerAdapter(context).init(http);
isInitialized = true;
}
}