]> source.dussan.org Git - sonarqube.git/commitdiff
Fix authentication during db upgrade
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 6 May 2013 08:07:45 +0000 (10:07 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 6 May 2013 08:08:12 +0000 (10:08 +0200)
sonar-server/src/main/webapp/WEB-INF/lib/need_authentication.rb

index 914ff44846018db859117fbf1bb283d3a27f0c73..8750a0691bfef3ec9154b1f888722ba2e3c82c00 100644 (file)
@@ -180,8 +180,12 @@ class RealmFactory
   def self.realm
     if @@realm.nil?
       realm_factory = Api::Utils.java_facade.getCoreComponentByClassname('org.sonar.server.ui.SecurityRealmFactory')
-      component = realm_factory.getRealm()
-      @@realm = component ? PluginRealm.new(component) : DefaultRealm.new
+      if realm_factory
+        component = realm_factory.getRealm()
+        @@realm = component ? PluginRealm.new(component) : DefaultRealm.new
+      else
+        # SecurityRealmFactory is not yet available in pico, for example during db upgrade
+      end
     end
     @@realm
   end
@@ -213,11 +217,11 @@ module NeedAuthentication
           login = login.downcase
         end
 
-        RealmFactory.realm.authenticate?(login, password, servlet_request)
+        RealmFactory.realm.authenticate?(login, password, servlet_request) if RealmFactory.realm
       end
 
       def editable_password?
-        RealmFactory.realm.editable_password?
+        RealmFactory.realm && RealmFactory.realm.editable_password?
       end
     end
   end