From ceb7b6f837cfe196fd1a9b51abbffe0c31ee7e71 Mon Sep 17 00:00:00 2001 From: bag_of_tricks Date: Wed, 14 Mar 2018 10:44:25 -0400 Subject: [PATCH] ZEPPELIN-3332 Zeppelin login fails with NPE if ldapRealm.authorizationEnabled is not set true Issue was introduced by pull https://github.com/apache/zeppelin/pull/2498 --- .../main/java/org/apache/zeppelin/utils/SecurityUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java b/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java index e24af20c3b8..41b5c250bda 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java @@ -56,6 +56,7 @@ public class SecurityUtils { private static boolean isEnabled = false; private static final Logger log = LoggerFactory.getLogger(SecurityUtils.class); + public static void setIsEnabled(boolean value) { isEnabled = value; } @@ -149,7 +150,9 @@ public static HashSet getRoles() { new SimplePrincipalCollection(subject.getPrincipal(), realm.getName()), ((LdapRealm) realm).getContextFactory() ); - roles = new HashSet<>(auth.getRoles()); + if (auth != null) { + roles = new HashSet<>(auth.getRoles()); + } } catch (NamingException e) { log.error("Can't fetch roles", e); }