You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2016/10/03 17:38:44 UTC
archiva-redback-core git commit: Adding flag for authenticator to
avoid autowiring exceptions
Repository: archiva-redback-core
Updated Branches:
refs/heads/validauth [created] 7e83bebce
Adding flag for authenticator to avoid autowiring exceptions
Adds a isValid() method to the authenticator to avoid exceptions during
initialization.
Project: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/commit/7e83bebc
Tree: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/tree/7e83bebc
Diff: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/diff/7e83bebc
Branch: refs/heads/validauth
Commit: 7e83bebcec58429d9eb3ae9573280db9676a2cf7
Parents: d17c6ff
Author: Martin Stockhammer <ma...@apache.org>
Authored: Mon Oct 3 19:36:13 2016 +0200
Committer: Martin Stockhammer <ma...@apache.org>
Committed: Mon Oct 3 19:36:13 2016 +0200
----------------------------------------------------------------------
.../redback/authentication/AbstractAuthenticator.java | 8 +++++++-
.../archiva/redback/authentication/Authenticator.java | 2 ++
.../authentication/DefaultAuthenticationManager.java | 2 +-
.../authentication/ldap/LdapBindAuthenticator.java | 5 +++++
.../connection/ConfigurableLdapConnectionFactory.java | 13 ++++++++++++-
.../common/ldap/connection/LdapConnectionFactory.java | 2 ++
6 files changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/7e83bebc/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AbstractAuthenticator.java
----------------------------------------------------------------------
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AbstractAuthenticator.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AbstractAuthenticator.java
index 1c80bc3..80d1918 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AbstractAuthenticator.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AbstractAuthenticator.java
@@ -24,9 +24,15 @@ package org.apache.archiva.redback.authentication;
public abstract class AbstractAuthenticator
implements Authenticator
{
+ protected boolean valid = false;
+
public void initialize()
throws AuthenticationException
{
- // no op
+ valid = true;
+ }
+
+ public boolean isValid() {
+ return valid;
}
}
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/7e83bebc/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/Authenticator.java
----------------------------------------------------------------------
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/Authenticator.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/Authenticator.java
index 6efe11c..ce99757 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/Authenticator.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/Authenticator.java
@@ -38,4 +38,6 @@ public interface Authenticator
throws AccountLockedException, AuthenticationException, MustChangePasswordException;
void initialize() throws AuthenticationException;
+
+ boolean isValid();
}
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/7e83bebc/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/DefaultAuthenticationManager.java
----------------------------------------------------------------------
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 d5342bf..bda3276 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
@@ -92,7 +92,7 @@ public class DefaultAuthenticationManager
List<AuthenticationFailureCause> authnResultErrors = new ArrayList<AuthenticationFailureCause>();
for ( Authenticator authenticator : authenticators )
{
- if ( authenticator.supportsDataSource( source ) )
+ if ( authenticator.isValid() && authenticator.supportsDataSource( source ) )
{
AuthenticationResult authResult = authenticator.authenticate( source );
List<AuthenticationFailureCause> authenticationFailureCauses =
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/7e83bebc/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
----------------------------------------------------------------------
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 648b2f9..fedae34 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
@@ -208,4 +208,9 @@ public class LdapBindAuthenticator
log.warn( "skip exception closing naming search result {}", e.getMessage() );
}
}
+
+ @Override
+ public boolean isValid() {
+ return connectionFactory.isValid();
+ }
}
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/7e83bebc/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java
----------------------------------------------------------------------
diff --git a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java
index 4aab487..2340cc5 100644
--- a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java
+++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java
@@ -21,6 +21,8 @@ package org.apache.archiva.redback.common.ldap.connection;
import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@@ -41,6 +43,8 @@ public class ConfigurableLdapConnectionFactory
implements LdapConnectionFactory
{
+ private final Logger log = LoggerFactory.getLogger(ConfigurableLdapConnectionFactory.class);
+
private String hostname;
private int port;
@@ -61,6 +65,8 @@ public class ConfigurableLdapConnectionFactory
private LdapConnectionConfiguration ldapConnectionConfiguration;
+ private boolean valid = false;
+
@Inject
@Named(value = "userConfiguration#default")
@@ -90,10 +96,11 @@ public class ConfigurableLdapConnectionFactory
ldapConnectionConfiguration.setAuthenticationMethod(
userConf.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, authenticationMethod ) );
ldapConnectionConfiguration.setExtraProperties( extraProperties );
+ valid = true;
}
catch ( InvalidNameException e )
{
- throw new RuntimeException( "Error while initializing connection factory.", e );
+ log.error("Error during initialization of LdapConnectionFactory "+e.getMessage(),e);
}
}
@@ -266,4 +273,8 @@ public class ConfigurableLdapConnectionFactory
{
this.userConf = userConf;
}
+
+ public boolean isValid() {
+ return valid;
+ }
}
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/7e83bebc/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/LdapConnectionFactory.java
----------------------------------------------------------------------
diff --git a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/LdapConnectionFactory.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/LdapConnectionFactory.java
index d81b3e2..4d6ec03 100644
--- a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/LdapConnectionFactory.java
+++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/LdapConnectionFactory.java
@@ -51,4 +51,6 @@ public interface LdapConnectionFactory
void initialize();
+ public boolean isValid();
+
}