Merge branch 'validauth' into jpa
This commit is contained in:
commit
e2581cd127
|
@ -24,9 +24,15 @@ package org.apache.archiva.redback.authentication;
|
||||||
public abstract class AbstractAuthenticator
|
public abstract class AbstractAuthenticator
|
||||||
implements Authenticator
|
implements Authenticator
|
||||||
{
|
{
|
||||||
|
protected boolean valid = false;
|
||||||
|
|
||||||
public void initialize()
|
public void initialize()
|
||||||
throws AuthenticationException
|
throws AuthenticationException
|
||||||
{
|
{
|
||||||
// no op
|
valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
return valid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,4 +38,6 @@ public interface Authenticator
|
||||||
throws AccountLockedException, AuthenticationException, MustChangePasswordException;
|
throws AccountLockedException, AuthenticationException, MustChangePasswordException;
|
||||||
|
|
||||||
void initialize() throws AuthenticationException;
|
void initialize() throws AuthenticationException;
|
||||||
|
|
||||||
|
boolean isValid();
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class DefaultAuthenticationManager
|
||||||
List<AuthenticationFailureCause> authnResultErrors = new ArrayList<AuthenticationFailureCause>();
|
List<AuthenticationFailureCause> authnResultErrors = new ArrayList<AuthenticationFailureCause>();
|
||||||
for ( Authenticator authenticator : authenticators )
|
for ( Authenticator authenticator : authenticators )
|
||||||
{
|
{
|
||||||
if ( authenticator.supportsDataSource( source ) )
|
if ( authenticator.isValid() && authenticator.supportsDataSource( source ) )
|
||||||
{
|
{
|
||||||
AuthenticationResult authResult = authenticator.authenticate( source );
|
AuthenticationResult authResult = authenticator.authenticate( source );
|
||||||
List<AuthenticationFailureCause> authenticationFailureCauses =
|
List<AuthenticationFailureCause> authenticationFailureCauses =
|
||||||
|
|
|
@ -208,4 +208,9 @@ public class LdapBindAuthenticator
|
||||||
log.warn( "skip exception closing naming search result {}", e.getMessage() );
|
log.warn( "skip exception closing naming search result {}", e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
return connectionFactory.isValid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.UserConfiguration;
|
||||||
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
|
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
@ -41,6 +43,8 @@ public class ConfigurableLdapConnectionFactory
|
||||||
implements LdapConnectionFactory
|
implements LdapConnectionFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final Logger log = LoggerFactory.getLogger(ConfigurableLdapConnectionFactory.class);
|
||||||
|
|
||||||
private String hostname;
|
private String hostname;
|
||||||
|
|
||||||
private int port;
|
private int port;
|
||||||
|
@ -61,6 +65,8 @@ public class ConfigurableLdapConnectionFactory
|
||||||
|
|
||||||
private LdapConnectionConfiguration ldapConnectionConfiguration;
|
private LdapConnectionConfiguration ldapConnectionConfiguration;
|
||||||
|
|
||||||
|
private boolean valid = false;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named(value = "userConfiguration#default")
|
@Named(value = "userConfiguration#default")
|
||||||
|
@ -90,10 +96,11 @@ public class ConfigurableLdapConnectionFactory
|
||||||
ldapConnectionConfiguration.setAuthenticationMethod(
|
ldapConnectionConfiguration.setAuthenticationMethod(
|
||||||
userConf.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, authenticationMethod ) );
|
userConf.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, authenticationMethod ) );
|
||||||
ldapConnectionConfiguration.setExtraProperties( extraProperties );
|
ldapConnectionConfiguration.setExtraProperties( extraProperties );
|
||||||
|
valid = true;
|
||||||
}
|
}
|
||||||
catch ( InvalidNameException e )
|
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;
|
this.userConf = userConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,4 +51,6 @@ public interface LdapConnectionFactory
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
|
public boolean isValid();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue