Spring Security) Mit X. 509-Zertifikat

Bin ich langsam wahnsinnig zu werden, versucht zu konfigurieren, Spring Security 3.0.0 zum sichern der Anwendung.

Habe ich konfiguriert den server (jetty) Anforderung der client-Authentifizierung (unter Verwendung einer smart-card). Aber ich kann nicht scheinen, um die applicationContext-security.xml und UserDetailsService Umsetzung.

Erste, von der Anwendung Kontext-Datei:

<?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"/>

Den UserDetailsService sieht wie folgt aus:

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;

}

}

Die Anwendung hat eine "front page" mit Login-Taste, so dass der Zugriff auf, die, sollten Sie nicht verlangen, jede Art von Authentifizierung.

Jede Hilfe ist willkommen.

InformationsquelleAutor Jason | 2010-02-10
Schreibe einen Kommentar