mirror of https://github.com/apache/archiva.git
Adding isValid() method to authentication classes
This commit is contained in:
parent
1fd9c951e1
commit
0cc2733ca0
|
@ -192,7 +192,12 @@ public class DefaultRedbackRuntimeConfigurationService
|
||||||
|
|
||||||
for ( Authenticator authenticator : authenticators )
|
for ( Authenticator authenticator : authenticators )
|
||||||
{
|
{
|
||||||
authenticator.initialize();
|
try {
|
||||||
|
log.debug("Initializing authenticatior "+authenticator.getId());
|
||||||
|
authenticator.initialize();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Initialization of authenticator failed "+authenticator.getId(),e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// users cache
|
// users cache
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.archiva.admin.model.beans.LdapConfiguration;
|
||||||
import org.apache.archiva.admin.model.runtime.RedbackRuntimeConfigurationAdmin;
|
import org.apache.archiva.admin.model.runtime.RedbackRuntimeConfigurationAdmin;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.ConfigurableLdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.ConfigurableLdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration;
|
||||||
|
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;
|
||||||
|
@ -40,6 +42,10 @@ public class ArchivaLdapConnectionFactory
|
||||||
extends ConfigurableLdapConnectionFactory
|
extends ConfigurableLdapConnectionFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final Logger log = LoggerFactory.getLogger(ArchivaLdapConnectionFactory.class);
|
||||||
|
|
||||||
|
private boolean valid = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin;
|
private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin;
|
||||||
|
|
||||||
|
@ -63,10 +69,12 @@ public class ArchivaLdapConnectionFactory
|
||||||
ldapConnectionConfiguration.setPassword( ldapConfiguration.getPassword() );
|
ldapConnectionConfiguration.setPassword( ldapConfiguration.getPassword() );
|
||||||
ldapConnectionConfiguration.setAuthenticationMethod( ldapConfiguration.getAuthenticationMethod() );
|
ldapConnectionConfiguration.setAuthenticationMethod( ldapConfiguration.getAuthenticationMethod() );
|
||||||
ldapConnectionConfiguration.setExtraProperties( toProperties( ldapConfiguration.getExtraProperties() ) );
|
ldapConnectionConfiguration.setExtraProperties( toProperties( ldapConfiguration.getExtraProperties() ) );
|
||||||
|
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);
|
||||||
|
// throw new RuntimeException( "Error while initializing connection factory.", e );
|
||||||
}
|
}
|
||||||
catch ( RepositoryAdminException e )
|
catch ( RepositoryAdminException e )
|
||||||
{
|
{
|
||||||
|
@ -99,4 +107,9 @@ public class ArchivaLdapConnectionFactory
|
||||||
{
|
{
|
||||||
this.ldapConnectionConfiguration = ldapConnectionConfiguration;
|
this.ldapConnectionConfiguration = ldapConnectionConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ public class ArchivaUserManagerAuthenticator
|
||||||
|
|
||||||
private List<UserManager> userManagers;
|
private List<UserManager> userManagers;
|
||||||
|
|
||||||
|
private boolean valid = false;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@Override
|
@Override
|
||||||
public void initialize()
|
public void initialize()
|
||||||
|
@ -83,10 +85,12 @@ public class ArchivaUserManagerAuthenticator
|
||||||
{
|
{
|
||||||
userManagers.add( applicationContext.getBean( "userManager#" + beanId, UserManager.class ) );
|
userManagers.add( applicationContext.getBean( "userManager#" + beanId, UserManager.class ) );
|
||||||
}
|
}
|
||||||
|
valid=true;
|
||||||
}
|
}
|
||||||
catch ( RepositoryAdminException e )
|
catch ( RepositoryAdminException e )
|
||||||
{
|
{
|
||||||
throw new AuthenticationException( e.getMessage(), e );
|
log.error("Error during repository initialization "+e.getMessage(),e);
|
||||||
|
// throw new AuthenticationException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,4 +229,8 @@ public class ArchivaUserManagerAuthenticator
|
||||||
{
|
{
|
||||||
return "ArchivaUserManagerAuthenticator";
|
return "ArchivaUserManagerAuthenticator";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue