Hi
First - implement your own org.springframework.security.web.authentication.pr eauth.x509.X509PrincipalExtractor:
Code:
public class MySpecialX509PrincipalExtractor implements X509PrincipalExtractor
{
private static Pattern serialNumber = Pattern.compile("serialNumber=([^=,]*)", Pattern.CASE_INSENSITIVE);
public Object extractPrincipal(X509Certificate cert)
{
String name = cert.getSubjectDN().getName();
Matcher m = serialNumber.matcher(name);
if (!m.find())
throw new BadCredentialsException("There's no serialNumber field in provided certificate.");
return m.group(1);
}
}
Then you have to use it in Spring-Security config:
Code:
<http auto-config="false" entry-point-ref="formLogin" servlet-api-provision="false">
<!-- zasoby niechronione -->
<intercept-url pattern="/**/*.css" filters="none" />
...
<!-- custom X509 filter -->
<custom-filter position="X509_FILTER" ref="myX509AuthenticationFilter" />
</http>
...
<beans:bean id="myX509AuthenticationFilter" class="org.springframework.security.web.authentication.preauth.x509.X509AuthenticationFilter">
<beans:description>By default, X509 filter creates its own authManager with its own provider. Here we'll use a shared one</beans:description>
<beans:property name="authenticationManager" ref="authenticationManager" />
<beans:property name="principalExtractor">
<beans:bean class="MySpecialX509PrincipalExtractor" />
</beans:property>
</beans:bean>
It works for me 
regards
Grzegorz Grzybek