2016-12-03 14 views
1

私は、IBM Libertyプロファイル上で動作するスプリングセキュリティWebアプリケーションを実行しているspringmvcを実行しています。私はすべてを設定するJavaの設定を使用して(とweb.xml)。次のようにクラスWebSecurityConfigurerAdapterを拡張IBM LibertyプロファイルbasicRegistryとスプリングセキュリティ構成を接続する方法

は、私は、ユーザーの単純なリストを設定します。

@Autowired 
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception { 
auth.inMemoryAuthentication().withUser("bill").password("123456").roles("USER"); 
} 

私は私のコードでユーザー情報をしたくないので、私はserver.xmlにユーザー・レジストリーを移動したいですIBM Libertyプロファイル・サーバーのインストール。

<basicRegistry> 
    <user name="bill" password="123456"/> 
</basicRegistry> 

どうすれば設定できますか?

追加情報私は、耳と戦争モジュールを備えたマルチモジュールプロジェクトを使用しています。したがって、server.xmlの最後の行は

<enterpriseApplication id="hellospringEAR" location="hellospringEAR-00.00.0001-SNAPSHOT.ear" name="hellospringEAR"/> 

です。ヒントやアドバイスをいただければ幸いです。コンテナは

@Configuration 
@EnableWebSecurity 
public class SecurityConfig extends WebSecurityConfigurerAdapter { 
private static final Logger LOGGER = LoggerFactory.getLogger(SecurityConfig.class); 

@Autowired 
private ApplicationProperties appProperties; 

@Override 
protected void configure(final HttpSecurity http) throws Exception { 
    http.authorizeRequests() 
      .anyRequest().authenticated() 
      .and().httpBasic(); 

    if (appProperties.isContainerManaged()) { 
     LOGGER.info("using container managed"); 
     http.jee(); 
    } 
    http.csrf().disable() 
      .logout() 
      .permitAll(); 
} 
} 

詳細ここで(つまり、JEE()メソッドです)、セキュリティを管理するため

+0

チェックこの[記事](のhttp:// stackoverflowの.com/a/9847324/3701228)、SpringセキュリティとJava EEの統合を構成する方法について説明しています(サイトのminderについては説明していますが、プリンシパルは同じです。 – Gas

答えて

0

あなたは春のセキュリティのサポートを使用する必要があります。 Roles/Authorities not working in Websphere Liberty

+0

Davidに感謝します...しかし、私はプリンシパルのためにnullを得ます。私はまだ春にフィルターチェーン全体を把握しようとしています。 – Maarten

+0

LibertyPreAuthenticatedWebAuthenticatedDetailsS​​ourceのコードを私に提供できますか?どのように私はsecurityConfigクラスにそれを接続し、私はcom.ibm.websphere.securityライブラリの正しいmavenリポジトリ/依存関係を見つけるのに苦労します。 – Maarten

関連する問題