當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpSecurity.getSharedObject方法代碼示例

本文整理匯總了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
}
 
開發者ID:juiser,項目名稱:juiser,代碼行數:16,代碼來源:JuiserAuthenticationFilterRegistrar.java

示例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);
}
 
開發者ID:kakawait,項目名稱:cas-security-spring-boot-starter,代碼行數:27,代碼來源:CasHttpSecurityConfigurer.java

示例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;
    }
}
 
開發者ID:kakawait,項目名稱:cas-security-spring-boot-starter,代碼行數:27,代碼來源:CasHttpSecurityConfigurer.java


注:本文中的org.springframework.security.config.annotation.web.builders.HttpSecurity.getSharedObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。