LDAP 認証を使用する Java EE Web アプリケーションがあります。Spring セキュリティを使用して、次のコードで LDAP に接続します。
<bean id="ldapContextSource" class="com.myapp.security.authentication.MySecurityContextSource">
<constructor-arg index="0" value="${ldap.url}" />
<constructor-arg index="1" ref="userConnexion" />
</bean>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider ref="ldapAuthProvider" />
</security:authentication-manager>
<bean id="userConnexion" class="com.myapp.util.security.WebsphereCredentials">
<constructor-arg value="${ldap.authJndiAlias}" />
</bean>
<bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="ldapContextSource" />
<property name="userSearch" ref="userSearch" />
</bean>
</constructor-arg>
<constructor-arg>
<bean class="com.myapp.security.authentication.MyAuthoritiesPopulator" >
<property name="userService" ref="userService" />
</bean>
</constructor-arg>
<property name="userDetailsContextMapper" ref="myUserDetailsContextMapper"/>
<property name="hideUserNotFoundExceptions" value="false" />
</bean>
実際、私の Beanは、この応答のようにWebsphereCredentials
WebSphere プライベート クラスを使用します: Websphere 6.1 にデプロイされた EJB から認証エイリアスにアクセスする方法WSMappingCallbackHandlerFactory
Websphere の公式ドキュメントで確認できます: http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae %2Frsec_pluginj2c.html
しかし、私はそれを望んでいません:
- 私のアプリケーションは、WebSphere インスタンスのすべての JAAS ログインにアクセスできると思います (よくわかりません)。
- このクラスは巨大な IBM クライアント ライブラリ com.ibm.ws.admin.client-7.0.0.jar (42 Mo) で定義されています => コンパイルが遅く、私のエンタープライズ ネクサスには存在しません
- ポータブルではなく、標準ではありません
WebsphereCredentials
参考までに、コンストラクターを次のように定義します。
Map<String, String> map = new HashMap<String, String>();
map.put(Constants.MAPPING_ALIAS, this.jndiAlias);
Subject subject;
try {
CallbackHandler callbackHandler = WSMappingCallbackHandlerFactory.getInstance().getCallbackHandler(map, null);
LoginContext lc = new LoginContext("DefaultPrincipalMapping", callbackHandler);
lc.login();
subject = lc.getSubject();
} catch (NotImplementedException e) {
throw new EfritTechnicalException(EfritTechnicalExceptionEnum.LOGIN_CREDENTIAL_PROBLEM, e);
} catch (LoginException e) {
throw new EfritTechnicalException(EfritTechnicalExceptionEnum.LOGIN_CREDENTIAL_PROBLEM, e);
}
PasswordCredential cred = (PasswordCredential) subject.getPrivateCredentials().toArray()[0];
this.user = cred.getUserName();
this.password = String.valueOf(cred.getPassword());
Spring セキュリティだけを使用して、この依存関係を削除する方法はありますか?
http://static.springsource.org/spring-security/site/docs/3.1.x/reference/jaas.htmlとhttp://static.springsource.org/spring-security/siteを組み合わせる方法がわかりません/docs/3.1.x/reference/ldap.html .
多分私は自分のアプローチを完全に変えて別の方法を使わなければならないのでしょうか?