Source:
public Connection getConnection(String dbPrefix, InterpreterContext context) throws ClassNotFoundException, SQLException, InterpreterException, IOException { final String user = context.getAuthenticationInfo().getUser(); Connection connection; if (dbPrefix == null || basePropertiesMap.get(dbPrefix) == null) { return null; } JDBCUserConfigurations jdbcUserConfigurations = getJDBCConfiguration(user); setUserProperty(dbPrefix, context); final Properties properties = jdbcUserConfigurations.getPropertyMap(dbPrefix); String url = properties.getProperty(URL_KEY); String principal = getProperty("zeppelin.jdbc.principal"); if (!StringUtils.isBlank(principal) && !url.contains("principal=")) { url = url + ";principal=" + principal; } if (isEmpty(getProperty("zeppelin.jdbc.auth.type"))) { connection = getConnectionFromPool(url, user, dbPrefix, properties); } else { UserGroupInformation.AuthenticationMethod authType = JDBCSecurityImpl.getAuthType(getProperties()); final String connectionUrl = appendProxyUserToURL(url, user, dbPrefix); JDBCSecurityImpl.createSecureConfiguration(getProperties(), authType); if (basePropertiesMap.get(dbPrefix).containsKey("proxy.user.property")) { connection = getConnectionFromPool(connectionUrl, user, dbPrefix, properties); } else { UserGroupInformation ugi = null; try { ugi = UserGroupInformation.createProxyUser( user, UserGroupInformation.getCurrentUser()); } catch (Exception e) { LOGGER.error("Error in getCurrentUser", e); throw new InterpreterException("Error in getCurrentUser", e); } final String poolKey = dbPrefix; try { connection = ugi.doAs((PrivilegedExceptionAction<Connection>) () -> getConnectionFromPool(connectionUrl, user, poolKey, properties)); } catch (Exception e) { LOGGER.error("Error in doAs", e); throw new InterpreterException("Error in doAs", e); } } } return connection; }

Target:
public Connection getConnection(String dbPrefix, InterpreterContext context) throws ClassNotFoundException, SQLException, InterpreterException, IOException { final String user = context.getAuthenticationInfo().getUser(); Connection connection; if (dbPrefix == null || basePropertiesMap.get(dbPrefix) == null) { return null; } JDBCUserConfigurations jdbcUserConfigurations = getJDBCConfiguration(user); setUserProperty(dbPrefix, context); final Properties properties = jdbcUserConfigurations.getPropertyMap(dbPrefix); String url = properties.getProperty(URL_KEY); if (isEmpty(getProperty("zeppelin.jdbc.auth.type"))) { connection = getConnectionFromPool(url, user, dbPrefix, properties); } else { UserGroupInformation.AuthenticationMethod authType = JDBCSecurityImpl.getAuthType(getProperties()); final String connectionUrl = appendProxyUserToURL(url, user, dbPrefix); JDBCSecurityImpl.createSecureConfiguration(getProperties(), authType); if (basePropertiesMap.get(dbPrefix).containsKey("proxy.user.property")) { connection = getConnectionFromPool(connectionUrl, user, dbPrefix, properties); } else { UserGroupInformation ugi = null; try { ugi = UserGroupInformation.createProxyUser( user, UserGroupInformation.getCurrentUser()); } catch (Exception e) { LOGGER.error("Error in getCurrentUser", e); throw new InterpreterException("Error in getCurrentUser", e); } final String poolKey = dbPrefix; try { connection = ugi.doAs((PrivilegedExceptionAction<Connection>) () -> getConnectionFromPool(connectionUrl, user, poolKey, properties)); } catch (Exception e) { LOGGER.error("Error in doAs", e); throw new InterpreterException("Error in doAs", e); } } } return connection; }