[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-30 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r340954854
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
 ##
 @@ -298,6 +301,27 @@ public void contextDestroyed(ServletContextEvent 
servletContextEvent) {}
 }
   }
 
+  private static void validateShiroIni() throws Exception {
+if (conf.getShiroPath().length() > 0) {
+  Ini ini = new Ini();
+  ini.loadFromPath(conf.getShiroPath());
+
+  Ini.Section usersSection = ini.get("users");
+  String activeDirectoryRealm = ini.getSectionProperty("main", 
"activeDirectoryRealm");
 
 Review comment:
   > This is just a name user can choose it to be anything, for example 
activeDirectoryRealm user can choose to write this as just adRealm
   
   I thought these properties names are constant means users can not change it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-24 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r338405781
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.Collection;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initializing");
+init(conf);
+  }
+
+  public void init(ZeppelinConfiguration conf) throws Exception {
+if (conf.getShiroPath().length() > 0) {
+  loadSecurityManager();
+  validateRealms();
+}
+LOGGER.info("ShiroValidationService is initialized.");
+  }
+
+  private synchronized void loadSecurityManager() throws Exception {
+long waitTime = 500;
+Integer nosOfTry = 0;
 
 Review comment:
   Ok. Then there is no need to load SecurityManager and also that will help to 
avoid the polling approach, right? 
   I am just thinking about test-cases behavior after these changes.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-22 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r337517383
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.Collection;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initializing");
+init(conf);
+  }
+
+  public void init(ZeppelinConfiguration conf) throws Exception {
+if (conf.getShiroPath().length() > 0) {
+  loadSecurityManager();
+  validateRealms();
+}
+LOGGER.info("ShiroValidationService is initialized.");
+  }
+
+  private synchronized void loadSecurityManager() throws Exception {
+long waitTime = 500;
+Integer nosOfTry = 0;
 
 Review comment:
   Yes, we can do that but the Shiro environment (as well as SecurityManager) 
gets initialized when the jetty server start method gets invoked, till that 
time SecurityManager is null. for the same reason, I have used polling.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-22 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r337506028
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.Collection;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initializing");
+init(conf);
+  }
+
+  public void init(ZeppelinConfiguration conf) throws Exception {
+if (conf.getShiroPath().length() > 0) {
+  loadSecurityManager();
+  validateRealms();
+}
+LOGGER.info("ShiroValidationService is initialized.");
+  }
+
+  private synchronized void loadSecurityManager() throws Exception {
+long waitTime = 500;
+Integer nosOfTry = 0;
 
 Review comment:
   Initializing it from the [public static 
main](https://github.com/apache/zeppelin/pull/3488/files#diff-3477d79f3012453f20c3727ec60338e9R156)
 only by Injecting as a service.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-22 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r337506028
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.Collection;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initializing");
+init(conf);
+  }
+
+  public void init(ZeppelinConfiguration conf) throws Exception {
+if (conf.getShiroPath().length() > 0) {
+  loadSecurityManager();
+  validateRealms();
+}
+LOGGER.info("ShiroValidationService is initialized.");
+  }
+
+  private synchronized void loadSecurityManager() throws Exception {
+long waitTime = 500;
+Integer nosOfTry = 0;
 
 Review comment:
   Initializing it from the [public static main](url) only by Injecting as a 
service.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-16 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r335319441
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.*;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  private final ZeppelinConfiguration conf;
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initialized");
+this.conf = conf;
+if (conf.getShiroPath().length() > 0) {
+  try {
+Collection realms =
+((DefaultWebSecurityManager) 
org.apache.shiro.SecurityUtils.getSecurityManager())
+.getRealms();
+if (realms != null && realms.size() > 1) {
 
 Review comment:
   When realms are null than application should not start. also added retry 
logic when "UnavailableSecurityManagerException" is thrown.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-16 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r335319441
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.*;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  private final ZeppelinConfiguration conf;
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initialized");
+this.conf = conf;
+if (conf.getShiroPath().length() > 0) {
+  try {
+Collection realms =
+((DefaultWebSecurityManager) 
org.apache.shiro.SecurityUtils.getSecurityManager())
+.getRealms();
+if (realms != null && realms.size() > 1) {
 
 Review comment:
   When SecurityManager is not accessible then it will be null and yes 
application will start by logging the error message, but sometimes only 
SecurityManager is not accessible so planning to add 3sec delay so it will be 
always accessible or by adding retry(2-3 time) logic.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-16 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r335319441
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.*;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  private final ZeppelinConfiguration conf;
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initialized");
+this.conf = conf;
+if (conf.getShiroPath().length() > 0) {
+  try {
+Collection realms =
+((DefaultWebSecurityManager) 
org.apache.shiro.SecurityUtils.getSecurityManager())
+.getRealms();
+if (realms != null && realms.size() > 1) {
 
 Review comment:
   When SecurityManager is not accessible then it will be null and yes 
application will start by logging the error message, but sometimes only it is 
SecurityManager is not accessible so planning to add 3sec delay so it will be 
always accessible or by adding retry(2-3 time) logic.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-16 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r335319441
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.*;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  private final ZeppelinConfiguration conf;
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initialized");
+this.conf = conf;
+if (conf.getShiroPath().length() > 0) {
+  try {
+Collection realms =
+((DefaultWebSecurityManager) 
org.apache.shiro.SecurityUtils.getSecurityManager())
+.getRealms();
+if (realms != null && realms.size() > 1) {
 
 Review comment:
   When SecurityManager is not accessible then it will be null and yes 
application will start by logging the error message.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zeppelin] bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] Zeppelin should stop/die/etc when can't create/access notebook repo

2019-10-15 Thread GitBox
bhavikpatel9977 commented on a change in pull request #3488: [ZEPPELIN-4356] 
Zeppelin should stop/die/etc when can't create/access notebook repo
URL: https://github.com/apache/zeppelin/pull/3488#discussion_r335279842
 
 

 ##
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/service/ShiroValidationService.java
 ##
 @@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zeppelin.service;
+
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.util.*;
+
+/**
+ * ShiroValidationService to validate shiro config
+ */
+public class ShiroValidationService {
+
+  private final Logger LOGGER = 
LoggerFactory.getLogger(ShiroValidationService.class);
+
+  private final ZeppelinConfiguration conf;
+
+  @Inject
+  public ShiroValidationService(ZeppelinConfiguration conf) throws Exception {
+LOGGER.info("ShiroValidationService is initialized");
+this.conf = conf;
+if (conf.getShiroPath().length() > 0) {
+  try {
+Collection realms =
+((DefaultWebSecurityManager) 
org.apache.shiro.SecurityUtils.getSecurityManager())
+.getRealms();
+if (realms != null && realms.size() > 1) {
 
 Review comment:
   Size will be either one or greater than one, it will not be zero and if 
SecurityManager is not accessible than it will throw 
'_UnavailableSecurityManagerException_'


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services