UPDATE
Having done a little bit of digging, I discovered that the Java Config provides a very easy way to get at the X509Certificate with a simple implementation of the AuthenticationUserDetailsService:
@Configuration
protected static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**")
.x509()
.authenticationUserDetailsService(new X509AuthenticatedUserDetailsService());
}
protected static class X509AuthenticatedUserDetailsService implements AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> {
@Override
public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token)
throws UsernameNotFoundException {
X509Certificate certificate = (X509Certificate)token.getCredentials();
// do your extra checking here...
// add granted authorities, etc.
Collection<GrantedAuthority> authorities = Collections.EMPTY_LIST;
// generate your user how you deem fit
User user = new User(certificate.getSubjectX500Principal().getName(), null, authorities);
return user;
}
}
}
Note that in the loadUserDetails method you do the same thing really as you would do when implementing UserDetailsService with the exception that this method takes the entire Authentication object.
ORIGINAL
I'm not sure if this is the intended way; however, the X509Certificate is passed along via the authentication token generated in the X509AuthenticationFilter. Invoking PreAuthenticatedAuthenticationToken#getCredentials should get the certificate for you.
Digging a bit through the API shows that the PreAuthenticatedAuthenticationProvider could be configured with a custom UserDetailsChecker and AuthenticatedUserDetailsService. These may be sufficient for you to extract the details from the X509Certificate and verify them.