アプリケーションを保護するために Spring Security 3.0.0 を構成しようとして、私はゆっくりと狂気に陥っています。
クライアント認証 (スマート カードを使用) を要求するようにサーバー (jetty) を構成しました。ただし、applicationContext-security.xml と UserDetailsService の実装を正しく取得できないようです。
まず、アプリケーション コンテキスト ファイルから:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<security:global-method-security secured-annotations="enabled" />
<security:http auto-config="true">
<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
<security:x509 subject-principal-regex="CN=(.*?)," user-service-ref="accountService" />
</security:http>
<bean id="accountService" class="com.app.service.AccountServiceImpl"/>
UserDetailsService は次のようになります。
public class AccountServiceImpl implements AccountService, UserDetailsService {
private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
private AccountDao accountDao;
@Autowired
public void setAccountDao(AccountDao accountDao) {
this.accountDao = accountDao;
}
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException, DataAccessException {
log.debug("called loadUserByUsername()");
System.out.println("called loadByUsername()");
Account result = accountDao.getByEdpi(s);
return result;
}
}
アプリケーションにはログイン ボタンのある「フロント ページ」があるため、そのページへのアクセスには、いかなる種類の認証も必要ありません。
どんな助けでも大歓迎です。