mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-03 20:09:18 +00:00
SEC-346: Fix. Added suggested change. Also some minor tidying up of comments etc.
This commit is contained in:
parent
8cb836c6cf
commit
301626fd6e
@ -18,6 +18,7 @@ package org.acegisecurity.providers.x509.populator;
|
|||||||
import org.acegisecurity.AcegiMessageSource;
|
import org.acegisecurity.AcegiMessageSource;
|
||||||
import org.acegisecurity.AuthenticationException;
|
import org.acegisecurity.AuthenticationException;
|
||||||
import org.acegisecurity.BadCredentialsException;
|
import org.acegisecurity.BadCredentialsException;
|
||||||
|
import org.acegisecurity.AuthenticationServiceException;
|
||||||
|
|
||||||
import org.acegisecurity.providers.x509.X509AuthoritiesPopulator;
|
import org.acegisecurity.providers.x509.X509AuthoritiesPopulator;
|
||||||
|
|
||||||
@ -79,8 +80,7 @@ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, In
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDetails getUserDetails(X509Certificate clientCert)
|
public UserDetails getUserDetails(X509Certificate clientCert) throws AuthenticationException {
|
||||||
throws AuthenticationException {
|
|
||||||
String subjectDN = clientCert.getSubjectDN().getName();
|
String subjectDN = clientCert.getSubjectDN().getName();
|
||||||
PatternMatcher matcher = new Perl5Matcher();
|
PatternMatcher matcher = new Perl5Matcher();
|
||||||
|
|
||||||
@ -97,7 +97,14 @@ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, In
|
|||||||
|
|
||||||
String userName = match.group(1);
|
String userName = match.group(1);
|
||||||
|
|
||||||
return this.userDetailsService.loadUserByUsername(userName);
|
UserDetails user = this.userDetailsService.loadUserByUsername(userName);
|
||||||
|
|
||||||
|
if (user == null) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"UserDetailsService returned null, which is an interface contract violation");
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessageSource(MessageSource messageSource) {
|
public void setMessageSource(MessageSource messageSource) {
|
||||||
@ -106,7 +113,8 @@ public class DaoX509AuthoritiesPopulator implements X509AuthoritiesPopulator, In
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the regular expression which will by used to extract the user name from the certificate's Subject
|
* Sets the regular expression which will by used to extract the user name from the certificate's Subject
|
||||||
* DN.<p>It should contain a single group; for example the default expression "CN=(.?)," matches the common
|
* DN.
|
||||||
|
* <p>It should contain a single group; for example the default expression "CN=(.?)," matches the common
|
||||||
* name field. So "CN=Jimi Hendrix, OU=..." will give a user name of "Jimi Hendrix".</p>
|
* name field. So "CN=Jimi Hendrix, OU=..." will give a user name of "Jimi Hendrix".</p>
|
||||||
* <p>The matches are case insensitive. So "emailAddress=(.?)," will match "EMAILADDRESS=jimi@hendrix.org,
|
* <p>The matches are case insensitive. So "emailAddress=(.?)," will match "EMAILADDRESS=jimi@hendrix.org,
|
||||||
* CN=..." giving a user name "jimi@hendrix.org"</p>
|
* CN=..." giving a user name "jimi@hendrix.org"</p>
|
||||||
|
@ -43,7 +43,6 @@ public class DaoX509AuthoritiesPopulatorTests extends TestCase {
|
|||||||
//~ Constructors ===================================================================================================
|
//~ Constructors ===================================================================================================
|
||||||
|
|
||||||
public DaoX509AuthoritiesPopulatorTests() {
|
public DaoX509AuthoritiesPopulatorTests() {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DaoX509AuthoritiesPopulatorTests(String arg0) {
|
public DaoX509AuthoritiesPopulatorTests(String arg0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user