summaryrefslogtreecommitdiffstats
path: root/redback-authentication
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-12-04 15:07:13 +0000
committerOlivier Lamy <olamy@apache.org>2012-12-04 15:07:13 +0000
commit1d47163f9dab80e3c868d3d19d7a07ff84ef0d97 (patch)
tree9dd5dcff98af1cfab21cc59f3412984152d091c4 /redback-authentication
parenteed51a9447b1072ff739f9732cb659720fcf8485 (diff)
downloadarchiva-1d47163f9dab80e3c868d3d19d7a07ff84ef0d97.tar.gz
archiva-1d47163f9dab80e3c868d3d19d7a07ff84ef0d97.zip
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
Diffstat (limited to 'redback-authentication')
-rw-r--r--redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationConstants.java5
-rw-r--r--redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationResult.java1
-rw-r--r--redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/DefaultAuthenticationManager.java26
-rw-r--r--redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java3
4 files changed, 27 insertions, 8 deletions
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationConstants.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationConstants.java
index 35c9bfd7e..88e4d2b61 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationConstants.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationConstants.java
@@ -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";
+
}
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationResult.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationResult.java
index 90a4cf07e..2608959a4 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationResult.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationResult.java
@@ -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;
/**
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/DefaultAuthenticationManager.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/DefaultAuthenticationManager.java
index b05539b0f..85c6d5958 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/DefaultAuthenticationManager.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/DefaultAuthenticationManager.java
@@ -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() );
+ }
+ }
+
+
}
}
diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java b/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
index 56b86b13f..3269c1a77 100644
--- a/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
+++ b/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
@@ -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: