You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pr...@apache.org on 2018/06/08 05:40:30 UTC

zeppelin git commit: [HOTFIX][ZEPPELIN-3526] fix when no shiro.ini exists

Repository: zeppelin
Updated Branches:
  refs/heads/master b06e97c97 -> 9fbcacf5c


[HOTFIX][ZEPPELIN-3526] fix when no shiro.ini exists

This is a side effect of ZEPPELIN-3526, occurs when there's no shiro.ini in the classpath.

[Hot Fix]

* CI should be green

* Does the licenses files need update? n/a
* Is there breaking changes for older versions? n/a
* Does this needs documentation? n/a

Author: Prabhjyot Singh <pr...@gmail.com>

Closes #3011 from prabhjyotsingh/hotfix/ZEPPELIN-3526 and squashes the following commits:

ac6565cd3 [Prabhjyot Singh] fix ZEPPELIN-3526 when no shiro.ini exists

Change-Id: I5016e293eeec17e44be29dbf7f2668ec542a8dfa


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/9fbcacf5
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/9fbcacf5
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/9fbcacf5

Branch: refs/heads/master
Commit: 9fbcacf5c528292754ce17d5b1eaab9581770583
Parents: b06e97c
Author: Prabhjyot Singh <pr...@gmail.com>
Authored: Fri Jun 8 09:53:49 2018 +0530
Committer: Prabhjyot Singh <pr...@gmail.com>
Committed: Fri Jun 8 11:10:24 2018 +0530

----------------------------------------------------------------------
 .../apache/zeppelin/server/ZeppelinServer.java  | 31 ++++++++++++--------
 1 file changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9fbcacf5/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
index b64636d..3e92a9a 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
@@ -18,6 +18,7 @@ package org.apache.zeppelin.server;
 
 import java.util.Collection;
 import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.UnavailableSecurityManagerException;
 import org.apache.shiro.realm.Realm;
 import org.apache.shiro.realm.text.IniRealm;
 import org.apache.shiro.web.env.EnvironmentLoaderListener;
@@ -102,19 +103,25 @@ public class ZeppelinServer extends Application {
 
   public ZeppelinServer() throws Exception {
     ZeppelinConfiguration conf = ZeppelinConfiguration.create();
-    Collection<Realm> realms = ((DefaultWebSecurityManager) org.apache.shiro.SecurityUtils
-        .getSecurityManager()).getRealms();
-    if (realms.size() > 1) {
-      Boolean isIniRealmEnabled = false;
-      for (Object realm : realms) {
-        if (realm instanceof IniRealm && ((IniRealm) realm).getIni().get("users") != null) {
-          isIniRealmEnabled = true;
-          break;
+    if (conf.getShiroPath().length() > 0) {
+      try {
+        Collection<Realm> realms = ((DefaultWebSecurityManager) org.apache.shiro.SecurityUtils
+            .getSecurityManager()).getRealms();
+        if (realms.size() > 1) {
+          Boolean isIniRealmEnabled = false;
+          for (Object realm : realms) {
+            if (realm instanceof IniRealm && ((IniRealm) realm).getIni().get("users") != null) {
+              isIniRealmEnabled = true;
+              break;
+            }
+          }
+          if (isIniRealmEnabled) {
+            throw new Exception("IniRealm/password based auth mechanisms should be exclusive. "
+                + "Consider removing [users] block from shiro.ini");
+          }
         }
-      }
-      if (isIniRealmEnabled) {
-        throw new Exception("IniRealm/password based auth mechanisms should be exclusive. "
-            + "Consider removing [users] block from shiro.ini");
+      } catch (UnavailableSecurityManagerException e) {
+        LOG.error("Failed to initialise shiro configuraion", e);
       }
     }