take of having all authenticator exceptions returned

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1416980 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-04 15:07:13 +00:00
parent eed51a9447
commit 1d47163f9d
4 changed files with 27 additions and 8 deletions

View File

@ -29,4 +29,9 @@ public class AuthenticationConstants
// for User Manager Authenticator
public static final String AUTHN_NO_SUCH_USER = "1";
/**
* @since 2.1
*/
public static final String AUTHN_RUNTIME_EXCEPTION = "2";
}

View File

@ -22,6 +22,7 @@ package org.apache.archiva.redback.authentication;
import org.apache.archiva.redback.users.User;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**

View File

@ -46,21 +46,21 @@ import java.util.Map;
public class DefaultAuthenticationManager
implements AuthenticationManager
{
private List<Authenticator> authenticators;
@Inject
private ApplicationContext applicationContext;
@SuppressWarnings("unchecked")
@PostConstruct
public void initialize()
{
this.authenticators = new ArrayList<Authenticator>
( applicationContext.getBeansOfType( Authenticator.class ).values() );
this.authenticators =
new ArrayList<Authenticator>( applicationContext.getBeansOfType( Authenticator.class ).values() );
}
public String getId()
{
return "Default Authentication Manager - " + this.getClass().getName() + " : managed authenticators - " +
@ -77,13 +77,13 @@ public class DefaultAuthenticationManager
}
// put AuthenticationResult exceptions in a map
Map<String,String> authnResultExceptionsMap = new HashMap<String,String>();
Map<String, String> authnResultExceptionsMap = new HashMap<String, String>();
for ( Authenticator authenticator : authenticators )
{
if ( authenticator.supportsDataSource( source ) )
{
AuthenticationResult authResult = authenticator.authenticate( source );
Map<String,String> exceptionsMap = authResult.getExceptionsMap();
Map<String, String> exceptionsMap = authResult.getExceptionsMap();
if ( authResult.isAuthenticated() )
{
@ -94,6 +94,16 @@ public class DefaultAuthenticationManager
{
authnResultExceptionsMap.putAll( exceptionsMap );
}
else
{
if ( authResult.getException() != null )
{
authnResultExceptionsMap.put( AuthenticationConstants.AUTHN_RUNTIME_EXCEPTION,
authResult.getException().getMessage() );
}
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.archiva.redback.authentication.ldap;
* under the License.
*/
import org.apache.archiva.redback.authentication.AuthenticationConstants;
import org.apache.archiva.redback.common.ldap.UserMapper;
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
import org.apache.archiva.redback.configuration.UserConfiguration;
@ -42,6 +43,8 @@ import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import java.util.HashMap;
import java.util.Map;
/**
* LdapBindAuthenticator: