Repository: archiva
Updated Branches:
  refs/heads/master c4596cb59 -> 3fe100086


Adding isValid() method to authentication classes


Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/3fe10008
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/3fe10008
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/3fe10008

Branch: refs/heads/master
Commit: 3fe1000865bcab2e210b8482fa9f79ce5fd24782
Parents: c4596cb
Author: Martin Stockhammer <marti...@apache.org>
Authored: Tue Oct 4 20:52:25 2016 +0200
Committer: Martin Stockhammer <marti...@apache.org>
Committed: Sun Oct 16 17:18:23 2016 +0200

----------------------------------------------------------------------
 .../DefaultRedbackRuntimeConfigurationService.java   |  7 ++++++-
 .../runtime/ldap/ArchivaLdapConnectionFactory.java   | 15 ++++++++++++++-
 .../security/ArchivaUserManagerAuthenticator.java    | 10 +++++++++-
 3 files changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/3fe10008/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
----------------------------------------------------------------------
diff --git 
a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
 
b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
index e319c36..0284bb8 100644
--- 
a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
+++ 
b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
@@ -192,7 +192,12 @@ public class DefaultRedbackRuntimeConfigurationService
 
             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

http://git-wip-us.apache.org/repos/asf/archiva/blob/3fe10008/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ldap/ArchivaLdapConnectionFactory.java
----------------------------------------------------------------------
diff --git 
a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ldap/ArchivaLdapConnectionFactory.java
 
b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ldap/ArchivaLdapConnectionFactory.java
index cd15b1e..45945f1 100644
--- 
a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ldap/ArchivaLdapConnectionFactory.java
+++ 
b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ldap/ArchivaLdapConnectionFactory.java
@@ -23,6 +23,8 @@ import org.apache.archiva.admin.model.beans.LdapConfiguration;
 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.LdapConnectionConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
@@ -40,6 +42,10 @@ public class ArchivaLdapConnectionFactory
     extends ConfigurableLdapConnectionFactory
 {
 
+    private final Logger log = 
LoggerFactory.getLogger(ArchivaLdapConnectionFactory.class);
+
+    private boolean valid = false;
+
     @Inject
     private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin;
 
@@ -63,10 +69,12 @@ public class ArchivaLdapConnectionFactory
             ldapConnectionConfiguration.setPassword( 
ldapConfiguration.getPassword() );
             ldapConnectionConfiguration.setAuthenticationMethod( 
ldapConfiguration.getAuthenticationMethod() );
             ldapConnectionConfiguration.setExtraProperties( toProperties( 
ldapConfiguration.getExtraProperties() ) );
+            valid=true;
         }
         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 )
         {
@@ -99,4 +107,9 @@ public class ArchivaLdapConnectionFactory
     {
         this.ldapConnectionConfiguration = ldapConnectionConfiguration;
     }
+
+    @Override
+    public boolean isValid() {
+        return valid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/archiva/blob/3fe10008/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java
----------------------------------------------------------------------
diff --git 
a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java
 
b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java
index 4d93253..0a74e39 100644
--- 
a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java
+++ 
b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java
@@ -67,6 +67,8 @@ public class ArchivaUserManagerAuthenticator
 
     private List<UserManager> userManagers;
 
+    private boolean valid = false;
+
     @PostConstruct
     @Override
     public void initialize()
@@ -83,10 +85,12 @@ public class ArchivaUserManagerAuthenticator
             {
                 userManagers.add( applicationContext.getBean( "userManager#" + 
beanId, UserManager.class ) );
             }
+            valid=true;
         }
         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";
     }
+
+    public boolean isValid() {
+        return valid;
+    }
 }

Reply via email to