You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2020/02/17 02:04:09 UTC

[zeppelin] branch master updated: [ZEPPELIN-4580] check the instance type rather than the class name

This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new c4adf54  [ZEPPELIN-4580] check the instance type rather than the class name
c4adf54 is described below

commit c4adf542154f206cea46a0184c7e464dbb482664
Author: Jeff Hammel <je...@leapyear.io>
AuthorDate: Fri Feb 14 08:35:17 2020 -0800

    [ZEPPELIN-4580] check the instance type rather than the class name
    
    ### What is this PR for?
    A few sentences describing the overall goals of the pull request's commits.
    First time? Check out the contributing guide - https://zeppelin.apache.org/contribution/contributions.html
    
    This checks if the realm is an instance of KnoxJwtRealm instead of checking for it by name to enable subclassing of KnoxJwtRealm.
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/
    * Put link here, and add [ZEPPELIN-*Jira number*] in PR title, eg. [ZEPPELIN-533]
    
    https://issues.apache.org/jira/browse/ZEPPELIN-4580
    
    ### How should this be tested?
    * First time? Setup Travis CI as described on https://zeppelin.apache.org/contribution/contributions.html#continuous-integration
    * Strongly recommended: add automated unit tests for any new or changed behavior
    * Outline any manual steps to test the PR here.
    
    CI run is at https://travis-ci.org/LeapYear/zeppelin-source/builds/650518752
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: Jeff Hammel <je...@leapyear.io>
    
    Closes #3647 from jeff-hammel-leapyear/jeff/ZEPPELIN-4580 and squashes the following commits:
    
    aca5badea [Jeff Hammel] [ZEPPELIN-4580] check the instance type rather than the class name
---
 .../src/main/java/org/apache/zeppelin/rest/LoginRestApi.java   | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java
index c7b563d..ef222a1 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java
@@ -149,11 +149,7 @@ public class LoginRestApi {
     Collection<Realm> realmsList = authenticationService.getRealmsList();
     if (realmsList != null) {
       for (Realm realm : realmsList) {
-        String name = realm.getClass().getName();
-
-        LOG.debug("RealmClass.getName: {}", name);
-
-        if (name.equals("org.apache.zeppelin.realm.jwt.KnoxJwtRealm")) {
+        if (realm instanceof KnoxJwtRealm) {
           return (KnoxJwtRealm) realm;
         }
       }
@@ -165,9 +161,7 @@ public class LoginRestApi {
     Collection<Realm> realmsList = authenticationService.getRealmsList();
     if (realmsList != null) {
       for (Realm realm : realmsList) {
-        String name = realm.getClass().getName();
-        LOG.debug("RealmClass.getName: {}", name);
-        if (name.equals("org.apache.zeppelin.realm.jwt.KnoxJwtRealm")) {
+        if (realm instanceof KnoxJwtRealm) {
           return true;
         }
       }